comparison test/integration/issues_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
20 class IssuesTest < ActionController::IntegrationTest 20 class IssuesTest < ActionController::IntegrationTest
21 fixtures :projects, 21 fixtures :projects,
22 :users, 22 :users,
23 :roles, 23 :roles,
24 :members, 24 :members,
25 :member_roles,
25 :trackers, 26 :trackers,
26 :projects_trackers, 27 :projects_trackers,
27 :enabled_modules, 28 :enabled_modules,
28 :issue_statuses, 29 :issue_statuses,
29 :issues, 30 :issues,
62 assert_equal 'jsmith', issue.author.login 63 assert_equal 'jsmith', issue.author.login
63 assert_equal 1, issue.project.id 64 assert_equal 1, issue.project.id
64 assert_equal 1, issue.status.id 65 assert_equal 1, issue.status.id
65 end 66 end
66 67
68 def test_update_issue_form
69 log_user('jsmith', 'jsmith')
70 post 'projects/ecookbook/issues/new', :issue => { :tracker_id => "2"}
71 assert_response :success
72 assert_tag 'select',
73 :attributes => {:name => 'issue[tracker_id]'},
74 :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
75 end
76
67 # add then remove 2 attachments to an issue 77 # add then remove 2 attachments to an issue
68 def test_issue_attachments 78 def test_issue_attachments
69 log_user('jsmith', 'jsmith') 79 log_user('jsmith', 'jsmith')
70 set_tmp_attachments_directory 80 set_tmp_attachments_directory
71 81
87 # remove the attachments 97 # remove the attachments
88 Issue.find(1).attachments.each(&:destroy) 98 Issue.find(1).attachments.each(&:destroy)
89 assert_equal 0, Issue.find(1).attachments.length 99 assert_equal 0, Issue.find(1).attachments.length
90 end 100 end
91 101
92 def test_other_formats_links_on_get_index 102 def test_other_formats_links_on_index
93 get '/projects/ecookbook/issues' 103 get '/projects/ecookbook/issues'
94 104
95 %w(Atom PDF CSV).each do |format| 105 %w(Atom PDF CSV).each do |format|
96 assert_tag :a, :content => format, 106 assert_tag :a, :content => format,
97 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}", 107 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
98 :rel => 'nofollow' } 108 :rel => 'nofollow' }
99 end 109 end
100 end 110 end
101 111
102 def test_other_formats_links_on_post_index_without_project_id_in_url 112 def test_other_formats_links_on_index_without_project_id_in_url
103 post '/issues', :project_id => 'ecookbook' 113 get '/issues', :project_id => 'ecookbook'
104 114
105 %w(Atom PDF CSV).each do |format| 115 %w(Atom PDF CSV).each do |format|
106 assert_tag :a, :content => format, 116 assert_tag :a, :content => format,
107 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}", 117 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
108 :rel => 'nofollow' } 118 :rel => 'nofollow' }
109 end 119 end
110 end 120 end
111 121
112 def test_pagination_links_on_get_index 122 def test_pagination_links_on_index
113 Setting.per_page_options = '2' 123 Setting.per_page_options = '2'
114 get '/projects/ecookbook/issues' 124 get '/projects/ecookbook/issues'
115 125
116 assert_tag :a, :content => '2', 126 assert_tag :a, :content => '2',
117 :attributes => { :href => '/projects/ecookbook/issues?page=2' } 127 :attributes => { :href => '/projects/ecookbook/issues?page=2' }
118 128
119 end 129 end
120 130
121 def test_pagination_links_on_post_index_without_project_id_in_url 131 def test_pagination_links_on_index_without_project_id_in_url
122 Setting.per_page_options = '2' 132 Setting.per_page_options = '2'
123 post '/issues', :project_id => 'ecookbook' 133 get '/issues', :project_id => 'ecookbook'
124 134
125 assert_tag :a, :content => '2', 135 assert_tag :a, :content => '2',
126 :attributes => { :href => '/projects/ecookbook/issues?page=2' } 136 :attributes => { :href => '/projects/ecookbook/issues?page=2' }
127 137
128 end 138 end
195 :sibling => { 205 :sibling => {
196 :content => new_tester.name 206 :content => new_tester.name
197 } 207 }
198 } 208 }
199 end 209 end
210
211 def test_update_using_invalid_http_verbs
212 subject = 'Updated by an invalid http verb'
213
214 get '/issues/update/1', {:issue => {:subject => subject}}, credentials('jsmith')
215 assert_response 404
216 assert_not_equal subject, Issue.find(1).subject
217
218 post '/issues/1', {:issue => {:subject => subject}}, credentials('jsmith')
219 assert_response 404
220 assert_not_equal subject, Issue.find(1).subject
221 end
222
223 def test_get_watch_should_be_invalid
224 assert_no_difference 'Watcher.count' do
225 get '/watchers/watch?object_type=issue&object_id=1', {}, credentials('jsmith')
226 assert_response 404
227 end
228 end
200 end 229 end