@@ -45,7 +45,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
45 | 45 | def test_new_with_copy |
|
46 | 46 | copy_from = Role.find(2) |
|
47 | 47 | |
|
48 | get :new, :copy => copy_from.id.to_s | |
|
48 | get :new, :params => {:copy => copy_from.id.to_s} | |
|
49 | 49 | assert_response :success |
|
50 | 50 | assert_template 'new' |
|
51 | 51 | |
@@ -68,20 +68,26 class RolesControllerTest < Redmine::ControllerTest | |||
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_create_with_validaton_failure |
|
71 |
post :create, : |
|
|
72 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
73 | :assignable => '0'} | |
|
74 | ||
|
71 | post :create, :params => { | |
|
72 | :role => { | |
|
73 | :name => '', | |
|
74 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
75 | :assignable => '0' | |
|
76 | } | |
|
77 | } | |
|
75 | 78 | assert_response :success |
|
76 | 79 | assert_template 'new' |
|
77 | 80 | assert_select 'div#errorExplanation' |
|
78 | 81 | end |
|
79 | 82 | |
|
80 | 83 | def test_create_without_workflow_copy |
|
81 | post :create, :role => {:name => 'RoleWithoutWorkflowCopy', | |
|
82 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
83 | :assignable => '0'} | |
|
84 | ||
|
84 | post :create, :params => { | |
|
85 | :role => { | |
|
86 | :name => 'RoleWithoutWorkflowCopy', | |
|
87 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
88 | :assignable => '0' | |
|
89 | } | |
|
90 | } | |
|
85 | 91 | assert_redirected_to '/roles' |
|
86 | 92 | role = Role.find_by_name('RoleWithoutWorkflowCopy') |
|
87 | 93 | assert_not_nil role |
@@ -90,11 +96,14 class RolesControllerTest < Redmine::ControllerTest | |||
|
90 | 96 | end |
|
91 | 97 | |
|
92 | 98 | def test_create_with_workflow_copy |
|
93 | post :create, :role => {:name => 'RoleWithWorkflowCopy', | |
|
94 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
95 | :assignable => '0'}, | |
|
96 | :copy_workflow_from => '1' | |
|
97 | ||
|
99 | post :create, :params => { | |
|
100 | :role => { | |
|
101 | :name => 'RoleWithWorkflowCopy', | |
|
102 | :permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |
|
103 | :assignable => '0' | |
|
104 | }, | |
|
105 | :copy_workflow_from => '1' | |
|
106 | } | |
|
98 | 107 | assert_redirected_to '/roles' |
|
99 | 108 | role = Role.find_by_name('RoleWithWorkflowCopy') |
|
100 | 109 | assert_not_nil role |
@@ -102,7 +111,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
102 | 111 | end |
|
103 | 112 | |
|
104 | 113 | def test_edit |
|
105 | get :edit, :id => 1 | |
|
114 | get :edit, :params => {:id => 1} | |
|
106 | 115 | assert_response :success |
|
107 | 116 | assert_template 'edit' |
|
108 | 117 | assert_equal Role.find(1), assigns(:role) |
@@ -110,34 +119,39 class RolesControllerTest < Redmine::ControllerTest | |||
|
110 | 119 | end |
|
111 | 120 | |
|
112 | 121 | def test_edit_anonymous |
|
113 | get :edit, :id => Role.anonymous.id | |
|
122 | get :edit, :params => {:id => Role.anonymous.id} | |
|
114 | 123 | assert_response :success |
|
115 | 124 | assert_template 'edit' |
|
116 | 125 | assert_select 'select[name=?]', 'role[issues_visibility]', 0 |
|
117 | 126 | end |
|
118 | 127 | |
|
119 | 128 | def test_edit_invalid_should_respond_with_404 |
|
120 | get :edit, :id => 999 | |
|
129 | get :edit, :params => {:id => 999} | |
|
121 | 130 | assert_response 404 |
|
122 | 131 | end |
|
123 | 132 | |
|
124 | 133 | def test_update |
|
125 |
put :update, : |
|
|
126 | :role => {:name => 'Manager', | |
|
127 | :permissions => ['edit_project', ''], | |
|
128 | :assignable => '0'} | |
|
129 | ||
|
134 | put :update, :params => { | |
|
135 | :id => 1, | |
|
136 | :role => { | |
|
137 | :name => 'Manager', | |
|
138 | :permissions => ['edit_project', ''], | |
|
139 | :assignable => '0' | |
|
140 | } | |
|
141 | } | |
|
130 | 142 | assert_redirected_to '/roles' |
|
131 | 143 | role = Role.find(1) |
|
132 | 144 | assert_equal [:edit_project], role.permissions |
|
133 | 145 | end |
|
134 | 146 | |
|
135 | 147 | def test_update_trackers_permissions |
|
136 |
put :update, : |
|
|
137 | :permissions_all_trackers => {'add_issues' => '0'}, | |
|
138 | :permissions_tracker_ids => {'add_issues' => ['1', '3', '']} | |
|
148 | put :update, :params => { | |
|
149 | :id => 1, | |
|
150 | :role => { | |
|
151 | :permissions_all_trackers => {'add_issues' => '0'}, | |
|
152 | :permissions_tracker_ids => {'add_issues' => ['1', '3', '']} | |
|
153 | } | |
|
139 | 154 | } |
|
140 | ||
|
141 | 155 | assert_redirected_to '/roles' |
|
142 | 156 | role = Role.find(1) |
|
143 | 157 | |
@@ -149,7 +163,7 class RolesControllerTest < Redmine::ControllerTest | |||
|
149 | 163 | end |
|
150 | 164 | |
|
151 | 165 | def test_update_with_failure |
|
152 | put :update, :id => 1, :role => {:name => ''} | |
|
166 | put :update, :params => {:id => 1, :role => {:name => ''}} | |
|
153 | 167 | assert_response :success |
|
154 | 168 | assert_template 'edit' |
|
155 | 169 | end |
@@ -157,13 +171,13 class RolesControllerTest < Redmine::ControllerTest | |||
|
157 | 171 | def test_destroy |
|
158 | 172 | r = Role.create!(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages]) |
|
159 | 173 | |
|
160 | delete :destroy, :id => r | |
|
174 | delete :destroy, :params => {:id => r} | |
|
161 | 175 | assert_redirected_to '/roles' |
|
162 | 176 | assert_nil Role.find_by_id(r.id) |
|
163 | 177 | end |
|
164 | 178 | |
|
165 | 179 | def test_destroy_role_in_use |
|
166 | delete :destroy, :id => 1 | |
|
180 | delete :destroy, :params => {:id => 1} | |
|
167 | 181 | assert_redirected_to '/roles' |
|
168 | 182 | assert_equal 'This role is in use and cannot be deleted.', flash[:error] |
|
169 | 183 | assert_not_nil Role.find_by_id(1) |
@@ -182,7 +196,13 class RolesControllerTest < Redmine::ControllerTest | |||
|
182 | 196 | end |
|
183 | 197 | |
|
184 | 198 | def test_post_permissions |
|
185 | post :permissions, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']} | |
|
199 | post :permissions, :params => { | |
|
200 | :permissions => { | |
|
201 | '0' => '', | |
|
202 | '1' => ['edit_issues'], | |
|
203 | '3' => ['add_issues', 'delete_issues'] | |
|
204 | } | |
|
205 | } | |
|
186 | 206 | assert_redirected_to '/roles' |
|
187 | 207 | |
|
188 | 208 | assert_equal [:edit_issues], Role.find(1).permissions |
@@ -191,33 +211,33 class RolesControllerTest < Redmine::ControllerTest | |||
|
191 | 211 | end |
|
192 | 212 | |
|
193 | 213 | def test_clear_all_permissions |
|
194 | post :permissions, :permissions => { '0' => '' } | |
|
214 | post :permissions, :params => {:permissions => { '0' => '' }} | |
|
195 | 215 | assert_redirected_to '/roles' |
|
196 | 216 | assert Role.find(1).permissions.empty? |
|
197 | 217 | end |
|
198 | 218 | |
|
199 | 219 | def test_move_highest |
|
200 | put :update, :id => 3, :role => {:position => 1} | |
|
220 | put :update, :params => {:id => 3, :role => {:position => 1}} | |
|
201 | 221 | assert_redirected_to '/roles' |
|
202 | 222 | assert_equal 1, Role.find(3).position |
|
203 | 223 | end |
|
204 | 224 | |
|
205 | 225 | def test_move_higher |
|
206 | 226 | position = Role.find(3).position |
|
207 | put :update, :id => 3, :role => {:position => position - 1} | |
|
227 | put :update, :params => {:id => 3, :role => {:position => position - 1}} | |
|
208 | 228 | assert_redirected_to '/roles' |
|
209 | 229 | assert_equal position - 1, Role.find(3).position |
|
210 | 230 | end |
|
211 | 231 | |
|
212 | 232 | def test_move_lower |
|
213 | 233 | position = Role.find(2).position |
|
214 | put :update, :id => 2, :role => {:position => position + 1} | |
|
234 | put :update, :params => {:id => 2, :role => {:position => position + 1}} | |
|
215 | 235 | assert_redirected_to '/roles' |
|
216 | 236 | assert_equal position + 1, Role.find(2).position |
|
217 | 237 | end |
|
218 | 238 | |
|
219 | 239 | def test_move_lowest |
|
220 | put :update, :id => 2, :role => {:position => Role.givable.count} | |
|
240 | put :update, :params => {:id => 2, :role => {:position => Role.givable.count}} | |
|
221 | 241 | assert_redirected_to '/roles' |
|
222 | 242 | assert_equal Role.givable.count, Role.find(2).position |
|
223 | 243 | end |
@@ -35,7 +35,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
35 | 35 | assert_response :success |
|
36 | 36 | assert_template 'index' |
|
37 | 37 | |
|
38 | get :index, :q => "cook" | |
|
38 | get :index, :params => {:q => "cook"} | |
|
39 | 39 | assert_response :success |
|
40 | 40 | assert_template 'index' |
|
41 | 41 | assert assigns(:results).include?(Project.find(1)) |
@@ -43,30 +43,30 class SearchControllerTest < Redmine::ControllerTest | |||
|
43 | 43 | |
|
44 | 44 | def test_search_on_archived_project_should_return_404 |
|
45 | 45 | Project.find(3).archive |
|
46 | get :index, :id => 3 | |
|
46 | get :index, :params => {:id => 3} | |
|
47 | 47 | assert_response 404 |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | def test_search_on_invisible_project_by_user_should_be_denied |
|
51 | 51 | @request.session[:user_id] = 7 |
|
52 | get :index, :id => 2 | |
|
52 | get :index, :params => {:id => 2} | |
|
53 | 53 | assert_response 403 |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def test_search_on_invisible_project_by_anonymous_user_should_redirect |
|
57 | get :index, :id => 2 | |
|
57 | get :index, :params => {:id => 2} | |
|
58 | 58 | assert_response 302 |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | def test_search_on_private_project_by_member_should_succeed |
|
62 | 62 | @request.session[:user_id] = 2 |
|
63 | get :index, :id => 2 | |
|
63 | get :index, :params => {:id => 2} | |
|
64 | 64 | assert_response :success |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def test_search_all_projects |
|
68 | 68 | with_settings :default_language => 'en' do |
|
69 | get :index, :q => 'recipe subproject commit', :all_words => '' | |
|
69 | get :index, :params => {:q => 'recipe subproject commit', :all_words => ''} | |
|
70 | 70 | end |
|
71 | 71 | assert_response :success |
|
72 | 72 | assert_template 'index' |
@@ -83,7 +83,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def test_search_issues |
|
86 | get :index, :q => 'issue', :issues => 1 | |
|
86 | get :index, :params => {:q => 'issue', :issues => 1} | |
|
87 | 87 | assert_response :success |
|
88 | 88 | assert_template 'index' |
|
89 | 89 | |
@@ -97,7 +97,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
97 | 97 | def test_search_issues_should_search_notes |
|
98 | 98 | Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') |
|
99 | 99 | |
|
100 | get :index, :q => 'searchkeyword', :issues => 1 | |
|
100 | get :index, :params => {:q => 'searchkeyword', :issues => 1} | |
|
101 | 101 | assert_response :success |
|
102 | 102 | assert_include Issue.find(2), assigns(:results) |
|
103 | 103 | end |
@@ -106,7 +106,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
106 | 106 | Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') |
|
107 | 107 | Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') |
|
108 | 108 | |
|
109 | get :index, :q => 'searchkeyword', :issues => 1 | |
|
109 | get :index, :params => {:q => 'searchkeyword', :issues => 1} | |
|
110 | 110 | assert_response :success |
|
111 | 111 | assert_include Issue.find(2), assigns(:results) |
|
112 | 112 | assert_equal 1, assigns(:results).size |
@@ -117,18 +117,18 class SearchControllerTest < Redmine::ControllerTest | |||
|
117 | 117 | @request.session[:user_id] = 2 |
|
118 | 118 | |
|
119 | 119 | Role.find(1).add_permission! :view_private_notes |
|
120 | get :index, :q => 'searchkeyword', :issues => 1 | |
|
120 | get :index, :params => {:q => 'searchkeyword', :issues => 1} | |
|
121 | 121 | assert_response :success |
|
122 | 122 | assert_include Issue.find(2), assigns(:results) |
|
123 | 123 | |
|
124 | 124 | Role.find(1).remove_permission! :view_private_notes |
|
125 | get :index, :q => 'searchkeyword', :issues => 1 | |
|
125 | get :index, :params => {:q => 'searchkeyword', :issues => 1} | |
|
126 | 126 | assert_response :success |
|
127 | 127 | assert_not_include Issue.find(2), assigns(:results) |
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | def test_search_all_projects_with_scope_param |
|
131 | get :index, :q => 'issue', :scope => 'all' | |
|
131 | get :index, :params => {:q => 'issue', :scope => 'all'} | |
|
132 | 132 | assert_response :success |
|
133 | 133 | assert_template 'index' |
|
134 | 134 | assert assigns(:results).present? |
@@ -136,7 +136,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
136 | 136 | |
|
137 | 137 | def test_search_my_projects |
|
138 | 138 | @request.session[:user_id] = 2 |
|
139 | get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => '' | |
|
139 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} | |
|
140 | 140 | assert_response :success |
|
141 | 141 | assert_template 'index' |
|
142 | 142 | assert assigns(:results).include?(Issue.find(1)) |
@@ -145,14 +145,14 class SearchControllerTest < Redmine::ControllerTest | |||
|
145 | 145 | |
|
146 | 146 | def test_search_my_projects_without_memberships |
|
147 | 147 | # anonymous user has no memberships |
|
148 | get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => '' | |
|
148 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} | |
|
149 | 149 | assert_response :success |
|
150 | 150 | assert_template 'index' |
|
151 | 151 | assert assigns(:results).empty? |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | def test_search_project_and_subprojects |
|
155 | get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => '' | |
|
155 | get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''} | |
|
156 | 156 | assert_response :success |
|
157 | 157 | assert_template 'index' |
|
158 | 158 | assert assigns(:results).include?(Issue.find(1)) |
@@ -162,18 +162,18 class SearchControllerTest < Redmine::ControllerTest | |||
|
162 | 162 | def test_search_without_searchable_custom_fields |
|
163 | 163 | CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" |
|
164 | 164 | |
|
165 | get :index, :id => 1 | |
|
165 | get :index, :params => {:id => 1} | |
|
166 | 166 | assert_response :success |
|
167 | 167 | assert_template 'index' |
|
168 | 168 | assert_not_nil assigns(:project) |
|
169 | 169 | |
|
170 | get :index, :id => 1, :q => "can" | |
|
170 | get :index, :params => {:id => 1, :q => "can"} | |
|
171 | 171 | assert_response :success |
|
172 | 172 | assert_template 'index' |
|
173 | 173 | end |
|
174 | 174 | |
|
175 | 175 | def test_search_with_searchable_custom_fields |
|
176 | get :index, :id => 1, :q => "stringforcustomfield" | |
|
176 | get :index, :params => {:id => 1, :q => "stringforcustomfield"} | |
|
177 | 177 | assert_response :success |
|
178 | 178 | results = assigns(:results) |
|
179 | 179 | assert_not_nil results |
@@ -185,7 +185,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
185 | 185 | issue = Issue.generate! :subject => 'search_attachments' |
|
186 | 186 | attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
187 | 187 | |
|
188 | get :index, :id => 1, :q => 'search_attachments', :attachments => '0' | |
|
188 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'} | |
|
189 | 189 | results = assigns(:results) |
|
190 | 190 | assert_equal 1, results.size |
|
191 | 191 | assert_equal issue, results.first |
@@ -195,7 +195,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
195 | 195 | issue = Issue.generate! :subject => 'search_attachments' |
|
196 | 196 | attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
197 | 197 | |
|
198 | get :index, :id => 1, :q => 'search_attachments', :attachments => 'only' | |
|
198 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'} | |
|
199 | 199 | results = assigns(:results) |
|
200 | 200 | assert_equal 1, results.size |
|
201 | 201 | assert_equal attachment.container, results.first |
@@ -205,7 +205,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
205 | 205 | Issue.generate! :subject => 'search_attachments' |
|
206 | 206 | Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' |
|
207 | 207 | |
|
208 | get :index, :id => 1, :q => 'search_attachments', :attachments => '1' | |
|
208 | get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'} | |
|
209 | 209 | results = assigns(:results) |
|
210 | 210 | assert_equal 2, results.size |
|
211 | 211 | end |
@@ -214,14 +214,14 class SearchControllerTest < Redmine::ControllerTest | |||
|
214 | 214 | Issue.generate! :subject => 'search_open' |
|
215 | 215 | Issue.generate! :subject => 'search_open', :status_id => 5 |
|
216 | 216 | |
|
217 | get :index, :id => 1, :q => 'search_open', :open_issues => '1' | |
|
217 | get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'} | |
|
218 | 218 | results = assigns(:results) |
|
219 | 219 | assert_equal 1, results.size |
|
220 | 220 | end |
|
221 | 221 | |
|
222 | 222 | def test_search_all_words |
|
223 | 223 | # 'all words' is on by default |
|
224 | get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1' | |
|
224 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'} | |
|
225 | 225 | assert_equal true, assigns(:all_words) |
|
226 | 226 | results = assigns(:results) |
|
227 | 227 | assert_not_nil results |
@@ -230,7 +230,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
230 | 230 | end |
|
231 | 231 | |
|
232 | 232 | def test_search_one_of_the_words |
|
233 | get :index, :id => 1, :q => 'recipe updating saving', :all_words => '' | |
|
233 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''} | |
|
234 | 234 | assert_equal false, assigns(:all_words) |
|
235 | 235 | results = assigns(:results) |
|
236 | 236 | assert_not_nil results |
@@ -239,14 +239,14 class SearchControllerTest < Redmine::ControllerTest | |||
|
239 | 239 | end |
|
240 | 240 | |
|
241 | 241 | def test_search_titles_only_without_result |
|
242 | get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1' | |
|
242 | get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'} | |
|
243 | 243 | results = assigns(:results) |
|
244 | 244 | assert_not_nil results |
|
245 | 245 | assert_equal 0, results.size |
|
246 | 246 | end |
|
247 | 247 | |
|
248 | 248 | def test_search_titles_only |
|
249 | get :index, :id => 1, :q => 'recipe', :titles_only => '1' | |
|
249 | get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'} | |
|
250 | 250 | assert_equal true, assigns(:titles_only) |
|
251 | 251 | results = assigns(:results) |
|
252 | 252 | assert_not_nil results |
@@ -255,7 +255,8 class SearchControllerTest < Redmine::ControllerTest | |||
|
255 | 255 | |
|
256 | 256 | def test_search_content |
|
257 | 257 | Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'") |
|
258 | get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => '' | |
|
258 | ||
|
259 | get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''} | |
|
259 | 260 | assert_equal false, assigns(:titles_only) |
|
260 | 261 | results = assigns(:results) |
|
261 | 262 | assert_not_nil results |
@@ -265,54 +266,54 class SearchControllerTest < Redmine::ControllerTest | |||
|
265 | 266 | def test_search_with_pagination |
|
266 | 267 | issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse |
|
267 | 268 | |
|
268 | get :index, :q => 'search_with_limited_results' | |
|
269 | get :index, :params => {:q => 'search_with_limited_results'} | |
|
269 | 270 | assert_response :success |
|
270 | 271 | assert_equal issue[0..9], assigns(:results) |
|
271 | 272 | |
|
272 | get :index, :q => 'search_with_limited_results', :page => 2 | |
|
273 | get :index, :params => {:q => 'search_with_limited_results', :page => 2} | |
|
273 | 274 | assert_response :success |
|
274 | 275 | assert_equal issue[10..19], assigns(:results) |
|
275 | 276 | |
|
276 | get :index, :q => 'search_with_limited_results', :page => 3 | |
|
277 | get :index, :params => {:q => 'search_with_limited_results', :page => 3} | |
|
277 | 278 | assert_response :success |
|
278 | 279 | assert_equal issue[20..24], assigns(:results) |
|
279 | 280 | |
|
280 | get :index, :q => 'search_with_limited_results', :page => 4 | |
|
281 | get :index, :params => {:q => 'search_with_limited_results', :page => 4} | |
|
281 | 282 | assert_response :success |
|
282 | 283 | assert_equal [], assigns(:results) |
|
283 | 284 | end |
|
284 | 285 | |
|
285 | 286 | def test_search_with_invalid_project_id |
|
286 | get :index, :id => 195, :q => 'recipe' | |
|
287 | get :index, :params => {:id => 195, :q => 'recipe'} | |
|
287 | 288 | assert_response 404 |
|
288 | 289 | assert_nil assigns(:results) |
|
289 | 290 | end |
|
290 | 291 | |
|
291 | 292 | def test_quick_jump_to_issue |
|
292 | 293 | # issue of a public project |
|
293 | get :index, :q => "3" | |
|
294 | get :index, :params => {:q => "3"} | |
|
294 | 295 | assert_redirected_to '/issues/3' |
|
295 | 296 | |
|
296 | 297 | # issue of a private project |
|
297 | get :index, :q => "4" | |
|
298 | get :index, :params => {:q => "4"} | |
|
298 | 299 | assert_response :success |
|
299 | 300 | assert_template 'index' |
|
300 | 301 | end |
|
301 | 302 | |
|
302 | 303 | def test_large_integer |
|
303 | get :index, :q => '4615713488' | |
|
304 | get :index, :params => {:q => '4615713488'} | |
|
304 | 305 | assert_response :success |
|
305 | 306 | assert_template 'index' |
|
306 | 307 | end |
|
307 | 308 | |
|
308 | 309 | def test_tokens_with_quotes |
|
309 | get :index, :id => 1, :q => '"good bye" hello "bye bye"' | |
|
310 | get :index, :params => {:id => 1, :q => '"good bye" hello "bye bye"'} | |
|
310 | 311 | assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) |
|
311 | 312 | end |
|
312 | 313 | |
|
313 | 314 | def test_results_should_be_escaped_once |
|
314 | 315 | assert Issue.find(1).update_attributes(:subject => '<subject> escaped_once', :description => '<description> escaped_once') |
|
315 | get :index, :q => 'escaped_once' | |
|
316 | get :index, :params => {:q => 'escaped_once'} | |
|
316 | 317 | assert_response :success |
|
317 | 318 | assert_select '#search-results' do |
|
318 | 319 | assert_select 'dt.issue a', :text => /<subject>/ |
@@ -322,7 +323,7 class SearchControllerTest < Redmine::ControllerTest | |||
|
322 | 323 | |
|
323 | 324 | def test_keywords_should_be_highlighted |
|
324 | 325 | assert Issue.find(1).update_attributes(:subject => 'subject highlighted', :description => 'description highlighted') |
|
325 | get :index, :q => 'highlighted' | |
|
326 | get :index, :params => {:q => 'highlighted'} | |
|
326 | 327 | assert_response :success |
|
327 | 328 | assert_select '#search-results' do |
|
328 | 329 | assert_select 'dt.issue a span.highlight', :text => 'highlighted' |
@@ -64,7 +64,7 class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
64 | 64 | @users_to_test.each do |user, fields| |
|
65 | 65 | @request.session[:user_id] = user.id |
|
66 | 66 | @fields.each_with_index do |field, i| |
|
67 | get :index, :q => "value#{i}" | |
|
67 | get :index, :params => {:q => "value#{i}"} | |
|
68 | 68 | assert_response :success |
|
69 | 69 | # we should get a result only if the custom field is visible |
|
70 | 70 | if fields.include?(field) |
@@ -35,7 +35,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
35 | 35 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => 10.hours.ago, :updated_on => 10.hours.ago) |
|
36 | 36 | created = token.reload.created_on |
|
37 | 37 | |
|
38 |
get :index, |
|
|
38 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
39 | 39 | assert_response :success |
|
40 | 40 | token.reload |
|
41 | 41 | assert_equal created.to_i, token.created_on.to_i |
@@ -48,13 +48,13 class SessionsControllerTest < Redmine::ControllerTest | |||
|
48 | 48 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
49 | 49 | |
|
50 | 50 | with_settings :session_lifetime => '0', :session_timeout => '0' do |
|
51 |
get :index, |
|
|
51 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
52 | 52 | assert_response :success |
|
53 | 53 | end |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def test_user_session_without_token_should_be_reset |
|
57 |
get :index, |
|
|
57 | get :index, :session => {:user_id => 2} | |
|
58 | 58 | assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' |
|
59 | 59 | end |
|
60 | 60 | |
@@ -63,7 +63,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
63 | 63 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
64 | 64 | |
|
65 | 65 | with_settings :session_timeout => '720' do |
|
66 |
get :index, |
|
|
66 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
67 | 67 | assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' |
|
68 | 68 | end |
|
69 | 69 | end |
@@ -73,7 +73,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
73 | 73 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
74 | 74 | |
|
75 | 75 | with_settings :session_timeout => '720' do |
|
76 |
get :index, |
|
|
76 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
77 | 77 | assert_response :success |
|
78 | 78 | end |
|
79 | 79 | end |
@@ -83,7 +83,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
83 | 83 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
84 | 84 | |
|
85 | 85 | with_settings :session_timeout => '60' do |
|
86 |
get :index, |
|
|
86 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
87 | 87 | assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' |
|
88 | 88 | end |
|
89 | 89 | end |
@@ -93,7 +93,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
93 | 93 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
94 | 94 | |
|
95 | 95 | with_settings :session_timeout => '60' do |
|
96 |
get :index, |
|
|
96 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
97 | 97 | assert_response :success |
|
98 | 98 | end |
|
99 | 99 | end |
@@ -106,7 +106,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
106 | 106 | autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago) |
|
107 | 107 | @request.cookies['autologin'] = autologin_token.value |
|
108 | 108 | |
|
109 |
get :index, |
|
|
109 | get :index, :session => {:user_id => 2, :tk => token.value} | |
|
110 | 110 | assert_equal 2, session[:user_id] |
|
111 | 111 | assert_response :success |
|
112 | 112 | assert_not_equal token.value, session[:tk] |
@@ -122,7 +122,7 class SessionsControllerTest < Redmine::ControllerTest | |||
|
122 | 122 | token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) |
|
123 | 123 | |
|
124 | 124 | with_settings :session_timeout => '60' do |
|
125 |
get :index, |
|
|
125 | get :index, :session => {:user_id => user.id, :tk => token.value} | |
|
126 | 126 | assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' |
|
127 | 127 | assert_include "Veuillez vous reconnecter", flash[:error] |
|
128 | 128 | assert_equal :fr, current_language |
@@ -73,11 +73,14 class SettingsControllerTest < Redmine::ControllerTest | |||
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | def test_post_edit_notifications |
|
76 | post :edit, :settings => {:mail_from => 'functional@test.foo', | |
|
77 | :bcc_recipients => '0', | |
|
78 | :notified_events => %w(issue_added issue_updated news_added), | |
|
79 | :emails_footer => 'Test footer' | |
|
80 | } | |
|
76 | post :edit, :params => { | |
|
77 | :settings => { | |
|
78 | :mail_from => 'functional@test.foo', | |
|
79 | :bcc_recipients => '0', | |
|
80 | :notified_events => %w(issue_added issue_updated news_added), | |
|
81 | :emails_footer => 'Test footer' | |
|
82 | } | |
|
83 | } | |
|
81 | 84 | assert_redirected_to '/settings' |
|
82 | 85 | assert_equal 'functional@test.foo', Setting.mail_from |
|
83 | 86 | assert !Setting.bcc_recipients? |
@@ -125,12 +128,14 class SettingsControllerTest < Redmine::ControllerTest | |||
|
125 | 128 | end |
|
126 | 129 | |
|
127 | 130 | def test_post_edit_commit_update_keywords |
|
128 |
post :edit, : |
|
|
129 | :commit_update_keywords => { | |
|
130 | :keywords => ["resolves", "closes"], | |
|
131 | :status_id => ["3", "5"], | |
|
132 |
|
|
|
133 |
|
|
|
131 | post :edit, :params => { | |
|
132 | :settings => { | |
|
133 | :commit_update_keywords => { | |
|
134 | :keywords => ["resolves", "closes"], | |
|
135 | :status_id => ["3", "5"], | |
|
136 | :done_ratio => ["", "100"], | |
|
137 | :if_tracker_id => ["", "2"] | |
|
138 | } | |
|
134 | 139 | } |
|
135 | 140 | } |
|
136 | 141 | assert_redirected_to '/settings' |
@@ -142,10 +147,11 class SettingsControllerTest < Redmine::ControllerTest | |||
|
142 | 147 | |
|
143 | 148 | def test_post_edit_should_send_security_notification_for_notified_settings |
|
144 | 149 | ActionMailer::Base.deliveries.clear |
|
145 |
post :edit, : |
|
|
146 | :login_required => 1 | |
|
150 | post :edit, :params => { | |
|
151 | :settings => { | |
|
152 | :login_required => 1 | |
|
153 | } | |
|
147 | 154 | } |
|
148 | ||
|
149 | 155 | assert_not_nil (mail = ActionMailer::Base.deliveries.last) |
|
150 | 156 | assert_mail_body_match '0.0.0.0', mail |
|
151 | 157 | assert_mail_body_match I18n.t(:setting_login_required), mail |
@@ -161,19 +167,21 class SettingsControllerTest < Redmine::ControllerTest | |||
|
161 | 167 | |
|
162 | 168 | def test_post_edit_should_not_send_security_notification_for_non_notified_settings |
|
163 | 169 | ActionMailer::Base.deliveries.clear |
|
164 |
post :edit, : |
|
|
165 | :app_title => 'MineRed' | |
|
170 | post :edit, :params => { | |
|
171 | :settings => { | |
|
172 | :app_title => 'MineRed' | |
|
173 | } | |
|
166 | 174 | } |
|
167 | ||
|
168 | 175 | assert_nil (mail = ActionMailer::Base.deliveries.last) |
|
169 | 176 | end |
|
170 | 177 | |
|
171 | 178 | def test_post_edit_should_not_send_security_notification_for_unchanged_settings |
|
172 | 179 | ActionMailer::Base.deliveries.clear |
|
173 |
post :edit, : |
|
|
174 | :login_required => 0 | |
|
180 | post :edit, :params => { | |
|
181 | :settings => { | |
|
182 | :login_required => 0 | |
|
183 | } | |
|
175 | 184 | } |
|
176 | ||
|
177 | 185 | assert_nil (mail = ActionMailer::Base.deliveries.last) |
|
178 | 186 | end |
|
179 | 187 | |
@@ -185,7 +193,7 class SettingsControllerTest < Redmine::ControllerTest | |||
|
185 | 193 | end |
|
186 | 194 | Setting.plugin_foo = {'sample_setting' => 'Plugin setting value'} |
|
187 | 195 | |
|
188 | get :plugin, :id => 'foo' | |
|
196 | get :plugin, :params => {:id => 'foo'} | |
|
189 | 197 | assert_response :success |
|
190 | 198 | assert_template 'plugin' |
|
191 | 199 | assert_select 'form[action="/settings/plugin/foo"]' do |
@@ -196,14 +204,14 class SettingsControllerTest < Redmine::ControllerTest | |||
|
196 | 204 | end |
|
197 | 205 | |
|
198 | 206 | def test_get_invalid_plugin_settings |
|
199 | get :plugin, :id => 'none' | |
|
207 | get :plugin, :params => {:id => 'none'} | |
|
200 | 208 | assert_response 404 |
|
201 | 209 | end |
|
202 | 210 | |
|
203 | 211 | def test_get_non_configurable_plugin_settings |
|
204 | 212 | Redmine::Plugin.register(:foo) {} |
|
205 | 213 | |
|
206 | get :plugin, :id => 'foo' | |
|
214 | get :plugin, :params => {:id => 'foo'} | |
|
207 | 215 | assert_response 404 |
|
208 | 216 | |
|
209 | 217 | ensure |
@@ -216,7 +224,10 class SettingsControllerTest < Redmine::ControllerTest | |||
|
216 | 224 | :default => {'sample_setting' => 'Plugin setting value'} |
|
217 | 225 | end |
|
218 | 226 | |
|
219 | post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |
|
227 | post :plugin, :params => { | |
|
228 | :id => 'foo', | |
|
229 | :settings => {'sample_setting' => 'Value'} | |
|
230 | } | |
|
220 | 231 | assert_redirected_to '/settings/plugin/foo' |
|
221 | 232 | |
|
222 | 233 | assert_equal({'sample_setting' => 'Value'}, Setting.plugin_foo) |
@@ -225,7 +236,10 class SettingsControllerTest < Redmine::ControllerTest | |||
|
225 | 236 | def test_post_non_configurable_plugin_settings |
|
226 | 237 | Redmine::Plugin.register(:foo) {} |
|
227 | 238 | |
|
228 | post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |
|
239 | post :plugin, :params => { | |
|
240 | :id => 'foo', | |
|
241 | :settings => {'sample_setting' => 'Value'} | |
|
242 | } | |
|
229 | 243 | assert_response 404 |
|
230 | 244 | |
|
231 | 245 | ensure |
@@ -48,9 +48,11 class SysControllerTest < Redmine::ControllerTest | |||
|
48 | 48 | def test_create_project_repository |
|
49 | 49 | assert_nil Project.find(4).repository |
|
50 | 50 | |
|
51 |
post :create_project_repository, : |
|
|
52 | :vendor => 'Subversion', | |
|
53 | :repository => { :url => 'file:///create/project/repository/subproject2'} | |
|
51 | post :create_project_repository, :params => { | |
|
52 | :id => 4, | |
|
53 | :vendor => 'Subversion', | |
|
54 | :repository => { :url => 'file:///create/project/repository/subproject2'} | |
|
55 | } | |
|
54 | 56 | assert_response :created |
|
55 | 57 | assert_equal 'application/xml', @response.content_type |
|
56 | 58 | |
@@ -67,18 +69,20 class SysControllerTest < Redmine::ControllerTest | |||
|
67 | 69 | end |
|
68 | 70 | |
|
69 | 71 | def test_create_already_existing |
|
70 |
post :create_project_repository, : |
|
|
72 | post :create_project_repository, :params => { | |
|
73 | :id => 1, | |
|
71 | 74 | :vendor => 'Subversion', |
|
72 | 75 | :repository => { :url => 'file:///create/project/repository/subproject2'} |
|
73 | ||
|
76 | } | |
|
74 | 77 | assert_response :conflict |
|
75 | 78 | end |
|
76 | 79 | |
|
77 | 80 | def test_create_with_failure |
|
78 |
post :create_project_repository, : |
|
|
81 | post :create_project_repository, :params => { | |
|
82 | :id => 4, | |
|
79 | 83 | :vendor => 'Subversion', |
|
80 | 84 | :repository => { :url => 'invalid url'} |
|
81 | ||
|
85 | } | |
|
82 | 86 | assert_response :unprocessable_entity |
|
83 | 87 | end |
|
84 | 88 | |
@@ -90,18 +94,18 class SysControllerTest < Redmine::ControllerTest | |||
|
90 | 94 | |
|
91 | 95 | def test_fetch_changesets_one_project_by_identifier |
|
92 | 96 | Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) |
|
93 | get :fetch_changesets, :id => 'ecookbook' | |
|
97 | get :fetch_changesets, :params => {:id => 'ecookbook'} | |
|
94 | 98 | assert_response :success |
|
95 | 99 | end |
|
96 | 100 | |
|
97 | 101 | def test_fetch_changesets_one_project_by_id |
|
98 | 102 | Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) |
|
99 | get :fetch_changesets, :id => '1' | |
|
103 | get :fetch_changesets, :params => {:id => '1'} | |
|
100 | 104 | assert_response :success |
|
101 | 105 | end |
|
102 | 106 | |
|
103 | 107 | def test_fetch_changesets_unknown_project |
|
104 | get :fetch_changesets, :id => 'unknown' | |
|
108 | get :fetch_changesets, :params => {:id => 'unknown'} | |
|
105 | 109 | assert_response 404 |
|
106 | 110 | end |
|
107 | 111 | |
@@ -114,14 +118,14 class SysControllerTest < Redmine::ControllerTest | |||
|
114 | 118 | |
|
115 | 119 | def test_api_key |
|
116 | 120 | with_settings :sys_api_key => 'my_secret_key' do |
|
117 | get :projects, :key => 'my_secret_key' | |
|
121 | get :projects, :params => {:key => 'my_secret_key'} | |
|
118 | 122 | assert_response :success |
|
119 | 123 | end |
|
120 | 124 | end |
|
121 | 125 | |
|
122 | 126 | def test_wrong_key_should_respond_with_403_error |
|
123 | 127 | with_settings :sys_api_enabled => 'my_secret_key' do |
|
124 | get :projects, :key => 'wrong_key' | |
|
128 | get :projects, :params => {:key => 'wrong_key'} | |
|
125 | 129 | assert_response 403 |
|
126 | 130 | end |
|
127 | 131 | end |
@@ -35,7 +35,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
35 | 35 | end |
|
36 | 36 | |
|
37 | 37 | def test_report_at_project_level |
|
38 | get :report, :project_id => 'ecookbook' | |
|
38 | get :report, :params => {:project_id => 'ecookbook'} | |
|
39 | 39 | assert_response :success |
|
40 | 40 | assert_template 'report' |
|
41 | 41 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report' |
@@ -58,7 +58,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def test_report_all_projects_one_criteria |
|
61 | get :report, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project'] | |
|
61 | get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} | |
|
62 | 62 | assert_response :success |
|
63 | 63 | assert_template 'report' |
|
64 | 64 | assert_not_nil assigns(:report) |
@@ -66,7 +66,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | def test_report_all_time |
|
69 | get :report, :project_id => 1, :criteria => ['project', 'issue'] | |
|
69 | get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']} | |
|
70 | 70 | assert_response :success |
|
71 | 71 | assert_template 'report' |
|
72 | 72 | assert_not_nil assigns(:report) |
@@ -74,7 +74,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
74 | 74 | end |
|
75 | 75 | |
|
76 | 76 | def test_report_all_time_by_day |
|
77 | get :report, :project_id => 1, :criteria => ['project', 'issue'], :columns => 'day' | |
|
77 | get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'} | |
|
78 | 78 | assert_response :success |
|
79 | 79 | assert_template 'report' |
|
80 | 80 | assert_not_nil assigns(:report) |
@@ -83,7 +83,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def test_report_one_criteria |
|
86 | get :report, :project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project'] | |
|
86 | get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} | |
|
87 | 87 | assert_response :success |
|
88 | 88 | assert_template 'report' |
|
89 | 89 | assert_not_nil assigns(:report) |
@@ -91,7 +91,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def test_report_two_criteria |
|
94 | get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"] | |
|
94 | get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]} | |
|
95 | 95 | assert_response :success |
|
96 | 96 | assert_template 'report' |
|
97 | 97 | assert_not_nil assigns(:report) |
@@ -104,7 +104,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
104 | 104 | CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1') |
|
105 | 105 | CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value2') |
|
106 | 106 | |
|
107 | get :report, :project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"] | |
|
107 | get :report, :params => {:project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"]} | |
|
108 | 108 | assert_response :success |
|
109 | 109 | end |
|
110 | 110 | |
@@ -112,7 +112,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
112 | 112 | TimeEntryCustomField.create!(:name => 'Single', :field_format => 'list', :possible_values => ['value1', 'value2']) |
|
113 | 113 | TimeEntryCustomField.create!(:name => 'Multi', :field_format => 'list', :multiple => true, :possible_values => ['value1', 'value2']) |
|
114 | 114 | |
|
115 | get :report, :project_id => 1 | |
|
115 | get :report, :params => {:project_id => 1} | |
|
116 | 116 | assert_response :success |
|
117 | 117 | assert_select 'select[name=?]', 'criteria[]' do |
|
118 | 118 | assert_select 'option', :text => 'Single' |
@@ -121,7 +121,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
121 | 121 | end |
|
122 | 122 | |
|
123 | 123 | def test_report_one_day |
|
124 | get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"] | |
|
124 | get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]} | |
|
125 | 125 | assert_response :success |
|
126 | 126 | assert_template 'report' |
|
127 | 127 | assert_not_nil assigns(:report) |
@@ -135,7 +135,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
135 | 135 | TimeEntry.generate!(:hours => '8', :spent_on => '2010-01-01') # 2009-53 |
|
136 | 136 | TimeEntry.generate!(:hours => '16', :spent_on => '2010-01-05') # 2010-1 |
|
137 | 137 | |
|
138 | get :report, :columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"] | |
|
138 | get :report, :params => {:columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"]} | |
|
139 | 139 | assert_response :success |
|
140 | 140 | |
|
141 | 141 | assert_select '#time-report thead tr' do |
@@ -167,7 +167,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
167 | 167 | end |
|
168 | 168 | |
|
169 | 169 | def test_report_with_association_custom_fields |
|
170 | get :report, :criteria => ['cf_1', 'cf_3', 'cf_7'] | |
|
170 | get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']} | |
|
171 | 171 | assert_response :success |
|
172 | 172 | assert_template 'report' |
|
173 | 173 | assert_not_nil assigns(:report) |
@@ -187,7 +187,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
187 | 187 | end |
|
188 | 188 | |
|
189 | 189 | def test_report_one_criteria_no_result |
|
190 | get :report, :project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project'] | |
|
190 | get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']} | |
|
191 | 191 | assert_response :success |
|
192 | 192 | assert_template 'report' |
|
193 | 193 | assert_not_nil assigns(:report) |
@@ -195,7 +195,7 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
195 | 195 | end |
|
196 | 196 | |
|
197 | 197 | def test_report_status_criterion |
|
198 | get :report, :project_id => 1, :criteria => ['status'] | |
|
198 | get :report, :params => {:project_id => 1, :criteria => ['status']} | |
|
199 | 199 | assert_response :success |
|
200 | 200 | assert_template 'report' |
|
201 | 201 | assert_select 'th', :text => 'Status' |
@@ -203,8 +203,13 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
203 | 203 | end |
|
204 | 204 | |
|
205 | 205 | def test_report_all_projects_csv_export |
|
206 | get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", | |
|
207 | :criteria => ["project", "user", "activity"], :format => "csv" | |
|
206 | get :report, :params => { | |
|
207 | :columns => 'month', | |
|
208 | :from => "2007-01-01", | |
|
209 | :to => "2007-06-30", | |
|
210 | :criteria => ["project", "user", "activity"], | |
|
211 | :format => "csv" | |
|
212 | } | |
|
208 | 213 | assert_response :success |
|
209 | 214 | assert_equal 'text/csv; header=present', @response.content_type |
|
210 | 215 | lines = @response.body.chomp.split("\n") |
@@ -215,9 +220,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
215 | 220 | end |
|
216 | 221 | |
|
217 | 222 | def test_report_csv_export |
|
218 |
get :report, :p |
|
|
219 | :from => "2007-01-01", :to => "2007-06-30", | |
|
220 | :criteria => ["project", "user", "activity"], :format => "csv" | |
|
223 | get :report, :params => { | |
|
224 | :project_id => 1, | |
|
225 | :columns => 'month', | |
|
226 | :from => "2007-01-01", | |
|
227 | :to => "2007-06-30", | |
|
228 | :criteria => ["project", "user", "activity"], | |
|
229 | :format => "csv" | |
|
230 | } | |
|
221 | 231 | assert_response :success |
|
222 | 232 | assert_equal 'text/csv; header=present', @response.content_type |
|
223 | 233 | lines = @response.body.chomp.split("\n") |
@@ -248,9 +258,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
248 | 258 | assert_equal 3, te2.user_id |
|
249 | 259 | |
|
250 | 260 | with_settings :default_language => "zh-TW" do |
|
251 |
get :report, :p |
|
|
252 | :from => "2011-11-11", :to => "2011-11-11", | |
|
253 | :criteria => ["user"], :format => "csv" | |
|
261 | get :report, :params => { | |
|
262 | :project_id => 1, | |
|
263 | :columns => 'day', | |
|
264 | :from => "2011-11-11", | |
|
265 | :to => "2011-11-11", | |
|
266 | :criteria => ["user"], | |
|
267 | :format => "csv" | |
|
268 | } | |
|
254 | 269 | end |
|
255 | 270 | assert_response :success |
|
256 | 271 | assert_equal 'text/csv; header=present', @response.content_type |
@@ -290,9 +305,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
290 | 305 | assert_equal 3, te2.user_id |
|
291 | 306 | |
|
292 | 307 | with_settings :default_language => "zh-TW" do |
|
293 |
get :report, :p |
|
|
294 | :from => "2011-11-11", :to => "2011-11-11", | |
|
295 | :criteria => ["user"], :format => "csv" | |
|
308 | get :report, :params => { | |
|
309 | :project_id => 1, | |
|
310 | :columns => 'day', | |
|
311 | :from => "2011-11-11", | |
|
312 | :to => "2011-11-11", | |
|
313 | :criteria => ["user"], | |
|
314 | :format => "csv" | |
|
315 | } | |
|
296 | 316 | end |
|
297 | 317 | assert_response :success |
|
298 | 318 | assert_equal 'text/csv; header=present', @response.content_type |
@@ -321,9 +341,14 class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
|
321 | 341 | assert_equal 7.3, te2.hours |
|
322 | 342 | assert_equal 3, te2.user_id |
|
323 | 343 | |
|
324 |
get :report, :p |
|
|
325 | :from => "2011-11-11", :to => "2011-11-11", | |
|
326 | :criteria => ["user"], :format => "csv" | |
|
344 | get :report, :params => { | |
|
345 | :project_id => 1, | |
|
346 | :columns => 'day', | |
|
347 | :from => "2011-11-11", | |
|
348 | :to => "2011-11-11", | |
|
349 | :criteria => ["user"], | |
|
350 | :format => "csv" | |
|
351 | } | |
|
327 | 352 | assert_response :success |
|
328 | 353 | assert_equal 'text/csv; header=present', @response.content_type |
|
329 | 354 | lines = @response.body.chomp.split("\n") |
@@ -43,7 +43,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
43 | 43 | |
|
44 | 44 | def test_new_with_project_id |
|
45 | 45 | @request.session[:user_id] = 3 |
|
46 | get :new, :project_id => 1 | |
|
46 | get :new, :params => {:project_id => 1} | |
|
47 | 47 | assert_response :success |
|
48 | 48 | assert_template 'new' |
|
49 | 49 | assert_select 'input[name=?][type=hidden]', 'project_id' |
@@ -53,7 +53,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
53 | 53 | |
|
54 | 54 | def test_new_with_issue_id |
|
55 | 55 | @request.session[:user_id] = 3 |
|
56 | get :new, :issue_id => 2 | |
|
56 | get :new, :params => {:issue_id => 2} | |
|
57 | 57 | assert_response :success |
|
58 | 58 | assert_template 'new' |
|
59 | 59 | assert_select 'input[name=?][type=hidden]', 'project_id', 0 |
@@ -63,7 +63,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
63 | 63 | |
|
64 | 64 | def test_new_without_project_should_prefill_the_form |
|
65 | 65 | @request.session[:user_id] = 3 |
|
66 | get :new, :time_entry => {:project_id => '1'} | |
|
66 | get :new, :params => {:time_entry => {:project_id => '1'}} | |
|
67 | 67 | assert_response :success |
|
68 | 68 | assert_template 'new' |
|
69 | 69 | assert_select 'select[name=?]', 'time_entry[project_id]' do |
@@ -81,7 +81,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
81 | 81 | |
|
82 | 82 | def test_new_should_select_default_activity |
|
83 | 83 | @request.session[:user_id] = 3 |
|
84 | get :new, :project_id => 1 | |
|
84 | get :new, :params => {:project_id => 1} | |
|
85 | 85 | assert_response :success |
|
86 | 86 | assert_select 'select[name=?]', 'time_entry[activity_id]' do |
|
87 | 87 | assert_select 'option[selected=selected]', :text => 'Development' |
@@ -90,21 +90,21 class TimelogControllerTest < Redmine::ControllerTest | |||
|
90 | 90 | |
|
91 | 91 | def test_new_should_only_show_active_time_entry_activities |
|
92 | 92 | @request.session[:user_id] = 3 |
|
93 | get :new, :project_id => 1 | |
|
93 | get :new, :params => {:project_id => 1} | |
|
94 | 94 | assert_response :success |
|
95 | 95 | assert_select 'option', :text => 'Inactive Activity', :count => 0 |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | def test_post_new_as_js_should_update_activity_options |
|
99 | 99 | @request.session[:user_id] = 3 |
|
100 | post :new, :time_entry => {:project_id => 1}, :format => 'js' | |
|
100 | post :new, :params => {:time_entry => {:project_id => 1}, :format => 'js'} | |
|
101 | 101 | assert_response :success |
|
102 | 102 | assert_include '#time_entry_activity_id', response.body |
|
103 | 103 | end |
|
104 | 104 | |
|
105 | 105 | def test_get_edit_existing_time |
|
106 | 106 | @request.session[:user_id] = 2 |
|
107 | get :edit, :id => 2, :project_id => nil | |
|
107 | get :edit, :params => {:id => 2, :project_id => nil} | |
|
108 | 108 | assert_response :success |
|
109 | 109 | assert_template 'edit' |
|
110 | 110 | assert_select 'form[action=?]', '/time_entries/2' |
@@ -116,7 +116,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
116 | 116 | te.save!(:validate => false) |
|
117 | 117 | |
|
118 | 118 | @request.session[:user_id] = 1 |
|
119 | get :edit, :project_id => 1, :id => 1 | |
|
119 | get :edit, :params => {:project_id => 1, :id => 1} | |
|
120 | 120 | assert_response :success |
|
121 | 121 | assert_template 'edit' |
|
122 | 122 | # Blank option since nothing is pre-selected |
@@ -126,13 +126,16 class TimelogControllerTest < Redmine::ControllerTest | |||
|
126 | 126 | def test_post_create |
|
127 | 127 | @request.session[:user_id] = 3 |
|
128 | 128 | assert_difference 'TimeEntry.count' do |
|
129 |
post :create, :p |
|
|
130 | :time_entry => {:comments => 'Some work on TimelogControllerTest', | |
|
131 | # Not the default activity | |
|
132 | :activity_id => '11', | |
|
133 | :spent_on => '2008-03-14', | |
|
134 | :issue_id => '1', | |
|
135 | :hours => '7.3'} | |
|
129 | post :create, :params => { | |
|
130 | :project_id => 1, | |
|
131 | :time_entry => {:comments => 'Some work on TimelogControllerTest', | |
|
132 | # Not the default activity | |
|
133 | :activity_id => '11', | |
|
134 | :spent_on => '2008-03-14', | |
|
135 | :issue_id => '1', | |
|
136 | :hours => '7.3' | |
|
137 | } | |
|
138 | } | |
|
136 | 139 | assert_redirected_to '/projects/ecookbook/time_entries' |
|
137 | 140 | end |
|
138 | 141 | |
@@ -149,13 +152,17 class TimelogControllerTest < Redmine::ControllerTest | |||
|
149 | 152 | def test_post_create_with_blank_issue |
|
150 | 153 | @request.session[:user_id] = 3 |
|
151 | 154 | assert_difference 'TimeEntry.count' do |
|
152 |
post :create, :p |
|
|
153 | :time_entry => {:comments => 'Some work on TimelogControllerTest', | |
|
154 | # Not the default activity | |
|
155 | :activity_id => '11', | |
|
156 | :issue_id => '', | |
|
157 | :spent_on => '2008-03-14', | |
|
158 | :hours => '7.3'} | |
|
155 | post :create, :params => { | |
|
156 | :project_id => 1, | |
|
157 | :time_entry => { | |
|
158 | :comments => 'Some work on TimelogControllerTest', | |
|
159 | # Not the default activity | |
|
160 | :activity_id => '11', | |
|
161 | :issue_id => '', | |
|
162 | :spent_on => '2008-03-14', | |
|
163 | :hours => '7.3' | |
|
164 | } | |
|
165 | } | |
|
159 | 166 | assert_redirected_to '/projects/ecookbook/time_entries' |
|
160 | 167 | end |
|
161 | 168 | |
@@ -174,9 +181,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
174 | 181 | |
|
175 | 182 | @request.session[:user_id] = 2 |
|
176 | 183 | assert_no_difference 'TimeEntry.count' do |
|
177 |
post :create, : |
|
|
178 | :project_id => '1', :issue_id => '', | |
|
179 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
184 | post :create, :params => { | |
|
185 | :time_entry => { | |
|
186 | :project_id => '1', :issue_id => '', | |
|
187 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
188 | } | |
|
180 | 189 | } |
|
181 | 190 | end |
|
182 | 191 | end |
@@ -186,9 +195,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
186 | 195 | |
|
187 | 196 | @request.session[:user_id] = 2 |
|
188 | 197 | assert_no_difference 'TimeEntry.count' do |
|
189 |
post :create, : |
|
|
190 | :project_id => '1', :issue_id => '', | |
|
191 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
198 | post :create, :params => { | |
|
199 | :time_entry => { | |
|
200 | :project_id => '1', :issue_id => '', | |
|
201 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
202 | } | |
|
192 | 203 | } |
|
193 | 204 | end |
|
194 | 205 | end |
@@ -198,9 +209,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
198 | 209 | |
|
199 | 210 | @request.session[:user_id] = 2 |
|
200 | 211 | assert_no_difference 'TimeEntry.count' do |
|
201 |
post :create, : |
|
|
202 | :project_id => '', :issue_id => '1', | |
|
203 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
212 | post :create, :params => { | |
|
213 | :time_entry => { | |
|
214 | :project_id => '', :issue_id => '1', | |
|
215 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
216 | } | |
|
204 | 217 | } |
|
205 | 218 | assert_select_error /Issue is invalid/ |
|
206 | 219 | end |
@@ -211,9 +224,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
211 | 224 | |
|
212 | 225 | @request.session[:user_id] = 2 |
|
213 | 226 | assert_no_difference 'TimeEntry.count' do |
|
214 |
post :create, : |
|
|
215 | :project_id => '', :issue_id => '1', | |
|
216 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
227 | post :create, :params => { | |
|
228 | :time_entry => { | |
|
229 | :project_id => '', :issue_id => '1', | |
|
230 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
231 | } | |
|
217 | 232 | } |
|
218 | 233 | assert_select_error /Issue is invalid/ |
|
219 | 234 | end |
@@ -225,9 +240,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
225 | 240 | |
|
226 | 241 | @request.session[:user_id] = 3 |
|
227 | 242 | assert_no_difference 'TimeEntry.count' do |
|
228 |
post :create, : |
|
|
229 | :project_id => '', :issue_id => issue.id.to_s, | |
|
230 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
243 | post :create, :params => { | |
|
244 | :time_entry => { | |
|
245 | :project_id => '', :issue_id => issue.id.to_s, | |
|
246 | :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |
|
247 | } | |
|
231 | 248 | } |
|
232 | 249 | end |
|
233 | 250 | assert_select_error /Issue is invalid/ |
@@ -239,12 +256,16 class TimelogControllerTest < Redmine::ControllerTest | |||
|
239 | 256 | def test_create_and_continue_at_project_level |
|
240 | 257 | @request.session[:user_id] = 2 |
|
241 | 258 | assert_difference 'TimeEntry.count' do |
|
242 |
post :create, : |
|
|
243 | :activity_id => '11', | |
|
244 | :issue_id => '', | |
|
245 | :spent_on => '2008-03-14', | |
|
246 | :hours => '7.3'}, | |
|
247 | :continue => '1' | |
|
259 | post :create, :params => { | |
|
260 | :time_entry => { | |
|
261 | :project_id => '1', | |
|
262 | :activity_id => '11', | |
|
263 | :issue_id => '', | |
|
264 | :spent_on => '2008-03-14', | |
|
265 | :hours => '7.3' | |
|
266 | }, | |
|
267 | :continue => '1' | |
|
268 | } | |
|
248 | 269 | assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=1' |
|
249 | 270 | end |
|
250 | 271 | end |
@@ -252,12 +273,16 class TimelogControllerTest < Redmine::ControllerTest | |||
|
252 | 273 | def test_create_and_continue_at_issue_level |
|
253 | 274 | @request.session[:user_id] = 2 |
|
254 | 275 | assert_difference 'TimeEntry.count' do |
|
255 |
post :create, : |
|
|
256 | :activity_id => '11', | |
|
257 | :issue_id => '1', | |
|
258 | :spent_on => '2008-03-14', | |
|
259 | :hours => '7.3'}, | |
|
260 | :continue => '1' | |
|
276 | post :create, :params => { | |
|
277 | :time_entry => { | |
|
278 | :project_id => '', | |
|
279 | :activity_id => '11', | |
|
280 | :issue_id => '1', | |
|
281 | :spent_on => '2008-03-14', | |
|
282 | :hours => '7.3' | |
|
283 | }, | |
|
284 | :continue => '1' | |
|
285 | } | |
|
261 | 286 | assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=' |
|
262 | 287 | end |
|
263 | 288 | end |
@@ -265,12 +290,16 class TimelogControllerTest < Redmine::ControllerTest | |||
|
265 | 290 | def test_create_and_continue_with_project_id |
|
266 | 291 | @request.session[:user_id] = 2 |
|
267 | 292 | assert_difference 'TimeEntry.count' do |
|
268 |
post :create, :p |
|
|
269 | :time_entry => {:activity_id => '11', | |
|
270 | :issue_id => '', | |
|
271 | :spent_on => '2008-03-14', | |
|
272 | :hours => '7.3'}, | |
|
273 | :continue => '1' | |
|
293 | post :create, :params => { | |
|
294 | :project_id => 1, | |
|
295 | :time_entry => { | |
|
296 | :activity_id => '11', | |
|
297 | :issue_id => '', | |
|
298 | :spent_on => '2008-03-14', | |
|
299 | :hours => '7.3' | |
|
300 | }, | |
|
301 | :continue => '1' | |
|
302 | } | |
|
274 | 303 | assert_redirected_to '/projects/ecookbook/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=' |
|
275 | 304 | end |
|
276 | 305 | end |
@@ -278,12 +307,16 class TimelogControllerTest < Redmine::ControllerTest | |||
|
278 | 307 | def test_create_and_continue_with_issue_id |
|
279 | 308 | @request.session[:user_id] = 2 |
|
280 | 309 | assert_difference 'TimeEntry.count' do |
|
281 |
post :create, : |
|
|
282 | :time_entry => {:activity_id => '11', | |
|
283 | :issue_id => '1', | |
|
284 | :spent_on => '2008-03-14', | |
|
285 | :hours => '7.3'}, | |
|
286 | :continue => '1' | |
|
310 | post :create, :params => { | |
|
311 | :issue_id => 1, | |
|
312 | :time_entry => { | |
|
313 | :activity_id => '11', | |
|
314 | :issue_id => '1', | |
|
315 | :spent_on => '2008-03-14', | |
|
316 | :hours => '7.3' | |
|
317 | }, | |
|
318 | :continue => '1' | |
|
319 | } | |
|
287 | 320 | assert_redirected_to '/issues/1/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=' |
|
288 | 321 | end |
|
289 | 322 | end |
@@ -291,18 +324,21 class TimelogControllerTest < Redmine::ControllerTest | |||
|
291 | 324 | def test_create_without_log_time_permission_should_be_denied |
|
292 | 325 | @request.session[:user_id] = 2 |
|
293 | 326 | Role.find_by_name('Manager').remove_permission! :log_time |
|
294 |
post :create, :p |
|
|
295 | :time_entry => {:activity_id => '11', | |
|
296 | :issue_id => '', | |
|
297 | :spent_on => '2008-03-14', | |
|
298 | :hours => '7.3'} | |
|
299 | ||
|
327 | post :create, :params => { | |
|
328 | :project_id => 1, | |
|
329 | :time_entry => { | |
|
330 | :activity_id => '11', | |
|
331 | :issue_id => '', | |
|
332 | :spent_on => '2008-03-14', | |
|
333 | :hours => '7.3' | |
|
334 | } | |
|
335 | } | |
|
300 | 336 | assert_response 403 |
|
301 | 337 | end |
|
302 | 338 | |
|
303 | 339 | def test_create_without_project_and_issue_should_fail |
|
304 | 340 | @request.session[:user_id] = 2 |
|
305 | post :create, :time_entry => {:issue_id => ''} | |
|
341 | post :create, :params => {:time_entry => {:issue_id => ''}} | |
|
306 | 342 | |
|
307 | 343 | assert_response :success |
|
308 | 344 | assert_template 'new' |
@@ -310,12 +346,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
310 | 346 | |
|
311 | 347 | def test_create_with_failure |
|
312 | 348 | @request.session[:user_id] = 2 |
|
313 |
post :create, :p |
|
|
314 | :time_entry => {:activity_id => '', | |
|
315 | :issue_id => '', | |
|
316 | :spent_on => '2008-03-14', | |
|
317 | :hours => '7.3'} | |
|
318 | ||
|
349 | post :create, :params => { | |
|
350 | :project_id => 1, | |
|
351 | :time_entry => { | |
|
352 | :activity_id => '', | |
|
353 | :issue_id => '', | |
|
354 | :spent_on => '2008-03-14', | |
|
355 | :hours => '7.3' | |
|
356 | } | |
|
357 | } | |
|
319 | 358 | assert_response :success |
|
320 | 359 | assert_template 'new' |
|
321 | 360 | end |
@@ -323,11 +362,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
323 | 362 | def test_create_without_project |
|
324 | 363 | @request.session[:user_id] = 2 |
|
325 | 364 | assert_difference 'TimeEntry.count' do |
|
326 |
post :create, : |
|
|
327 | :activity_id => '11', | |
|
328 | :issue_id => '', | |
|
329 | :spent_on => '2008-03-14', | |
|
330 | :hours => '7.3'} | |
|
365 | post :create, :params => { | |
|
366 | :time_entry => { | |
|
367 | :project_id => '1', | |
|
368 | :activity_id => '11', | |
|
369 | :issue_id => '', | |
|
370 | :spent_on => '2008-03-14', | |
|
371 | :hours => '7.3' | |
|
372 | } | |
|
373 | } | |
|
331 | 374 | end |
|
332 | 375 | |
|
333 | 376 | assert_redirected_to '/projects/ecookbook/time_entries' |
@@ -338,11 +381,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
338 | 381 | def test_create_without_project_should_fail_with_issue_not_inside_project |
|
339 | 382 | @request.session[:user_id] = 2 |
|
340 | 383 | assert_no_difference 'TimeEntry.count' do |
|
341 |
post :create, : |
|
|
342 | :activity_id => '11', | |
|
343 | :issue_id => '5', | |
|
344 | :spent_on => '2008-03-14', | |
|
345 | :hours => '7.3'} | |
|
384 | post :create, :params => { | |
|
385 | :time_entry => { | |
|
386 | :project_id => '1', | |
|
387 | :activity_id => '11', | |
|
388 | :issue_id => '5', | |
|
389 | :spent_on => '2008-03-14', | |
|
390 | :hours => '7.3' | |
|
391 | } | |
|
392 | } | |
|
346 | 393 | end |
|
347 | 394 | |
|
348 | 395 | assert_response :success |
@@ -354,11 +401,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
354 | 401 | Project.find(3).disable_module!(:time_tracking) |
|
355 | 402 | |
|
356 | 403 | assert_no_difference 'TimeEntry.count' do |
|
357 |
post :create, : |
|
|
358 | :activity_id => '11', | |
|
359 | :issue_id => '', | |
|
360 | :spent_on => '2008-03-14', | |
|
361 | :hours => '7.3'} | |
|
404 | post :create, :params => { | |
|
405 | :time_entry => { | |
|
406 | :project_id => '3', | |
|
407 | :activity_id => '11', | |
|
408 | :issue_id => '', | |
|
409 | :spent_on => '2008-03-14', | |
|
410 | :hours => '7.3' | |
|
411 | } | |
|
412 | } | |
|
362 | 413 | end |
|
363 | 414 | |
|
364 | 415 | assert_response 403 |
@@ -367,11 +418,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
367 | 418 | def test_create_without_project_with_failure |
|
368 | 419 | @request.session[:user_id] = 2 |
|
369 | 420 | assert_no_difference 'TimeEntry.count' do |
|
370 |
post :create, : |
|
|
371 | :activity_id => '11', | |
|
372 | :issue_id => '', | |
|
373 | :spent_on => '2008-03-14', | |
|
374 | :hours => ''} | |
|
421 | post :create, :params => { | |
|
422 | :time_entry => { | |
|
423 | :project_id => '1', | |
|
424 | :activity_id => '11', | |
|
425 | :issue_id => '', | |
|
426 | :spent_on => '2008-03-14', | |
|
427 | :hours => '' | |
|
428 | } | |
|
429 | } | |
|
375 | 430 | end |
|
376 | 431 | |
|
377 | 432 | assert_response :success |
@@ -386,9 +441,13 class TimelogControllerTest < Redmine::ControllerTest | |||
|
386 | 441 | assert_equal 2, entry.user_id |
|
387 | 442 | |
|
388 | 443 | @request.session[:user_id] = 1 |
|
389 |
put :update, : |
|
|
390 | :time_entry => {:issue_id => '2', | |
|
391 | :hours => '8'} | |
|
444 | put :update, :params => { | |
|
445 | :id => 1, | |
|
446 | :time_entry => { | |
|
447 | :issue_id => '2', | |
|
448 | :hours => '8' | |
|
449 | } | |
|
450 | } | |
|
392 | 451 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
393 | 452 | entry.reload |
|
394 | 453 | |
@@ -401,7 +460,12 class TimelogControllerTest < Redmine::ControllerTest | |||
|
401 | 460 | entry = TimeEntry.generate!(:issue_id => 1) |
|
402 | 461 | |
|
403 | 462 | @request.session[:user_id] = 1 |
|
404 | put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |
|
463 | put :update, :params => { | |
|
464 | :id => entry.id, | |
|
465 | :time_entry => { | |
|
466 | :issue_id => '5' | |
|
467 | } | |
|
468 | } | |
|
405 | 469 | assert_response 302 |
|
406 | 470 | entry.reload |
|
407 | 471 | |
@@ -414,14 +478,20 class TimelogControllerTest < Redmine::ControllerTest | |||
|
414 | 478 | Project.find(3).disable_module!(:time_tracking) |
|
415 | 479 | |
|
416 | 480 | @request.session[:user_id] = 1 |
|
417 | put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |
|
481 | put :update, :params => { | |
|
482 | :id => entry.id, | |
|
483 | :time_entry => { | |
|
484 | :issue_id => '5' | |
|
485 | } | |
|
486 | } | |
|
418 | 487 | assert_response 200 |
|
419 | 488 | assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages |
|
420 | 489 | end |
|
421 | 490 | |
|
422 | 491 | def test_get_bulk_edit |
|
423 | 492 | @request.session[:user_id] = 2 |
|
424 | get :bulk_edit, :ids => [1, 2] | |
|
493 | ||
|
494 | get :bulk_edit, :params => {:ids => [1, 2]} | |
|
425 | 495 | assert_response :success |
|
426 | 496 | assert_template 'bulk_edit' |
|
427 | 497 | |
@@ -444,7 +514,8 class TimelogControllerTest < Redmine::ControllerTest | |||
|
444 | 514 | |
|
445 | 515 | def test_get_bulk_edit_on_different_projects |
|
446 | 516 | @request.session[:user_id] = 2 |
|
447 | get :bulk_edit, :ids => [1, 2, 6] | |
|
517 | ||
|
518 | get :bulk_edit, :params => {:ids => [1, 2, 6]} | |
|
448 | 519 | assert_response :success |
|
449 | 520 | assert_template 'bulk_edit' |
|
450 | 521 | end |
@@ -455,14 +526,14 class TimelogControllerTest < Redmine::ControllerTest | |||
|
455 | 526 | Role.find_by_name('Manager').add_permission! :edit_own_time_entries |
|
456 | 527 | ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id} |
|
457 | 528 | |
|
458 | get :bulk_edit, :ids => ids | |
|
529 | get :bulk_edit, :params => {:ids => ids} | |
|
459 | 530 | assert_response :success |
|
460 | 531 | end |
|
461 | 532 | |
|
462 | 533 | def test_bulk_update |
|
463 | 534 | @request.session[:user_id] = 2 |
|
464 | 535 | # update time entry activity |
|
465 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} | |
|
536 | post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9}} | |
|
466 | 537 | |
|
467 | 538 | assert_response 302 |
|
468 | 539 | # check that the issues were updated |
@@ -471,7 +542,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
471 | 542 | |
|
472 | 543 | def test_bulk_update_with_failure |
|
473 | 544 | @request.session[:user_id] = 2 |
|
474 | post :bulk_update, :ids => [1, 2], :time_entry => { :hours => 'A'} | |
|
545 | post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :hours => 'A'}} | |
|
475 | 546 | |
|
476 | 547 | assert_response 302 |
|
477 | 548 | assert_match /Failed to save 2 time entrie/, flash[:error] |
@@ -483,7 +554,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
483 | 554 | Member.create!(:user_id => 2, :project_id => 3, :role_ids => [1]) |
|
484 | 555 | |
|
485 | 556 | # update time entry activity |
|
486 | post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } | |
|
557 | post :bulk_update, :params => {:ids => [1, 2, 4], :time_entry => { :activity_id => 9 }} | |
|
487 | 558 | |
|
488 | 559 | assert_response 302 |
|
489 | 560 | # check that the issues were updated |
@@ -496,7 +567,8 class TimelogControllerTest < Redmine::ControllerTest | |||
|
496 | 567 | action = { :controller => "timelog", :action => "bulk_update" } |
|
497 | 568 | assert user.allowed_to?(action, TimeEntry.find(1).project) |
|
498 | 569 | assert ! user.allowed_to?(action, TimeEntry.find(5).project) |
|
499 | post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 } | |
|
570 | ||
|
571 | post :bulk_update, :params => {:ids => [1, 5], :time_entry => { :activity_id => 9 }} | |
|
500 | 572 | assert_response 403 |
|
501 | 573 | end |
|
502 | 574 | |
@@ -506,7 +578,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
506 | 578 | Role.find_by_name('Manager').add_permission! :edit_own_time_entries |
|
507 | 579 | ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id} |
|
508 | 580 | |
|
509 | post :bulk_update, :ids => ids, :time_entry => { :activity_id => 9 } | |
|
581 | post :bulk_update, :params => {:ids => ids, :time_entry => { :activity_id => 9 }} | |
|
510 | 582 | assert_response 302 |
|
511 | 583 | end |
|
512 | 584 | |
@@ -515,13 +587,13 class TimelogControllerTest < Redmine::ControllerTest | |||
|
515 | 587 | Role.find_by_name('Manager').remove_permission! :edit_time_entries |
|
516 | 588 | Role.find_by_name('Manager').add_permission! :edit_own_time_entries |
|
517 | 589 | |
|
518 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9 } | |
|
590 | post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9 }} | |
|
519 | 591 | assert_response 403 |
|
520 | 592 | end |
|
521 | 593 | |
|
522 | 594 | def test_bulk_update_custom_field |
|
523 | 595 | @request.session[:user_id] = 2 |
|
524 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } | |
|
596 | post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }} | |
|
525 | 597 | |
|
526 | 598 | assert_response 302 |
|
527 | 599 | assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} |
@@ -530,7 +602,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
530 | 602 | def test_bulk_update_clear_custom_field |
|
531 | 603 | field = TimeEntryCustomField.generate!(:field_format => 'string') |
|
532 | 604 | @request.session[:user_id] = 2 |
|
533 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} } | |
|
605 | post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} }} | |
|
534 | 606 | |
|
535 | 607 | assert_response 302 |
|
536 | 608 | assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value} |
@@ -538,7 +610,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
538 | 610 | |
|
539 | 611 | def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter |
|
540 | 612 | @request.session[:user_id] = 2 |
|
541 | post :bulk_update, :ids => [1,2], :back_url => '/time_entries' | |
|
613 | post :bulk_update, :params => {:ids => [1,2], :back_url => '/time_entries'} | |
|
542 | 614 | |
|
543 | 615 | assert_response :redirect |
|
544 | 616 | assert_redirected_to '/time_entries' |
@@ -546,7 +618,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
546 | 618 | |
|
547 | 619 | def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host |
|
548 | 620 | @request.session[:user_id] = 2 |
|
549 | post :bulk_update, :ids => [1,2], :back_url => 'http://google.com' | |
|
621 | post :bulk_update, :params => {:ids => [1,2], :back_url => 'http://google.com'} | |
|
550 | 622 | |
|
551 | 623 | assert_response :redirect |
|
552 | 624 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier |
@@ -555,14 +627,15 class TimelogControllerTest < Redmine::ControllerTest | |||
|
555 | 627 | def test_post_bulk_update_without_edit_permission_should_be_denied |
|
556 | 628 | @request.session[:user_id] = 2 |
|
557 | 629 | Role.find_by_name('Manager').remove_permission! :edit_time_entries |
|
558 | post :bulk_update, :ids => [1,2] | |
|
559 | 630 | |
|
631 | post :bulk_update, :params => {:ids => [1,2]} | |
|
560 | 632 | assert_response 403 |
|
561 | 633 | end |
|
562 | 634 | |
|
563 | 635 | def test_destroy |
|
564 | 636 | @request.session[:user_id] = 2 |
|
565 | delete :destroy, :id => 1 | |
|
637 | ||
|
638 | delete :destroy, :params => {:id => 1} | |
|
566 | 639 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
567 | 640 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] |
|
568 | 641 | assert_nil TimeEntry.find_by_id(1) |
@@ -571,9 +644,9 class TimelogControllerTest < Redmine::ControllerTest | |||
|
571 | 644 | def test_destroy_should_fail |
|
572 | 645 | # simulate that this fails (e.g. due to a plugin), see #5700 |
|
573 | 646 | TimeEntry.any_instance.expects(:destroy).returns(false) |
|
574 | ||
|
575 | 647 | @request.session[:user_id] = 2 |
|
576 | delete :destroy, :id => 1 | |
|
648 | ||
|
649 | delete :destroy, :params => {:id => 1} | |
|
577 | 650 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
578 | 651 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] |
|
579 | 652 | assert_not_nil TimeEntry.find_by_id(1) |
@@ -597,14 +670,14 class TimelogControllerTest < Redmine::ControllerTest | |||
|
597 | 670 | |
|
598 | 671 | def test_index_my_spent_time |
|
599 | 672 | @request.session[:user_id] = 2 |
|
600 | get :index, :user_id => 'me' | |
|
673 | get :index, :params => {:user_id => 'me'} | |
|
601 | 674 | assert_response :success |
|
602 | 675 | assert_template 'index' |
|
603 | 676 | assert assigns(:entries).all? {|entry| entry.user_id == 2} |
|
604 | 677 | end |
|
605 | 678 | |
|
606 | 679 | def test_index_at_project_level |
|
607 | get :index, :project_id => 'ecookbook' | |
|
680 | get :index, :params => {:project_id => 'ecookbook'} | |
|
608 | 681 | assert_response :success |
|
609 | 682 | assert_template 'index' |
|
610 | 683 | assert_not_nil assigns(:entries) |
@@ -620,7 +693,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
620 | 693 | entry = TimeEntry.generate!(:project => Project.find(3)) |
|
621 | 694 | |
|
622 | 695 | with_settings :display_subprojects_issues => '0' do |
|
623 | get :index, :project_id => 'ecookbook' | |
|
696 | get :index, :params => {:project_id => 'ecookbook'} | |
|
624 | 697 | assert_response :success |
|
625 | 698 | assert_template 'index' |
|
626 | 699 | assert_not_include entry, assigns(:entries) |
@@ -631,7 +704,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
631 | 704 | entry = TimeEntry.generate!(:project => Project.find(3)) |
|
632 | 705 | |
|
633 | 706 | with_settings :display_subprojects_issues => '0' do |
|
634 | get :index, :project_id => 'ecookbook', :subproject_id => 3 | |
|
707 | get :index, :params => {:project_id => 'ecookbook', :subproject_id => 3} | |
|
635 | 708 | assert_response :success |
|
636 | 709 | assert_template 'index' |
|
637 | 710 | assert_include entry, assigns(:entries) |
@@ -644,7 +717,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
644 | 717 | TimeEntry.generate!(:issue => issue, :hours => 3) |
|
645 | 718 | @request.session[:user_id] = 2 |
|
646 | 719 | |
|
647 | get :index, :project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1 | |
|
720 | get :index, :params => {:project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1} | |
|
648 | 721 | assert_select '.total-for-hours', :text => 'Hours: 7.00' |
|
649 | 722 | end |
|
650 | 723 | |
@@ -655,15 +728,17 class TimelogControllerTest < Redmine::ControllerTest | |||
|
655 | 728 | TimeEntry.generate!(:issue => issue, :hours => 3) |
|
656 | 729 | @request.session[:user_id] = 2 |
|
657 | 730 | |
|
658 | get :index, :project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1 | |
|
731 | get :index, :params => {:project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1} | |
|
659 | 732 | assert_select '.total-for-hours', :text => 'Hours: 5.00' |
|
660 | 733 | end |
|
661 | 734 | |
|
662 | 735 | def test_index_at_project_level_with_date_range |
|
663 |
get :index, :p |
|
|
736 | get :index, :params => { | |
|
737 | :project_id => 'ecookbook', | |
|
664 | 738 | :f => ['spent_on'], |
|
665 | 739 | :op => {'spent_on' => '><'}, |
|
666 | 740 | :v => {'spent_on' => ['2007-03-20', '2007-04-30']} |
|
741 | } | |
|
667 | 742 | assert_response :success |
|
668 | 743 | assert_template 'index' |
|
669 | 744 | assert_not_nil assigns(:entries) |
@@ -674,7 +749,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
674 | 749 | end |
|
675 | 750 | |
|
676 | 751 | def test_index_at_project_level_with_date_range_using_from_and_to_params |
|
677 | get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' | |
|
752 | get :index, :params => { | |
|
753 | :project_id => 'ecookbook', | |
|
754 | :from => '2007-03-20', | |
|
755 | :to => '2007-04-30' | |
|
756 | } | |
|
678 | 757 | assert_response :success |
|
679 | 758 | assert_template 'index' |
|
680 | 759 | assert_not_nil assigns(:entries) |
@@ -685,10 +764,12 class TimelogControllerTest < Redmine::ControllerTest | |||
|
685 | 764 | end |
|
686 | 765 | |
|
687 | 766 | def test_index_at_project_level_with_period |
|
688 |
get :index, :p |
|
|
767 | get :index, :params => { | |
|
768 | :project_id => 'ecookbook', | |
|
689 | 769 | :f => ['spent_on'], |
|
690 | 770 | :op => {'spent_on' => '>t-'}, |
|
691 | 771 | :v => {'spent_on' => ['7']} |
|
772 | } | |
|
692 | 773 | assert_response :success |
|
693 | 774 | |
|
694 | 775 | assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' |
@@ -699,18 +780,22 class TimelogControllerTest < Redmine::ControllerTest | |||
|
699 | 780 | t2 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10) |
|
700 | 781 | t3 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10) |
|
701 | 782 | |
|
702 |
get :index, :p |
|
|
783 | get :index, :params => { | |
|
784 | :project_id => 1, | |
|
703 | 785 | :f => ['spent_on'], |
|
704 | 786 | :op => {'spent_on' => '><'}, |
|
705 | 787 | :v => {'spent_on' => ['2012-06-15', '2012-06-16']} |
|
788 | } | |
|
706 | 789 | assert_response :success |
|
707 | 790 | assert_equal [t2, t1, t3], assigns(:entries) |
|
708 | 791 | |
|
709 |
get :index, :p |
|
|
792 | get :index, :params => { | |
|
793 | :project_id => 1, | |
|
710 | 794 | :f => ['spent_on'], |
|
711 | 795 | :op => {'spent_on' => '><'}, |
|
712 | 796 | :v => {'spent_on' => ['2012-06-15', '2012-06-16']}, |
|
713 | 797 | :sort => 'spent_on' |
|
798 | } | |
|
714 | 799 | assert_response :success |
|
715 | 800 | assert_equal [t3, t1, t2], assigns(:entries) |
|
716 | 801 | end |
@@ -719,7 +804,11 class TimelogControllerTest < Redmine::ControllerTest | |||
|
719 | 804 | issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'}) |
|
720 | 805 | entry = TimeEntry.generate!(:issue => issue, :hours => 2.5) |
|
721 | 806 | |
|
722 | get :index, :f => ['issue.cf_2'], :op => {'issue.cf_2' => '='}, :v => {'issue.cf_2' => ['filter_on_issue_custom_field']} | |
|
807 | get :index, :params => { | |
|
808 | :f => ['issue.cf_2'], | |
|
809 | :op => {'issue.cf_2' => '='}, | |
|
810 | :v => {'issue.cf_2' => ['filter_on_issue_custom_field']} | |
|
811 | } | |
|
723 | 812 | assert_response :success |
|
724 | 813 | assert_equal [entry], assigns(:entries) |
|
725 | 814 | end |
@@ -728,7 +817,9 class TimelogControllerTest < Redmine::ControllerTest | |||
|
728 | 817 | issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'}) |
|
729 | 818 | entry = TimeEntry.generate!(:issue => issue, :hours => 2.5) |
|
730 | 819 | |
|
731 | get :index, :c => %w(project spent_on issue comments hours issue.cf_2) | |
|
820 | get :index, :params => { | |
|
821 | :c => %w(project spent_on issue comments hours issue.cf_2) | |
|
822 | } | |
|
732 | 823 | assert_response :success |
|
733 | 824 | assert_include :'issue.cf_2', assigns(:query).column_names |
|
734 | 825 | assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field' |
@@ -739,7 +830,9 class TimelogControllerTest < Redmine::ControllerTest | |||
|
739 | 830 | entry = TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value'}) |
|
740 | 831 | field_name = "cf_#{field.id}" |
|
741 | 832 | |
|
742 | get :index, :c => ["hours", field_name] | |
|
833 | get :index, :params => { | |
|
834 | :c => ["hours", field_name] | |
|
835 | } | |
|
743 | 836 | assert_response :success |
|
744 | 837 | assert_include field_name.to_sym, assigns(:query).column_names |
|
745 | 838 | assert_select "td.#{field_name}", :text => 'CF Value' |
@@ -752,7 +845,10 class TimelogControllerTest < Redmine::ControllerTest | |||
|
752 | 845 | TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value 2'}) |
|
753 | 846 | field_name = "cf_#{field.id}" |
|
754 | 847 | |
|
755 | get :index, :c => ["hours", field_name], :sort => field_name | |
|
848 | get :index, :params => { | |
|
849 | :c => ["hours", field_name], | |
|
850 | :sort => field_name | |
|
851 | } | |
|
756 | 852 | assert_response :success |
|
757 | 853 | assert_include field_name.to_sym, assigns(:query).column_names |
|
758 | 854 | assert_select "th a.sort", :text => 'String Field' |
@@ -768,14 +864,14 class TimelogControllerTest < Redmine::ControllerTest | |||
|
768 | 864 | query.save! |
|
769 | 865 | @request.session[:user_id] = 2 |
|
770 | 866 | |
|
771 | get :index, :project_id => 'ecookbook', :query_id => query.id | |
|
867 | get :index, :params => {:project_id => 'ecookbook', :query_id => query.id} | |
|
772 | 868 | assert_response :success |
|
773 | 869 | assert_select 'h2', :text => query.name |
|
774 | 870 | assert_select '#sidebar a.selected', :text => query.name |
|
775 | 871 | end |
|
776 | 872 | |
|
777 | 873 | def test_index_atom_feed |
|
778 | get :index, :project_id => 1, :format => 'atom' | |
|
874 | get :index, :params => {:project_id => 1, :format => 'atom'} | |
|
779 | 875 | assert_response :success |
|
780 | 876 | assert_equal 'application/atom+xml', @response.content_type |
|
781 | 877 | assert_not_nil assigns(:items) |
@@ -783,11 +879,13 class TimelogControllerTest < Redmine::ControllerTest | |||
|
783 | 879 | end |
|
784 | 880 | |
|
785 | 881 | def test_index_at_project_level_should_include_csv_export_dialog |
|
786 |
get :index, :p |
|
|
882 | get :index, :params => { | |
|
883 | :project_id => 'ecookbook', | |
|
787 | 884 | :f => ['spent_on'], |
|
788 | 885 | :op => {'spent_on' => '>='}, |
|
789 | 886 | :v => {'spent_on' => ['2007-04-01']}, |
|
790 | 887 | :c => ['spent_on', 'user'] |
|
888 | } | |
|
791 | 889 | assert_response :success |
|
792 | 890 | |
|
793 | 891 | assert_select '#csv-export-options' do |
@@ -815,7 +913,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
815 | 913 | |
|
816 | 914 | def test_index_csv_all_projects |
|
817 | 915 | with_settings :date_format => '%m/%d/%Y' do |
|
818 | get :index, :format => 'csv' | |
|
916 | get :index, :params => {:format => 'csv'} | |
|
819 | 917 | assert_response :success |
|
820 | 918 | assert_equal 'text/csv; header=present', response.content_type |
|
821 | 919 | end |
@@ -823,7 +921,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
823 | 921 | |
|
824 | 922 | def test_index_csv |
|
825 | 923 | with_settings :date_format => '%m/%d/%Y' do |
|
826 | get :index, :project_id => 1, :format => 'csv' | |
|
924 | get :index, :params => {:project_id => 1, :format => 'csv'} | |
|
827 | 925 | assert_response :success |
|
828 | 926 | assert_equal 'text/csv; header=present', response.content_type |
|
829 | 927 | end |
@@ -833,7 +931,7 class TimelogControllerTest < Redmine::ControllerTest | |||
|
833 | 931 | issue = Issue.find(1) |
|
834 | 932 | entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column content test") |
|
835 | 933 | |
|
836 | get :index, :format => 'csv' | |
|
934 | get :index, :params => {:format => 'csv'} | |
|
837 | 935 | line = response.body.split("\n").detect {|l| l.include?(entry.comments)} |
|
838 | 936 | assert_not_nil line |
|
839 | 937 | assert_include "#{issue.tracker} #1: #{issue.subject}", line |
@@ -64,7 +64,11 class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
64 | 64 | def test_index_should_show_visible_custom_fields_only |
|
65 | 65 | @users_to_test.each do |user, fields| |
|
66 | 66 | @request.session[:user_id] = user.id |
|
67 | get :index, :project_id => 1, :issue_id => @issue.id, :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}) | |
|
67 | get :index, :params => { | |
|
68 | :project_id => 1, | |
|
69 | :issue_id => @issue.id, | |
|
70 | :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}) | |
|
71 | } | |
|
68 | 72 | @fields.each_with_index do |field, i| |
|
69 | 73 | if fields.include?(field) |
|
70 | 74 | assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}" |
@@ -78,7 +82,12 class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
78 | 82 | def test_index_as_csv_should_show_visible_custom_fields_only |
|
79 | 83 | @users_to_test.each do |user, fields| |
|
80 | 84 | @request.session[:user_id] = user.id |
|
81 | get :index, :project_id => 1, :issue_id => @issue.id, :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}), :format => 'csv' | |
|
85 | get :index, :params => { | |
|
86 | :project_id => 1, | |
|
87 | :issue_id => @issue.id, | |
|
88 | :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}), | |
|
89 | :format => 'csv' | |
|
90 | } | |
|
82 | 91 | @fields.each_with_index do |field, i| |
|
83 | 92 | if fields.include?(field) |
|
84 | 93 | assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV" |
@@ -107,12 +116,13 class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
|
107 | 116 | :issue => Issue.generate!(:project => p1, :tracker_id => 1, |
|
108 | 117 | :custom_field_values => {@field2.id => 'ValueC'})) |
|
109 | 118 | @request.session[:user_id] = user.id |
|
110 | get :index, :c => ["hours", "issue.cf_#{@field2.id}"] | |
|
119 | ||
|
120 | get :index, :params => {:c => ["hours", "issue.cf_#{@field2.id}"]} | |
|
111 | 121 | assert_select 'td', {:text => 'ValueA'}, "ValueA not found in:\n#{response.body}" |
|
112 | 122 | assert_select 'td', :text => 'ValueB', :count => 0 |
|
113 | 123 | assert_select 'td', {:text => 'ValueC'}, "ValueC not found in:\n#{response.body}" |
|
114 | 124 | |
|
115 | get :index, :set_filter => '1', "issue.cf_#{@field2.id}" => '*' | |
|
125 | get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*'} | |
|
116 | 126 | assert_equal %w(ValueA ValueC), assigns(:entries).map{|i| i.issue.custom_field_value(@field2)}.sort |
|
117 | 127 | end |
|
118 | 128 | end |
@@ -51,7 +51,14 class TrackersControllerTest < Redmine::ControllerTest | |||
|
51 | 51 | |
|
52 | 52 | def test_create |
|
53 | 53 | assert_difference 'Tracker.count' do |
|
54 | post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
|
54 | post :create, :params => { | |
|
55 | :tracker => { | |
|
56 | :name => 'New tracker', | |
|
57 | :default_status_id => 1, | |
|
58 | :project_ids => ['1', '', ''], | |
|
59 | :custom_field_ids => ['1', '6', ''] | |
|
60 | } | |
|
61 | } | |
|
55 | 62 | end |
|
56 | 63 | assert_redirected_to :action => 'index' |
|
57 | 64 | tracker = Tracker.order('id DESC').first |
@@ -64,7 +71,13 class TrackersControllerTest < Redmine::ControllerTest | |||
|
64 | 71 | |
|
65 | 72 | def test_create_with_disabled_core_fields |
|
66 | 73 | assert_difference 'Tracker.count' do |
|
67 | post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :core_fields => ['assigned_to_id', 'fixed_version_id', ''] } | |
|
74 | post :create, :params => { | |
|
75 | :tracker => { | |
|
76 | :name => 'New tracker', | |
|
77 | :default_status_id => 1, | |
|
78 | :core_fields => ['assigned_to_id', 'fixed_version_id', ''] | |
|
79 | } | |
|
80 | } | |
|
68 | 81 | end |
|
69 | 82 | assert_redirected_to :action => 'index' |
|
70 | 83 | tracker = Tracker.order('id DESC').first |
@@ -74,7 +87,13 class TrackersControllerTest < Redmine::ControllerTest | |||
|
74 | 87 | |
|
75 | 88 | def test_create_new_with_workflow_copy |
|
76 | 89 | assert_difference 'Tracker.count' do |
|
77 | post :create, :tracker => { :name => 'New tracker', :default_status_id => 1 }, :copy_workflow_from => 1 | |
|
90 | post :create, :params => { | |
|
91 | :tracker => { | |
|
92 | :name => 'New tracker', | |
|
93 | :default_status_id => 1 | |
|
94 | }, | |
|
95 | :copy_workflow_from => 1 | |
|
96 | } | |
|
78 | 97 | end |
|
79 | 98 | assert_redirected_to :action => 'index' |
|
80 | 99 | tracker = Tracker.find_by_name('New tracker') |
@@ -84,8 +103,13 class TrackersControllerTest < Redmine::ControllerTest | |||
|
84 | 103 | |
|
85 | 104 | def test_create_with_failure |
|
86 | 105 | assert_no_difference 'Tracker.count' do |
|
87 | post :create, :tracker => { :name => '', :project_ids => ['1', '', ''], | |
|
88 | :custom_field_ids => ['1', '6', ''] } | |
|
106 | post :create, :params => { | |
|
107 | :tracker => { | |
|
108 | :name => '', | |
|
109 | :project_ids => ['1', '', ''], | |
|
110 | :custom_field_ids => ['1', '6', ''] | |
|
111 | } | |
|
112 | } | |
|
89 | 113 | end |
|
90 | 114 | assert_response :success |
|
91 | 115 | assert_template 'new' |
@@ -95,7 +119,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
95 | 119 | def test_edit |
|
96 | 120 | Tracker.find(1).project_ids = [1, 3] |
|
97 | 121 | |
|
98 | get :edit, :id => 1 | |
|
122 | get :edit, :params => {:id => 1} | |
|
99 | 123 | assert_response :success |
|
100 | 124 | assert_template 'edit' |
|
101 | 125 | |
@@ -110,7 +134,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
110 | 134 | tracker.core_fields = %w(assigned_to_id fixed_version_id) |
|
111 | 135 | tracker.save! |
|
112 | 136 | |
|
113 | get :edit, :id => 1 | |
|
137 | get :edit, :params => {:id => 1} | |
|
114 | 138 | assert_response :success |
|
115 | 139 | assert_template 'edit' |
|
116 | 140 | |
@@ -124,27 +148,43 class TrackersControllerTest < Redmine::ControllerTest | |||
|
124 | 148 | end |
|
125 | 149 | |
|
126 | 150 | def test_update |
|
127 | put :update, :id => 1, :tracker => { :name => 'Renamed', | |
|
128 | :project_ids => ['1', '2', ''] } | |
|
151 | put :update, :params => { | |
|
152 | :id => 1, | |
|
153 | :tracker => { | |
|
154 | :name => 'Renamed', | |
|
155 | :project_ids => ['1', '2', ''] | |
|
156 | } | |
|
157 | } | |
|
129 | 158 | assert_redirected_to :action => 'index' |
|
130 | 159 | assert_equal [1, 2], Tracker.find(1).project_ids.sort |
|
131 | 160 | end |
|
132 | 161 | |
|
133 | 162 | def test_update_without_projects |
|
134 | put :update, :id => 1, :tracker => { :name => 'Renamed', | |
|
135 | :project_ids => [''] } | |
|
163 | put :update, :params => { | |
|
164 | :id => 1, | |
|
165 | :tracker => { | |
|
166 | :name => 'Renamed', | |
|
167 | :project_ids => [''] | |
|
168 | } | |
|
169 | } | |
|
136 | 170 | assert_redirected_to :action => 'index' |
|
137 | 171 | assert Tracker.find(1).project_ids.empty? |
|
138 | 172 | end |
|
139 | 173 | |
|
140 | 174 | def test_update_without_core_fields |
|
141 | put :update, :id => 1, :tracker => { :name => 'Renamed', :core_fields => [''] } | |
|
175 | put :update, :params => { | |
|
176 | :id => 1, | |
|
177 | :tracker => { | |
|
178 | :name => 'Renamed', | |
|
179 | :core_fields => [''] | |
|
180 | } | |
|
181 | } | |
|
142 | 182 | assert_redirected_to :action => 'index' |
|
143 | 183 | assert Tracker.find(1).core_fields.empty? |
|
144 | 184 | end |
|
145 | 185 | |
|
146 | 186 | def test_update_with_failure |
|
147 | put :update, :id => 1, :tracker => { :name => '' } | |
|
187 | put :update, :params => {:id => 1, :tracker => { :name => '' }} | |
|
148 | 188 | assert_response :success |
|
149 | 189 | assert_template 'edit' |
|
150 | 190 | assert_select_error /name cannot be blank/i |
@@ -152,14 +192,14 class TrackersControllerTest < Redmine::ControllerTest | |||
|
152 | 192 | |
|
153 | 193 | def test_move_lower |
|
154 | 194 | tracker = Tracker.find_by_position(1) |
|
155 | put :update, :id => 1, :tracker => { :position => '2' } | |
|
195 | put :update, :params => {:id => 1, :tracker => { :position => '2' }} | |
|
156 | 196 | assert_equal 2, tracker.reload.position |
|
157 | 197 | end |
|
158 | 198 | |
|
159 | 199 | def test_destroy |
|
160 | 200 | tracker = Tracker.generate!(:name => 'Destroyable') |
|
161 | 201 | assert_difference 'Tracker.count', -1 do |
|
162 | delete :destroy, :id => tracker.id | |
|
202 | delete :destroy, :params => {:id => tracker.id} | |
|
163 | 203 | end |
|
164 | 204 | assert_redirected_to :action => 'index' |
|
165 | 205 | assert_nil flash[:error] |
@@ -167,7 +207,7 class TrackersControllerTest < Redmine::ControllerTest | |||
|
167 | 207 | |
|
168 | 208 | def test_destroy_tracker_in_use |
|
169 | 209 | assert_no_difference 'Tracker.count' do |
|
170 | delete :destroy, :id => 1 | |
|
210 | delete :destroy, :params => {:id => 1} | |
|
171 | 211 | end |
|
172 | 212 | assert_redirected_to :action => 'index' |
|
173 | 213 | assert_not_nil flash[:error] |
@@ -188,9 +228,11 class TrackersControllerTest < Redmine::ControllerTest | |||
|
188 | 228 | end |
|
189 | 229 | |
|
190 | 230 | def test_post_fields |
|
191 |
post :fields, : |
|
|
192 | '1' => {'core_fields' => ['assigned_to_id', 'due_date', ''], 'custom_field_ids' => ['1', '2']}, | |
|
193 |
|
|
|
231 | post :fields, :params => { | |
|
232 | :trackers => { | |
|
233 | '1' => {'core_fields' => ['assigned_to_id', 'due_date', ''], 'custom_field_ids' => ['1', '2']}, | |
|
234 | '2' => {'core_fields' => [''], 'custom_field_ids' => ['']} | |
|
235 | } | |
|
194 | 236 | } |
|
195 | 237 | assert_redirected_to '/trackers/fields' |
|
196 | 238 |
@@ -27,7 +27,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
27 | 27 | end |
|
28 | 28 | |
|
29 | 29 | def test_index |
|
30 | get :index, :project_id => 1 | |
|
30 | get :index, :params => {:project_id => 1} | |
|
31 | 31 | assert_response :success |
|
32 | 32 | assert_template 'index' |
|
33 | 33 | assert_not_nil assigns(:versions) |
@@ -46,7 +46,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_index_with_completed_versions |
|
49 | get :index, :project_id => 1, :completed => 1 | |
|
49 | get :index, :params => {:project_id => 1, :completed => 1} | |
|
50 | 50 | assert_response :success |
|
51 | 51 | assert_template 'index' |
|
52 | 52 | assert_not_nil assigns(:versions) |
@@ -57,7 +57,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | def test_index_with_tracker_ids |
|
60 | get :index, :project_id => 1, :tracker_ids => [1, 3] | |
|
60 | get :index, :params => {:project_id => 1, :tracker_ids => [1, 3]} | |
|
61 | 61 | assert_response :success |
|
62 | 62 | assert_template 'index' |
|
63 | 63 | assert_not_nil assigns(:issues_by_version) |
@@ -66,7 +66,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
66 | 66 | |
|
67 | 67 | def test_index_showing_subprojects_versions |
|
68 | 68 | @subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version") |
|
69 | get :index, :project_id => 1, :with_subprojects => 1 | |
|
69 | get :index, :params => {:project_id => 1, :with_subprojects => 1} | |
|
70 | 70 | assert_response :success |
|
71 | 71 | assert_template 'index' |
|
72 | 72 | assert_not_nil assigns(:versions) |
@@ -76,7 +76,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
76 | 76 | end |
|
77 | 77 | |
|
78 | 78 | def test_index_should_prepend_shared_versions |
|
79 | get :index, :project_id => 1 | |
|
79 | get :index, :params => {:project_id => 1} | |
|
80 | 80 | assert_response :success |
|
81 | 81 | |
|
82 | 82 | assert_select '#sidebar' do |
@@ -90,7 +90,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
90 | 90 | end |
|
91 | 91 | |
|
92 | 92 | def test_show |
|
93 | get :show, :id => 2 | |
|
93 | get :show, :params => {:id => 2} | |
|
94 | 94 | assert_response :success |
|
95 | 95 | assert_template 'show' |
|
96 | 96 | assert_not_nil assigns(:version) |
@@ -103,7 +103,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
103 | 103 | issue = Issue.generate(:fixed_version => version) |
|
104 | 104 | TimeEntry.generate!(:issue => issue, :hours => 7.2) |
|
105 | 105 | |
|
106 | get :show, :id => version.id | |
|
106 | get :show, :params => {:id => version.id} | |
|
107 | 107 | assert_response :success |
|
108 | 108 | |
|
109 | 109 | assert_select '.total-hours', :text => '7.20 hours' |
@@ -112,7 +112,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
112 | 112 | |
|
113 | 113 | def test_show_should_display_nil_counts |
|
114 | 114 | with_settings :default_language => 'en' do |
|
115 | get :show, :id => 2, :status_by => 'category' | |
|
115 | get :show, :params => {:id => 2, :status_by => 'category'} | |
|
116 | 116 | assert_response :success |
|
117 | 117 | assert_select 'div#status_by' do |
|
118 | 118 | assert_select 'select[name=status_by]' do |
@@ -125,14 +125,14 class VersionsControllerTest < Redmine::ControllerTest | |||
|
125 | 125 | |
|
126 | 126 | def test_new |
|
127 | 127 | @request.session[:user_id] = 2 |
|
128 | get :new, :project_id => '1' | |
|
128 | get :new, :params => {:project_id => '1'} | |
|
129 | 129 | assert_response :success |
|
130 | 130 | assert_template 'new' |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | def test_new_from_issue_form |
|
134 | 134 | @request.session[:user_id] = 2 |
|
135 | xhr :get, :new, :project_id => '1' | |
|
135 | xhr :get, :new, :params => {:project_id => '1'} | |
|
136 | 136 | assert_response :success |
|
137 | 137 | assert_template 'new' |
|
138 | 138 | assert_equal 'text/javascript', response.content_type |
@@ -141,7 +141,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
141 | 141 | def test_create |
|
142 | 142 | @request.session[:user_id] = 2 # manager |
|
143 | 143 | assert_difference 'Version.count' do |
|
144 | post :create, :project_id => '1', :version => {:name => 'test_add_version'} | |
|
144 | post :create, :params => {:project_id => '1', :version => {:name => 'test_add_version'}} | |
|
145 | 145 | end |
|
146 | 146 | assert_redirected_to '/projects/ecookbook/settings/versions' |
|
147 | 147 | version = Version.find_by_name('test_add_version') |
@@ -152,7 +152,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
152 | 152 | def test_create_from_issue_form |
|
153 | 153 | @request.session[:user_id] = 2 |
|
154 | 154 | assert_difference 'Version.count' do |
|
155 | xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |
|
155 | xhr :post, :create, :params => {:project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}} | |
|
156 | 156 | end |
|
157 | 157 | version = Version.find_by_name('test_add_version_from_issue_form') |
|
158 | 158 | assert_not_nil version |
@@ -167,7 +167,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
167 | 167 | def test_create_from_issue_form_with_failure |
|
168 | 168 | @request.session[:user_id] = 2 |
|
169 | 169 | assert_no_difference 'Version.count' do |
|
170 | xhr :post, :create, :project_id => '1', :version => {:name => ''} | |
|
170 | xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}} | |
|
171 | 171 | end |
|
172 | 172 | assert_response :success |
|
173 | 173 | assert_template 'new' |
@@ -176,7 +176,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
176 | 176 | |
|
177 | 177 | def test_get_edit |
|
178 | 178 | @request.session[:user_id] = 2 |
|
179 | get :edit, :id => 2 | |
|
179 | get :edit, :params => {:id => 2} | |
|
180 | 180 | assert_response :success |
|
181 | 181 | assert_template 'edit' |
|
182 | 182 | end |
@@ -184,7 +184,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
184 | 184 | def test_close_completed |
|
185 | 185 | Version.update_all("status = 'open'") |
|
186 | 186 | @request.session[:user_id] = 2 |
|
187 | put :close_completed, :project_id => 'ecookbook' | |
|
187 | put :close_completed, :params => {:project_id => 'ecookbook'} | |
|
188 | 188 | assert_redirected_to :controller => 'projects', :action => 'settings', |
|
189 | 189 | :tab => 'versions', :id => 'ecookbook' |
|
190 | 190 | assert_not_nil Version.find_by_status('closed') |
@@ -192,9 +192,13 class VersionsControllerTest < Redmine::ControllerTest | |||
|
192 | 192 | |
|
193 | 193 | def test_post_update |
|
194 | 194 | @request.session[:user_id] = 2 |
|
195 |
put :update, : |
|
|
196 | :version => {:name => 'New version name', | |
|
197 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
|
195 | put :update, :params => { | |
|
196 | :id => 2, | |
|
197 | :version => { | |
|
198 | :name => 'New version name', | |
|
199 | :effective_date => Date.today.strftime("%Y-%m-%d") | |
|
200 | } | |
|
201 | } | |
|
198 | 202 | assert_redirected_to :controller => 'projects', :action => 'settings', |
|
199 | 203 | :tab => 'versions', :id => 'ecookbook' |
|
200 | 204 | version = Version.find(2) |
@@ -204,9 +208,13 class VersionsControllerTest < Redmine::ControllerTest | |||
|
204 | 208 | |
|
205 | 209 | def test_post_update_with_validation_failure |
|
206 | 210 | @request.session[:user_id] = 2 |
|
207 |
put :update, : |
|
|
208 | :version => { :name => '', | |
|
209 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
|
211 | put :update, :params => { | |
|
212 | :id => 2, | |
|
213 | :version => { | |
|
214 | :name => '', | |
|
215 | :effective_date => Date.today.strftime("%Y-%m-%d") | |
|
216 | } | |
|
217 | } | |
|
210 | 218 | assert_response :success |
|
211 | 219 | assert_template 'edit' |
|
212 | 220 | end |
@@ -214,7 +222,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
214 | 222 | def test_destroy |
|
215 | 223 | @request.session[:user_id] = 2 |
|
216 | 224 | assert_difference 'Version.count', -1 do |
|
217 | delete :destroy, :id => 3 | |
|
225 | delete :destroy, :params => {:id => 3} | |
|
218 | 226 | end |
|
219 | 227 | assert_redirected_to :controller => 'projects', :action => 'settings', |
|
220 | 228 | :tab => 'versions', :id => 'ecookbook' |
@@ -224,7 +232,7 class VersionsControllerTest < Redmine::ControllerTest | |||
|
224 | 232 | def test_destroy_version_in_use_should_fail |
|
225 | 233 | @request.session[:user_id] = 2 |
|
226 | 234 | assert_no_difference 'Version.count' do |
|
227 | delete :destroy, :id => 2 | |
|
235 | delete :destroy, :params => {:id => 2} | |
|
228 | 236 | end |
|
229 | 237 | assert_redirected_to :controller => 'projects', :action => 'settings', |
|
230 | 238 | :tab => 'versions', :id => 'ecookbook' |
@@ -233,14 +241,14 class VersionsControllerTest < Redmine::ControllerTest | |||
|
233 | 241 | end |
|
234 | 242 | |
|
235 | 243 | def test_issue_status_by |
|
236 | xhr :get, :status_by, :id => 2 | |
|
244 | xhr :get, :status_by, :params => {:id => 2} | |
|
237 | 245 | assert_response :success |
|
238 | 246 | assert_template 'status_by' |
|
239 | 247 | assert_template '_issue_counts' |
|
240 | 248 | end |
|
241 | 249 | |
|
242 | 250 | def test_issue_status_by_status |
|
243 | xhr :get, :status_by, :id => 2, :status_by => 'status' | |
|
251 | xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'} | |
|
244 | 252 | assert_response :success |
|
245 | 253 | assert_template 'status_by' |
|
246 | 254 | assert_template '_issue_counts' |
@@ -28,7 +28,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_watch_a_single_object |
|
29 | 29 | @request.session[:user_id] = 3 |
|
30 | 30 | assert_difference('Watcher.count') do |
|
31 | xhr :post, :watch, :object_type => 'issue', :object_id => '1' | |
|
31 | xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'} | |
|
32 | 32 | assert_response :success |
|
33 | 33 | assert_include '$(".issue-1-watcher")', response.body |
|
34 | 34 | end |
@@ -38,7 +38,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
38 | 38 | def test_watch_a_collection_with_a_single_object |
|
39 | 39 | @request.session[:user_id] = 3 |
|
40 | 40 | assert_difference('Watcher.count') do |
|
41 | xhr :post, :watch, :object_type => 'issue', :object_id => ['1'] | |
|
41 | xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1']} | |
|
42 | 42 | assert_response :success |
|
43 | 43 | assert_include '$(".issue-1-watcher")', response.body |
|
44 | 44 | end |
@@ -48,7 +48,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
48 | 48 | def test_watch_a_collection_with_multiple_objects |
|
49 | 49 | @request.session[:user_id] = 3 |
|
50 | 50 | assert_difference('Watcher.count', 2) do |
|
51 | xhr :post, :watch, :object_type => 'issue', :object_id => ['1', '3'] | |
|
51 | xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1', '3']} | |
|
52 | 52 | assert_response :success |
|
53 | 53 | assert_include '$(".issue-bulk-watcher")', response.body |
|
54 | 54 | end |
@@ -61,7 +61,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
61 | 61 | assert_not_nil m = Project.find(1).enabled_module('news') |
|
62 | 62 | |
|
63 | 63 | assert_difference 'Watcher.count' do |
|
64 | xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s | |
|
64 | xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s} | |
|
65 | 65 | assert_response :success |
|
66 | 66 | end |
|
67 | 67 | assert m.reload.watched_by?(User.find(7)) |
@@ -72,7 +72,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
72 | 72 | assert_not_nil m = Project.find(2).enabled_module('news') |
|
73 | 73 | |
|
74 | 74 | assert_no_difference 'Watcher.count' do |
|
75 | xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s | |
|
75 | xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s} | |
|
76 | 76 | assert_response 403 |
|
77 | 77 | end |
|
78 | 78 | end |
@@ -81,7 +81,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
81 | 81 | Role.find(2).remove_permission! :view_issues |
|
82 | 82 | @request.session[:user_id] = 3 |
|
83 | 83 | assert_no_difference('Watcher.count') do |
|
84 | xhr :post, :watch, :object_type => 'issue', :object_id => '1' | |
|
84 | xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'} | |
|
85 | 85 | assert_response 403 |
|
86 | 86 | end |
|
87 | 87 | end |
@@ -89,7 +89,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
89 | 89 | def test_watch_invalid_class_should_respond_with_404 |
|
90 | 90 | @request.session[:user_id] = 3 |
|
91 | 91 | assert_no_difference('Watcher.count') do |
|
92 | xhr :post, :watch, :object_type => 'foo', :object_id => '1' | |
|
92 | xhr :post, :watch, :params => {:object_type => 'foo', :object_id => '1'} | |
|
93 | 93 | assert_response 404 |
|
94 | 94 | end |
|
95 | 95 | end |
@@ -97,7 +97,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
97 | 97 | def test_watch_invalid_object_should_respond_with_404 |
|
98 | 98 | @request.session[:user_id] = 3 |
|
99 | 99 | assert_no_difference('Watcher.count') do |
|
100 | xhr :post, :watch, :object_type => 'issue', :object_id => '999' | |
|
100 | xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '999'} | |
|
101 | 101 | assert_response 404 |
|
102 | 102 | end |
|
103 | 103 | end |
@@ -105,7 +105,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
105 | 105 | def test_unwatch |
|
106 | 106 | @request.session[:user_id] = 3 |
|
107 | 107 | assert_difference('Watcher.count', -1) do |
|
108 | xhr :delete, :unwatch, :object_type => 'issue', :object_id => '2' | |
|
108 | xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => '2'} | |
|
109 | 109 | assert_response :success |
|
110 | 110 | assert_include '$(".issue-2-watcher")', response.body |
|
111 | 111 | end |
@@ -118,7 +118,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
118 | 118 | Watcher.create!(:user_id => 3, :watchable => Issue.find(3)) |
|
119 | 119 | |
|
120 | 120 | assert_difference('Watcher.count', -2) do |
|
121 | xhr :delete, :unwatch, :object_type => 'issue', :object_id => ['1', '3'] | |
|
121 | xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => ['1', '3']} | |
|
122 | 122 | assert_response :success |
|
123 | 123 | assert_include '$(".issue-bulk-watcher")', response.body |
|
124 | 124 | end |
@@ -128,21 +128,21 class WatchersControllerTest < Redmine::ControllerTest | |||
|
128 | 128 | |
|
129 | 129 | def test_new |
|
130 | 130 | @request.session[:user_id] = 2 |
|
131 | xhr :get, :new, :object_type => 'issue', :object_id => '2' | |
|
131 | xhr :get, :new, :params => {:object_type => 'issue', :object_id => '2'} | |
|
132 | 132 | assert_response :success |
|
133 | 133 | assert_match /ajax-modal/, response.body |
|
134 | 134 | end |
|
135 | 135 | |
|
136 | 136 | def test_new_with_multiple_objects |
|
137 | 137 | @request.session[:user_id] = 2 |
|
138 | xhr :get, :new, :object_type => 'issue', :object_id => ['1', '2'] | |
|
138 | xhr :get, :new, :params => {:object_type => 'issue', :object_id => ['1', '2']} | |
|
139 | 139 | assert_response :success |
|
140 | 140 | assert_match /ajax-modal/, response.body |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | def test_new_for_new_record_with_project_id |
|
144 | 144 | @request.session[:user_id] = 2 |
|
145 | xhr :get, :new, :project_id => 1 | |
|
145 | xhr :get, :new, :params => {:project_id => 1} | |
|
146 | 146 | assert_response :success |
|
147 | 147 | assert_equal Project.find(1), assigns(:project) |
|
148 | 148 | assert_match /ajax-modal/, response.body |
@@ -150,7 +150,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
150 | 150 | |
|
151 | 151 | def test_new_for_new_record_with_project_identifier |
|
152 | 152 | @request.session[:user_id] = 2 |
|
153 | xhr :get, :new, :project_id => 'ecookbook' | |
|
153 | xhr :get, :new, :params => {:project_id => 'ecookbook'} | |
|
154 | 154 | assert_response :success |
|
155 | 155 | assert_equal Project.find(1), assigns(:project) |
|
156 | 156 | assert_match /ajax-modal/, response.body |
@@ -159,8 +159,10 class WatchersControllerTest < Redmine::ControllerTest | |||
|
159 | 159 | def test_create |
|
160 | 160 | @request.session[:user_id] = 2 |
|
161 | 161 | assert_difference('Watcher.count') do |
|
162 | xhr :post, :create, :object_type => 'issue', :object_id => '2', | |
|
163 | :watcher => {:user_id => '4'} | |
|
162 | xhr :post, :create, :params => { | |
|
163 | :object_type => 'issue', :object_id => '2', | |
|
164 | :watcher => {:user_id => '4'} | |
|
165 | } | |
|
164 | 166 | assert_response :success |
|
165 | 167 | assert_match /watchers/, response.body |
|
166 | 168 | assert_match /ajax-modal/, response.body |
@@ -171,8 +173,10 class WatchersControllerTest < Redmine::ControllerTest | |||
|
171 | 173 | def test_create_with_mutiple_users |
|
172 | 174 | @request.session[:user_id] = 2 |
|
173 | 175 | assert_difference('Watcher.count', 2) do |
|
174 | xhr :post, :create, :object_type => 'issue', :object_id => '2', | |
|
175 | :watcher => {:user_ids => ['4', '7']} | |
|
176 | xhr :post, :create, :params => { | |
|
177 | :object_type => 'issue', :object_id => '2', | |
|
178 | :watcher => {:user_ids => ['4', '7']} | |
|
179 | } | |
|
176 | 180 | assert_response :success |
|
177 | 181 | assert_match /watchers/, response.body |
|
178 | 182 | assert_match /ajax-modal/, response.body |
@@ -184,8 +188,10 class WatchersControllerTest < Redmine::ControllerTest | |||
|
184 | 188 | def test_create_with_mutiple_objects |
|
185 | 189 | @request.session[:user_id] = 2 |
|
186 | 190 | assert_difference('Watcher.count', 4) do |
|
187 | xhr :post, :create, :object_type => 'issue', :object_id => ['1', '2'], | |
|
188 |
|
|
|
191 | xhr :post, :create, :params => { | |
|
192 | :object_type => 'issue', :object_id => ['1', '2'], | |
|
193 | :watcher => {:user_ids => ['4', '7']} | |
|
194 | } | |
|
189 | 195 | assert_response :success |
|
190 | 196 | assert_match /watchers/, response.body |
|
191 | 197 | assert_match /ajax-modal/, response.body |
@@ -198,7 +204,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
198 | 204 | |
|
199 | 205 | def test_autocomplete_on_watchable_creation |
|
200 | 206 | @request.session[:user_id] = 2 |
|
201 | xhr :get, :autocomplete_for_user, :q => 'mi', :project_id => 'ecookbook' | |
|
207 | xhr :get, :autocomplete_for_user, :params => {:q => 'mi', :project_id => 'ecookbook'} | |
|
202 | 208 | assert_response :success |
|
203 | 209 | assert_select 'input', :count => 4 |
|
204 | 210 | assert_select 'input[name=?][value="1"]', 'watcher[user_ids][]' |
@@ -213,15 +219,17 class WatchersControllerTest < Redmine::ControllerTest | |||
|
213 | 219 | user = User.generate!(:firstname => 'issue15622') |
|
214 | 220 | membership = user.membership(project) |
|
215 | 221 | assert_nil membership |
|
216 | xhr :get, :autocomplete_for_user, :q => 'issue15622', :project_id => 'ecookbook' | |
|
222 | xhr :get, :autocomplete_for_user, :params => {:q => 'issue15622', :project_id => 'ecookbook'} | |
|
217 | 223 | assert_response :success |
|
218 | 224 | assert_select 'input', :count => 1 |
|
219 | 225 | end |
|
220 | 226 | |
|
221 | 227 | def test_autocomplete_on_watchable_update |
|
222 | 228 | @request.session[:user_id] = 2 |
|
223 |
xhr :get, :autocomplete_for_user, : |
|
|
224 |
|
|
|
229 | xhr :get, :autocomplete_for_user, :params => { | |
|
230 | :object_type => 'issue', :object_id => '2', | |
|
231 | :project_id => 'ecookbook', :q => 'mi' | |
|
232 | } | |
|
225 | 233 | assert_response :success |
|
226 | 234 | assert_select 'input', :count => 3 |
|
227 | 235 | assert_select 'input[name=?][value="2"]', 'watcher[user_ids][]' |
@@ -235,13 +243,19 class WatchersControllerTest < Redmine::ControllerTest | |||
|
235 | 243 | user = User.generate!(:firstname => 'issue15622') |
|
236 | 244 | membership = user.membership(project) |
|
237 | 245 | assert_nil membership |
|
238 | xhr :get, :autocomplete_for_user, :q => 'issue15622', :object_id => '2', | |
|
239 | :object_type => 'issue', :project_id => 'ecookbook' | |
|
246 | ||
|
247 | xhr :get, :autocomplete_for_user, :params => { | |
|
248 | :object_type => 'issue', :object_id => '2', | |
|
249 | :project_id => 'ecookbook', :q => 'issue15622' | |
|
250 | } | |
|
240 | 251 | assert_response :success |
|
241 | 252 | assert_select 'input', :count => 1 |
|
253 | ||
|
242 | 254 | assert_difference('Watcher.count', 1) do |
|
243 | xhr :post, :create, :object_type => 'issue', :object_id => '2', | |
|
244 | :watcher => {:user_ids => ["#{user.id}"]} | |
|
255 | xhr :post, :create, :params => { | |
|
256 | :object_type => 'issue', :object_id => '2', | |
|
257 | :watcher => {:user_ids => ["#{user.id}"]} | |
|
258 | } | |
|
245 | 259 | assert_response :success |
|
246 | 260 | assert_match /watchers/, response.body |
|
247 | 261 | assert_match /ajax-modal/, response.body |
@@ -257,7 +271,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
257 | 271 | User.add_to_project(visible, Project.find(1)) |
|
258 | 272 | |
|
259 | 273 | @request.session[:user_id] = 2 |
|
260 | xhr :get, :autocomplete_for_user, :q => 'autocomp', :project_id => 'ecookbook' | |
|
274 | xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'} | |
|
261 | 275 | assert_response :success |
|
262 | 276 | |
|
263 | 277 | assert_include visible, assigns(:users) |
@@ -267,7 +281,9 class WatchersControllerTest < Redmine::ControllerTest | |||
|
267 | 281 | def test_append |
|
268 | 282 | @request.session[:user_id] = 2 |
|
269 | 283 | assert_no_difference 'Watcher.count' do |
|
270 | xhr :post, :append, :watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook' | |
|
284 | xhr :post, :append, :params => { | |
|
285 | :watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook' | |
|
286 | } | |
|
271 | 287 | assert_response :success |
|
272 | 288 | assert_include 'watchers_inputs', response.body |
|
273 | 289 | assert_include 'issue[watcher_user_ids][]', response.body |
@@ -276,7 +292,7 class WatchersControllerTest < Redmine::ControllerTest | |||
|
276 | 292 | |
|
277 | 293 | def test_append_without_user_should_render_nothing |
|
278 | 294 | @request.session[:user_id] = 2 |
|
279 | xhr :post, :append, :project_id => 'ecookbook' | |
|
295 | xhr :post, :append, :params => {:project_id => 'ecookbook'} | |
|
280 | 296 | assert_response :success |
|
281 | 297 | assert response.body.blank? |
|
282 | 298 | end |
@@ -284,7 +300,9 class WatchersControllerTest < Redmine::ControllerTest | |||
|
284 | 300 | def test_destroy |
|
285 | 301 | @request.session[:user_id] = 2 |
|
286 | 302 | assert_difference('Watcher.count', -1) do |
|
287 | xhr :delete, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' | |
|
303 | xhr :delete, :destroy, :params => { | |
|
304 | :object_type => 'issue', :object_id => '2', :user_id => '3' | |
|
305 | } | |
|
288 | 306 | assert_response :success |
|
289 | 307 | assert_match /watchers/, response.body |
|
290 | 308 | end |
@@ -298,7 +316,9 class WatchersControllerTest < Redmine::ControllerTest | |||
|
298 | 316 | |
|
299 | 317 | @request.session[:user_id] = 2 |
|
300 | 318 | assert_difference('Watcher.count', -1) do |
|
301 | xhr :delete, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' | |
|
319 | xhr :delete, :destroy, :params => { | |
|
320 | :object_type => 'issue', :object_id => '2', :user_id => '3' | |
|
321 | } | |
|
302 | 322 | assert_response :success |
|
303 | 323 | assert_match /watchers/, response.body |
|
304 | 324 | end |
@@ -308,7 +328,9 class WatchersControllerTest < Redmine::ControllerTest | |||
|
308 | 328 | def test_destroy_invalid_user_should_respond_with_404 |
|
309 | 329 | @request.session[:user_id] = 2 |
|
310 | 330 | assert_no_difference('Watcher.count') do |
|
311 | delete :destroy, :object_type => 'issue', :object_id => '2', :user_id => '999' | |
|
331 | delete :destroy, :params => { | |
|
332 | :object_type => 'issue', :object_id => '2', :user_id => '999' | |
|
333 | } | |
|
312 | 334 | assert_response 404 |
|
313 | 335 | end |
|
314 | 336 | end |
@@ -28,7 +28,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | end |
|
29 | 29 | |
|
30 | 30 | def test_show_start_page |
|
31 | get :show, :project_id => 'ecookbook' | |
|
31 | get :show, :params => {:project_id => 'ecookbook'} | |
|
32 | 32 | assert_response :success |
|
33 | 33 | assert_template 'show' |
|
34 | 34 | assert_select 'h1', :text => /CookBook documentation/ |
@@ -40,13 +40,13 class WikiControllerTest < Redmine::ControllerTest | |||
|
40 | 40 | |
|
41 | 41 | def test_export_link |
|
42 | 42 | Role.anonymous.add_permission! :export_wiki_pages |
|
43 | get :show, :project_id => 'ecookbook' | |
|
43 | get :show, :params => {:project_id => 'ecookbook'} | |
|
44 | 44 | assert_response :success |
|
45 | 45 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation.txt' |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_show_page_with_name |
|
49 | get :show, :project_id => 1, :id => 'Another_page' | |
|
49 | get :show, :params => {:project_id => 1, :id => 'Another_page'} | |
|
50 | 50 | assert_response :success |
|
51 | 51 | assert_template 'show' |
|
52 | 52 | assert_select 'h1', :text => /Another page/ |
@@ -57,7 +57,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
57 | 57 | |
|
58 | 58 | def test_show_old_version |
|
59 | 59 | with_settings :default_language => 'en' do |
|
60 | get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2' | |
|
60 | get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'} | |
|
61 | 61 | end |
|
62 | 62 | assert_response :success |
|
63 | 63 | assert_template 'show' |
@@ -75,7 +75,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
75 | 75 | content.text = "update" |
|
76 | 76 | content.save! |
|
77 | 77 | |
|
78 | get :show, :project_id => 'ecookbook', :id => page.title, :version => '1' | |
|
78 | get :show, :params => {:project_id => 'ecookbook', :id => page.title, :version => '1'} | |
|
79 | 79 | assert_kind_of WikiContent::Version, assigns(:content) |
|
80 | 80 | assert_response :success |
|
81 | 81 | assert_template 'show' |
@@ -84,13 +84,13 class WikiControllerTest < Redmine::ControllerTest | |||
|
84 | 84 | def test_show_old_version_without_permission_should_be_denied |
|
85 | 85 | Role.anonymous.remove_permission! :view_wiki_edits |
|
86 | 86 | |
|
87 | get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2' | |
|
87 | get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'} | |
|
88 | 88 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fprojects%2Fecookbook%2Fwiki%2FCookBook_documentation%2F2' |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | def test_show_first_version |
|
92 | 92 | with_settings :default_language => 'en' do |
|
93 | get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1' | |
|
93 | get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'} | |
|
94 | 94 | end |
|
95 | 95 | assert_response :success |
|
96 | 96 | assert_template 'show' |
@@ -104,7 +104,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
104 | 104 | def test_show_redirected_page |
|
105 | 105 | WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page') |
|
106 | 106 | |
|
107 | get :show, :project_id => 'ecookbook', :id => 'Old_title' | |
|
107 | get :show, :params => {:project_id => 'ecookbook', :id => 'Old_title'} | |
|
108 | 108 | assert_redirected_to '/projects/ecookbook/wiki/Another_page' |
|
109 | 109 | end |
|
110 | 110 | |
@@ -113,14 +113,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
113 | 113 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') |
|
114 | 114 | page.save! |
|
115 | 115 | |
|
116 | get :show, :project_id => 1, :id => 'Another_page' | |
|
116 | get :show, :params => {:project_id => 1, :id => 'Another_page'} | |
|
117 | 117 | assert_response :success |
|
118 | 118 | assert_select 'div#sidebar', :text => /Side bar content for test_show_with_sidebar/ |
|
119 | 119 | end |
|
120 | 120 | |
|
121 | 121 | def test_show_should_display_section_edit_links |
|
122 | 122 | @request.session[:user_id] = 2 |
|
123 | get :show, :project_id => 1, :id => 'Page with sections' | |
|
123 | get :show, :params => {:project_id => 1, :id => 'Page with sections'} | |
|
124 | 124 | |
|
125 | 125 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=1', 0 |
|
126 | 126 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' |
@@ -129,38 +129,38 class WikiControllerTest < Redmine::ControllerTest | |||
|
129 | 129 | |
|
130 | 130 | def test_show_current_version_should_display_section_edit_links |
|
131 | 131 | @request.session[:user_id] = 2 |
|
132 | get :show, :project_id => 1, :id => 'Page with sections', :version => 3 | |
|
132 | get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 3} | |
|
133 | 133 | |
|
134 | 134 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' |
|
135 | 135 | end |
|
136 | 136 | |
|
137 | 137 | def test_show_old_version_should_not_display_section_edit_links |
|
138 | 138 | @request.session[:user_id] = 2 |
|
139 | get :show, :project_id => 1, :id => 'Page with sections', :version => 2 | |
|
139 | get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2} | |
|
140 | 140 | |
|
141 | 141 | assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2', 0 |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | def test_show_unexistent_page_without_edit_right |
|
145 | get :show, :project_id => 1, :id => 'Unexistent page' | |
|
145 | get :show, :params => {:project_id => 1, :id => 'Unexistent page'} | |
|
146 | 146 | assert_response 404 |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | def test_show_unexistent_page_with_edit_right |
|
150 | 150 | @request.session[:user_id] = 2 |
|
151 | get :show, :project_id => 1, :id => 'Unexistent page' | |
|
151 | get :show, :params => {:project_id => 1, :id => 'Unexistent page'} | |
|
152 | 152 | assert_response :success |
|
153 | 153 | assert_template 'edit' |
|
154 | 154 | end |
|
155 | 155 | |
|
156 | 156 | def test_show_specific_version_of_an_unexistent_page_without_edit_right |
|
157 | get :show, :project_id => 1, :id => 'Unexistent page', :version => 1 | |
|
157 | get :show, :params => {:project_id => 1, :id => 'Unexistent page', :version => 1} | |
|
158 | 158 | assert_response 404 |
|
159 | 159 | end |
|
160 | 160 | |
|
161 | 161 | def test_show_unexistent_page_with_parent_should_preselect_parent |
|
162 | 162 | @request.session[:user_id] = 2 |
|
163 | get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page' | |
|
163 | get :show, :params => {:project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'} | |
|
164 | 164 | assert_response :success |
|
165 | 165 | assert_template 'edit' |
|
166 | 166 | assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]' |
@@ -168,7 +168,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
168 | 168 | |
|
169 | 169 | def test_show_should_not_show_history_without_permission |
|
170 | 170 | Role.anonymous.remove_permission! :view_wiki_edits |
|
171 | get :show, :project_id => 1, :id => 'Page with sections', :version => 2 | |
|
171 | get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2} | |
|
172 | 172 | |
|
173 | 173 | assert_response 302 |
|
174 | 174 | end |
@@ -177,7 +177,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
177 | 177 | @request.session[:user_id] = 2 |
|
178 | 178 | WikiPage.create!(:title => 'NoContent', :wiki => Project.find(1).wiki) |
|
179 | 179 | |
|
180 | get :show, :project_id => 1, :id => 'NoContent' | |
|
180 | get :show, :params => {:project_id => 1, :id => 'NoContent'} | |
|
181 | 181 | assert_response :success |
|
182 | 182 | assert_template 'edit' |
|
183 | 183 | assert_select 'textarea[name=?]', 'content[text]' |
@@ -186,7 +186,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
186 | 186 | def test_get_new |
|
187 | 187 | @request.session[:user_id] = 2 |
|
188 | 188 | |
|
189 | get :new, :project_id => 'ecookbook' | |
|
189 | get :new, :params => {:project_id => 'ecookbook'} | |
|
190 | 190 | assert_response :success |
|
191 | 191 | assert_template 'new' |
|
192 | 192 | end |
@@ -194,7 +194,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
194 | 194 | def test_get_new_xhr |
|
195 | 195 | @request.session[:user_id] = 2 |
|
196 | 196 | |
|
197 | xhr :get, :new, :project_id => 'ecookbook' | |
|
197 | xhr :get, :new, :params => {:project_id => 'ecookbook'} | |
|
198 | 198 | assert_response :success |
|
199 | 199 | assert_template 'new' |
|
200 | 200 | end |
@@ -202,14 +202,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
202 | 202 | def test_post_new_with_valid_title_should_redirect_to_edit |
|
203 | 203 | @request.session[:user_id] = 2 |
|
204 | 204 | |
|
205 | post :new, :project_id => 'ecookbook', :title => 'New Page' | |
|
205 | post :new, :params => {:project_id => 'ecookbook', :title => 'New Page'} | |
|
206 | 206 | assert_redirected_to '/projects/ecookbook/wiki/New_Page' |
|
207 | 207 | end |
|
208 | 208 | |
|
209 | 209 | def test_post_new_xhr_with_valid_title_should_redirect_to_edit |
|
210 | 210 | @request.session[:user_id] = 2 |
|
211 | 211 | |
|
212 | xhr :post, :new, :project_id => 'ecookbook', :title => 'New Page' | |
|
212 | xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'New Page'} | |
|
213 | 213 | assert_response :success |
|
214 | 214 | assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body |
|
215 | 215 | end |
@@ -217,7 +217,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
217 | 217 | def test_post_new_with_invalid_title_should_display_errors |
|
218 | 218 | @request.session[:user_id] = 2 |
|
219 | 219 | |
|
220 | post :new, :project_id => 'ecookbook', :title => 'Another page' | |
|
220 | post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} | |
|
221 | 221 | assert_response :success |
|
222 | 222 | assert_template 'new' |
|
223 | 223 | assert_select_error 'Title has already been taken' |
@@ -226,7 +226,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
226 | 226 | def test_post_new_xhr_with_invalid_title_should_display_errors |
|
227 | 227 | @request.session[:user_id] = 2 |
|
228 | 228 | |
|
229 | xhr :post, :new, :project_id => 'ecookbook', :title => 'Another page' | |
|
229 | xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} | |
|
230 | 230 | assert_response :success |
|
231 | 231 | assert_template 'new' |
|
232 | 232 | assert_include 'Title has already been taken', response.body |
@@ -236,11 +236,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
236 | 236 | @request.session[:user_id] = 2 |
|
237 | 237 | assert_difference 'WikiPage.count' do |
|
238 | 238 | assert_difference 'WikiContent.count' do |
|
239 |
put :update, :p |
|
|
240 | :id => 'New page', | |
|
241 | :content => {:comments => 'Created the page', | |
|
242 | :text => "h1. New page\n\nThis is a new page", | |
|
243 | :version => 0} | |
|
239 | put :update, :params => { | |
|
240 | :project_id => 1, | |
|
241 | :id => 'New page', | |
|
242 | :content => { | |
|
243 | :comments => 'Created the page', | |
|
244 | :text => "h1. New page\n\nThis is a new page", | |
|
245 | :version => 0 | |
|
246 | } | |
|
247 | } | |
|
244 | 248 | end |
|
245 | 249 | end |
|
246 | 250 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page' |
@@ -255,12 +259,16 class WikiControllerTest < Redmine::ControllerTest | |||
|
255 | 259 | @request.session[:user_id] = 2 |
|
256 | 260 | assert_difference 'WikiPage.count' do |
|
257 | 261 | assert_difference 'Attachment.count' do |
|
258 |
put :update, :p |
|
|
259 | :id => 'New page', | |
|
260 | :content => {:comments => 'Created the page', | |
|
261 | :text => "h1. New page\n\nThis is a new page", | |
|
262 | :version => 0}, | |
|
263 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
262 | put :update, :params => { | |
|
263 | :project_id => 1, | |
|
264 | :id => 'New page', | |
|
265 | :content => { | |
|
266 | :comments => 'Created the page', | |
|
267 | :text => "h1. New page\n\nThis is a new page", | |
|
268 | :version => 0 | |
|
269 | }, | |
|
270 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
271 | } | |
|
264 | 272 | end |
|
265 | 273 | end |
|
266 | 274 | page = Project.find(1).wiki.find_page('New page') |
@@ -271,9 +279,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
271 | 279 | def test_create_page_with_parent |
|
272 | 280 | @request.session[:user_id] = 2 |
|
273 | 281 | assert_difference 'WikiPage.count' do |
|
274 |
put :update, :p |
|
|
275 | :content => {:text => "h1. New page\n\nThis is a new page", :version => 0}, | |
|
282 | put :update, :params => { | |
|
283 | :project_id => 1, | |
|
284 | :id => 'New page', | |
|
285 | :content => { | |
|
286 | :text => "h1. New page\n\nThis is a new page", | |
|
287 | :version => 0 | |
|
288 | }, | |
|
276 | 289 | :wiki_page => {:parent_id => 2} |
|
290 | } | |
|
277 | 291 | end |
|
278 | 292 | page = Project.find(1).wiki.find_page('New page') |
|
279 | 293 | assert_equal WikiPage.find(2), page.parent |
@@ -281,7 +295,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
281 | 295 | |
|
282 | 296 | def test_edit_page |
|
283 | 297 | @request.session[:user_id] = 2 |
|
284 | get :edit, :project_id => 'ecookbook', :id => 'Another_page' | |
|
298 | get :edit, :params => {:project_id => 'ecookbook', :id => 'Another_page'} | |
|
285 | 299 | |
|
286 | 300 | assert_response :success |
|
287 | 301 | assert_template 'edit' |
@@ -292,7 +306,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
292 | 306 | |
|
293 | 307 | def test_edit_section |
|
294 | 308 | @request.session[:user_id] = 2 |
|
295 | get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2 | |
|
309 | get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2} | |
|
296 | 310 | |
|
297 | 311 | assert_response :success |
|
298 | 312 | assert_template 'edit' |
@@ -307,7 +321,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
307 | 321 | |
|
308 | 322 | def test_edit_invalid_section_should_respond_with_404 |
|
309 | 323 | @request.session[:user_id] = 2 |
|
310 | get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10 | |
|
324 | get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10} | |
|
311 | 325 | |
|
312 | 326 | assert_response 404 |
|
313 | 327 | end |
@@ -317,13 +331,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
317 | 331 | assert_no_difference 'WikiPage.count' do |
|
318 | 332 | assert_no_difference 'WikiContent.count' do |
|
319 | 333 | assert_difference 'WikiContent::Version.count' do |
|
320 |
put :update, :p |
|
|
334 | put :update, :params => { | |
|
335 | :project_id => 1, | |
|
321 | 336 | :id => 'Another_page', |
|
322 | 337 | :content => { |
|
323 | 338 | :comments => "my comments", |
|
324 | 339 | :text => "edited", |
|
325 | 340 | :version => 1 |
|
326 | 341 | } |
|
342 | } | |
|
327 | 343 | end |
|
328 | 344 | end |
|
329 | 345 | end |
@@ -340,7 +356,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
340 | 356 | assert_no_difference 'WikiPage.count' do |
|
341 | 357 | assert_no_difference 'WikiContent.count' do |
|
342 | 358 | assert_difference 'WikiContent::Version.count' do |
|
343 |
put :update, :p |
|
|
359 | put :update, :params => { | |
|
360 | :project_id => 1, | |
|
344 | 361 | :id => 'Another_page', |
|
345 | 362 | :content => { |
|
346 | 363 | :comments => "my comments", |
@@ -348,6 +365,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
348 | 365 | :version => 1 |
|
349 | 366 | }, |
|
350 | 367 | :wiki_page => {:parent_id => '1'} |
|
368 | } | |
|
351 | 369 | end |
|
352 | 370 | end |
|
353 | 371 | end |
@@ -365,7 +383,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
365 | 383 | assert_no_difference 'WikiPage.count' do |
|
366 | 384 | assert_no_difference 'WikiContent.count' do |
|
367 | 385 | assert_no_difference 'WikiContent::Version.count' do |
|
368 |
put :update, :p |
|
|
386 | put :update, :params => { | |
|
387 | :project_id => 1, | |
|
369 | 388 | :id => 'Another_page', |
|
370 | 389 | :content => { |
|
371 | 390 | :comments => 'a' * 1300, # failure here, comment is too long |
@@ -374,6 +393,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
374 | 393 | :wiki_page => { |
|
375 | 394 | :parent_id => "" |
|
376 | 395 | } |
|
396 | } | |
|
377 | 397 | end |
|
378 | 398 | end |
|
379 | 399 | end |
@@ -390,7 +410,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
390 | 410 | assert_no_difference 'WikiPage.count' do |
|
391 | 411 | assert_no_difference 'WikiContent.count' do |
|
392 | 412 | assert_no_difference 'WikiContent::Version.count' do |
|
393 |
put :update, :p |
|
|
413 | put :update, :params => { | |
|
414 | :project_id => 1, | |
|
394 | 415 | :id => 'Another_page', |
|
395 | 416 | :content => { |
|
396 | 417 | :comments => '', |
@@ -398,6 +419,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
398 | 419 | :version => 1 |
|
399 | 420 | }, |
|
400 | 421 | :wiki_page => {:parent_id => '1'} |
|
422 | } | |
|
401 | 423 | end |
|
402 | 424 | end |
|
403 | 425 | end |
@@ -412,7 +434,8 class WikiControllerTest < Redmine::ControllerTest | |||
|
412 | 434 | assert_no_difference 'WikiContent.count' do |
|
413 | 435 | assert_no_difference 'WikiContent::Version.count' do |
|
414 | 436 | assert_difference 'Attachment.count' do |
|
415 |
put :update, :p |
|
|
437 | put :update, :params => { | |
|
438 | :project_id => 1, | |
|
416 | 439 | :id => 'Another_page', |
|
417 | 440 | :content => { |
|
418 | 441 | :comments => '', |
@@ -420,6 +443,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
420 | 443 | :version => 1 |
|
421 | 444 | }, |
|
422 | 445 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
446 | } | |
|
423 | 447 | end |
|
424 | 448 | end |
|
425 | 449 | end |
@@ -438,13 +462,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
438 | 462 | assert_no_difference 'WikiPage.count' do |
|
439 | 463 | assert_no_difference 'WikiContent.count' do |
|
440 | 464 | assert_no_difference 'WikiContent::Version.count' do |
|
441 |
put :update, :p |
|
|
465 | put :update, :params => { | |
|
466 | :project_id => 1, | |
|
442 | 467 | :id => 'Another_page', |
|
443 | 468 | :content => { |
|
444 | 469 | :comments => 'My comments', |
|
445 | 470 | :text => 'Text should not be lost', |
|
446 | 471 | :version => 1 |
|
447 | 472 | } |
|
473 | } | |
|
448 | 474 | end |
|
449 | 475 | end |
|
450 | 476 | end |
@@ -465,7 +491,11 class WikiControllerTest < Redmine::ControllerTest | |||
|
465 | 491 | |
|
466 | 492 | assert_no_difference 'WikiPage.count' do |
|
467 | 493 | assert_difference 'WikiContent.count' do |
|
468 | put :update, :project_id => 1, :id => 'NoContent', :content => {:text => 'Some content'} | |
|
494 | put :update, :params => { | |
|
495 | :project_id => 1, | |
|
496 | :id => 'NoContent', | |
|
497 | :content => {:text => 'Some content'} | |
|
498 | } | |
|
469 | 499 | assert_response 302 |
|
470 | 500 | end |
|
471 | 501 | end |
@@ -481,13 +511,16 class WikiControllerTest < Redmine::ControllerTest | |||
|
481 | 511 | assert_no_difference 'WikiPage.count' do |
|
482 | 512 | assert_no_difference 'WikiContent.count' do |
|
483 | 513 | assert_difference 'WikiContent::Version.count' do |
|
484 | put :update, :project_id => 1, :id => 'Page_with_sections', | |
|
514 | put :update, :params => { | |
|
515 | :project_id => 1, | |
|
516 | :id => 'Page_with_sections', | |
|
485 | 517 | :content => { |
|
486 | 518 | :text => "New section content", |
|
487 | 519 | :version => 3 |
|
488 | 520 | }, |
|
489 | 521 | :section => 2, |
|
490 | 522 | :section_hash => hash |
|
523 | } | |
|
491 | 524 | end |
|
492 | 525 | end |
|
493 | 526 | end |
@@ -504,13 +537,16 class WikiControllerTest < Redmine::ControllerTest | |||
|
504 | 537 | assert_no_difference 'WikiPage.count' do |
|
505 | 538 | assert_no_difference 'WikiContent.count' do |
|
506 | 539 | assert_difference 'WikiContent::Version.count' do |
|
507 | put :update, :project_id => 1, :id => 'Page_with_sections', | |
|
540 | put :update, :params => { | |
|
541 | :project_id => 1, | |
|
542 | :id => 'Page_with_sections', | |
|
508 | 543 | :content => { |
|
509 | 544 | :text => "New section content", |
|
510 | 545 | :version => 2 # Current version is 3 |
|
511 | 546 | }, |
|
512 | 547 | :section => 2, |
|
513 | 548 | :section_hash => hash |
|
549 | } | |
|
514 | 550 | end |
|
515 | 551 | end |
|
516 | 552 | end |
@@ -526,7 +562,9 class WikiControllerTest < Redmine::ControllerTest | |||
|
526 | 562 | assert_no_difference 'WikiPage.count' do |
|
527 | 563 | assert_no_difference 'WikiContent.count' do |
|
528 | 564 | assert_no_difference 'WikiContent::Version.count' do |
|
529 | put :update, :project_id => 1, :id => 'Page_with_sections', | |
|
565 | put :update, :params => { | |
|
566 | :project_id => 1, | |
|
567 | :id => 'Page_with_sections', | |
|
530 | 568 | :content => { |
|
531 | 569 | :comments => 'My comments', |
|
532 | 570 | :text => "Text should not be lost", |
@@ -534,6 +572,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
534 | 572 | }, |
|
535 | 573 | :section => 2, |
|
536 | 574 | :section_hash => Digest::MD5.hexdigest("wrong hash") |
|
575 | } | |
|
537 | 576 | end |
|
538 | 577 | end |
|
539 | 578 | end |
@@ -546,10 +585,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
546 | 585 | |
|
547 | 586 | def test_preview |
|
548 | 587 | @request.session[:user_id] = 2 |
|
549 | xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', | |
|
550 | :content => { :comments => '', | |
|
551 | :text => 'this is a *previewed text*', | |
|
552 | :version => 3 } | |
|
588 | xhr :post, :preview, :params => { | |
|
589 | :project_id => 1, | |
|
590 | :id => 'CookBook_documentation', | |
|
591 | :content => { | |
|
592 | :comments => '', | |
|
593 | :text => 'this is a *previewed text*', | |
|
594 | :version => 3 | |
|
595 | } | |
|
596 | } | |
|
553 | 597 | assert_response :success |
|
554 | 598 | assert_template 'common/_preview' |
|
555 | 599 | assert_select 'strong', :text => /previewed text/ |
@@ -557,10 +601,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
557 | 601 | |
|
558 | 602 | def test_preview_new_page |
|
559 | 603 | @request.session[:user_id] = 2 |
|
560 |
xhr :post, :preview, :p |
|
|
561 | :content => { :text => 'h1. New page', | |
|
562 | :comments => '', | |
|
563 | :version => 0 } | |
|
604 | xhr :post, :preview, :params => { | |
|
605 | :project_id => 1, | |
|
606 | :id => 'New page', | |
|
607 | :content => { | |
|
608 | :text => 'h1. New page', | |
|
609 | :comments => '', | |
|
610 | :version => 0 | |
|
611 | } | |
|
612 | } | |
|
564 | 613 | assert_response :success |
|
565 | 614 | assert_template 'common/_preview' |
|
566 | 615 | assert_select 'h1', :text => /New page/ |
@@ -568,7 +617,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
568 | 617 | |
|
569 | 618 | def test_history |
|
570 | 619 | @request.session[:user_id] = 2 |
|
571 | get :history, :project_id => 'ecookbook', :id => 'CookBook_documentation' | |
|
620 | get :history, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation'} | |
|
572 | 621 | assert_response :success |
|
573 | 622 | assert_template 'history' |
|
574 | 623 | assert_not_nil assigns(:versions) |
@@ -584,7 +633,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
584 | 633 | |
|
585 | 634 | def test_history_with_one_version |
|
586 | 635 | @request.session[:user_id] = 2 |
|
587 | get :history, :project_id => 'ecookbook', :id => 'Another_page' | |
|
636 | get :history, :params => {:project_id => 'ecookbook', :id => 'Another_page'} | |
|
588 | 637 | assert_response :success |
|
589 | 638 | assert_template 'history' |
|
590 | 639 | assert_not_nil assigns(:versions) |
@@ -606,7 +655,11 class WikiControllerTest < Redmine::ControllerTest | |||
|
606 | 655 | content.save! |
|
607 | 656 | end |
|
608 | 657 | |
|
609 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => content.version, :version_from => (content.version - 1) | |
|
658 | get :diff, :params => { | |
|
659 | :project_id => 1, :id => 'CookBook_documentation', | |
|
660 | :version => content.version, | |
|
661 | :version_from => (content.version - 1) | |
|
662 | } | |
|
610 | 663 | assert_response :success |
|
611 | 664 | assert_template 'diff' |
|
612 | 665 | assert_select 'span.diff_out', :text => 'Line removed' |
@@ -614,17 +667,27 class WikiControllerTest < Redmine::ControllerTest | |||
|
614 | 667 | end |
|
615 | 668 | |
|
616 | 669 | def test_diff_with_invalid_version_should_respond_with_404 |
|
617 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99' | |
|
670 | get :diff, :params => { | |
|
671 | :project_id => 1, :id => 'CookBook_documentation', | |
|
672 | :version => '99' | |
|
673 | } | |
|
618 | 674 | assert_response 404 |
|
619 | 675 | end |
|
620 | 676 | |
|
621 | 677 | def test_diff_with_invalid_version_from_should_respond_with_404 |
|
622 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99', :version_from => '98' | |
|
678 | get :diff, :params => { | |
|
679 | :project_id => 1, :id => 'CookBook_documentation', | |
|
680 | :version => '99', | |
|
681 | :version_from => '98' | |
|
682 | } | |
|
623 | 683 | assert_response 404 |
|
624 | 684 | end |
|
625 | 685 | |
|
626 | 686 | def test_annotate |
|
627 | get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2 | |
|
687 | get :annotate, :params => { | |
|
688 | :project_id => 1, :id => 'CookBook_documentation', | |
|
689 | :version => 2 | |
|
690 | } | |
|
628 | 691 | assert_response :success |
|
629 | 692 | assert_template 'annotate' |
|
630 | 693 | |
@@ -644,13 +707,16 class WikiControllerTest < Redmine::ControllerTest | |||
|
644 | 707 | end |
|
645 | 708 | |
|
646 | 709 | def test_annotate_with_invalid_version_should_respond_with_404 |
|
647 | get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => '99' | |
|
710 | get :annotate, :params => { | |
|
711 | :project_id => 1, :id => 'CookBook_documentation', | |
|
712 | :version => '99' | |
|
713 | } | |
|
648 | 714 | assert_response 404 |
|
649 | 715 | end |
|
650 | 716 | |
|
651 | 717 | def test_get_rename |
|
652 | 718 | @request.session[:user_id] = 2 |
|
653 | get :rename, :project_id => 1, :id => 'Another_page' | |
|
719 | get :rename, :params => {:project_id => 1, :id => 'Another_page'} | |
|
654 | 720 | assert_response :success |
|
655 | 721 | assert_template 'rename' |
|
656 | 722 | |
@@ -662,7 +728,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
662 | 728 | |
|
663 | 729 | def test_get_rename_child_page |
|
664 | 730 | @request.session[:user_id] = 2 |
|
665 | get :rename, :project_id => 1, :id => 'Child_1' | |
|
731 | get :rename, :params => {:project_id => 1, :id => 'Child_1'} | |
|
666 | 732 | assert_response :success |
|
667 | 733 | assert_template 'rename' |
|
668 | 734 | |
@@ -674,9 +740,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
674 | 740 | |
|
675 | 741 | def test_rename_with_redirect |
|
676 | 742 | @request.session[:user_id] = 2 |
|
677 | post :rename, :project_id => 1, :id => 'Another_page', | |
|
678 | :wiki_page => { :title => 'Another renamed page', | |
|
679 | :redirect_existing_links => 1 } | |
|
743 | post :rename, :params => { | |
|
744 | :project_id => 1, | |
|
745 | :id => 'Another_page', | |
|
746 | :wiki_page => { | |
|
747 | :title => 'Another renamed page', | |
|
748 | :redirect_existing_links => 1 | |
|
749 | } | |
|
750 | } | |
|
680 | 751 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' |
|
681 | 752 | wiki = Project.find(1).wiki |
|
682 | 753 | # Check redirects |
@@ -686,9 +757,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
686 | 757 | |
|
687 | 758 | def test_rename_without_redirect |
|
688 | 759 | @request.session[:user_id] = 2 |
|
689 | post :rename, :project_id => 1, :id => 'Another_page', | |
|
690 | :wiki_page => { :title => 'Another renamed page', | |
|
691 | :redirect_existing_links => "0" } | |
|
760 | post :rename, :params => { | |
|
761 | :project_id => 1, | |
|
762 | :id => 'Another_page', | |
|
763 | :wiki_page => { | |
|
764 | :title => 'Another renamed page', | |
|
765 | :redirect_existing_links => "0" | |
|
766 | } | |
|
767 | } | |
|
692 | 768 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' |
|
693 | 769 | wiki = Project.find(1).wiki |
|
694 | 770 | # Check that there's no redirects |
@@ -697,16 +773,30 class WikiControllerTest < Redmine::ControllerTest | |||
|
697 | 773 | |
|
698 | 774 | def test_rename_with_parent_assignment |
|
699 | 775 | @request.session[:user_id] = 2 |
|
700 | post :rename, :project_id => 1, :id => 'Another_page', | |
|
701 | :wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' } | |
|
776 | post :rename, :params => { | |
|
777 | :project_id => 1, | |
|
778 | :id => 'Another_page', | |
|
779 | :wiki_page => { | |
|
780 | :title => 'Another page', | |
|
781 | :redirect_existing_links => "0", | |
|
782 | :parent_id => '4' | |
|
783 | } | |
|
784 | } | |
|
702 | 785 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' |
|
703 | 786 | assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent |
|
704 | 787 | end |
|
705 | 788 | |
|
706 | 789 | def test_rename_with_parent_unassignment |
|
707 | 790 | @request.session[:user_id] = 2 |
|
708 |
post :rename, :p |
|
|
709 | :wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' } | |
|
791 | post :rename, :params => { | |
|
792 | :project_id => 1, | |
|
793 | :id => 'Child_1', | |
|
794 | :wiki_page => { | |
|
795 | :title => 'Child 1', | |
|
796 | :redirect_existing_links => "0", | |
|
797 | :parent_id => '' | |
|
798 | } | |
|
799 | } | |
|
710 | 800 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1' |
|
711 | 801 | assert_nil WikiPage.find_by_title('Child_1').parent |
|
712 | 802 | end |
@@ -716,7 +806,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
716 | 806 | project = Project.find(5) |
|
717 | 807 | project.enable_module! :wiki |
|
718 | 808 | |
|
719 | get :rename, :project_id => 1, :id => 'Another_page' | |
|
809 | get :rename, :params => {:project_id => 1, :id => 'Another_page'} | |
|
720 | 810 | assert_response :success |
|
721 | 811 | assert_template 'rename' |
|
722 | 812 | |
@@ -732,12 +822,15 class WikiControllerTest < Redmine::ControllerTest | |||
|
732 | 822 | project = Project.find(5) |
|
733 | 823 | project.enable_module! :wiki |
|
734 | 824 | |
|
735 | post :rename, :project_id => 1, :id => 'Another_page', | |
|
825 | post :rename, :params => { | |
|
826 | :project_id => 1, | |
|
827 | :id => 'Another_page', | |
|
736 | 828 | :wiki_page => { |
|
737 | 829 | :wiki_id => project.wiki.id.to_s, |
|
738 | 830 | :title => 'Another renamed page', |
|
739 | 831 | :redirect_existing_links => 1 |
|
740 | 832 | } |
|
833 | } | |
|
741 | 834 | assert_redirected_to '/projects/private-child/wiki/Another_renamed_page' |
|
742 | 835 | |
|
743 | 836 | page = WikiPage.find(2) |
@@ -746,14 +839,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
746 | 839 | |
|
747 | 840 | def test_destroy_a_page_without_children_should_not_ask_confirmation |
|
748 | 841 | @request.session[:user_id] = 2 |
|
749 | delete :destroy, :project_id => 1, :id => 'Child_2' | |
|
842 | delete :destroy, :params => {:project_id => 1, :id => 'Child_2'} | |
|
750 | 843 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
751 | 844 | end |
|
752 | 845 | |
|
753 | 846 | def test_destroy_parent_should_ask_confirmation |
|
754 | 847 | @request.session[:user_id] = 2 |
|
755 | 848 | assert_no_difference('WikiPage.count') do |
|
756 | delete :destroy, :project_id => 1, :id => 'Another_page' | |
|
849 | delete :destroy, :params => {:project_id => 1, :id => 'Another_page'} | |
|
757 | 850 | end |
|
758 | 851 | assert_response :success |
|
759 | 852 | assert_template 'destroy' |
@@ -767,7 +860,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
767 | 860 | def test_destroy_parent_with_nullify_should_delete_parent_only |
|
768 | 861 | @request.session[:user_id] = 2 |
|
769 | 862 | assert_difference('WikiPage.count', -1) do |
|
770 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify' | |
|
863 | delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'nullify'} | |
|
771 | 864 | end |
|
772 | 865 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
773 | 866 | assert_nil WikiPage.find_by_id(2) |
@@ -776,7 +869,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
776 | 869 | def test_destroy_parent_with_cascade_should_delete_descendants |
|
777 | 870 | @request.session[:user_id] = 2 |
|
778 | 871 | assert_difference('WikiPage.count', -4) do |
|
779 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy' | |
|
872 | delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'destroy'} | |
|
780 | 873 | end |
|
781 | 874 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
782 | 875 | assert_nil WikiPage.find_by_id(2) |
@@ -786,7 +879,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
786 | 879 | def test_destroy_parent_with_reassign |
|
787 | 880 | @request.session[:user_id] = 2 |
|
788 | 881 | assert_difference('WikiPage.count', -1) do |
|
789 | delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 | |
|
882 | delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1} | |
|
790 | 883 | end |
|
791 | 884 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
792 | 885 | assert_nil WikiPage.find_by_id(2) |
@@ -798,7 +891,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
798 | 891 | assert_difference 'WikiContent::Version.count', -1 do |
|
799 | 892 | assert_no_difference 'WikiContent.count' do |
|
800 | 893 | assert_no_difference 'WikiPage.count' do |
|
801 | delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 2 | |
|
894 | delete :destroy_version, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 2} | |
|
802 | 895 | assert_redirected_to '/projects/ecookbook/wiki/CookBook_documentation/history' |
|
803 | 896 | end |
|
804 | 897 | end |
@@ -810,7 +903,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
810 | 903 | assert_no_difference 'WikiContent::Version.count' do |
|
811 | 904 | assert_no_difference 'WikiContent.count' do |
|
812 | 905 | assert_no_difference 'WikiPage.count' do |
|
813 | delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 99 | |
|
906 | delete :destroy_version, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 99} | |
|
814 | 907 | end |
|
815 | 908 | end |
|
816 | 909 | end |
@@ -818,7 +911,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
818 | 911 | end |
|
819 | 912 | |
|
820 | 913 | def test_index |
|
821 | get :index, :project_id => 'ecookbook' | |
|
914 | get :index, :params => {:project_id => 'ecookbook'} | |
|
822 | 915 | assert_response :success |
|
823 | 916 | assert_template 'index' |
|
824 | 917 | pages = assigns(:pages) |
@@ -836,13 +929,13 class WikiControllerTest < Redmine::ControllerTest | |||
|
836 | 929 | end |
|
837 | 930 | |
|
838 | 931 | def test_index_should_include_atom_link |
|
839 | get :index, :project_id => 'ecookbook' | |
|
932 | get :index, :params => {:project_id => 'ecookbook'} | |
|
840 | 933 | assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1' |
|
841 | 934 | end |
|
842 | 935 | |
|
843 | 936 | def test_export_to_html |
|
844 | 937 | @request.session[:user_id] = 2 |
|
845 | get :export, :project_id => 'ecookbook' | |
|
938 | get :export, :params => {:project_id => 'ecookbook'} | |
|
846 | 939 | |
|
847 | 940 | assert_response :success |
|
848 | 941 | assert_not_nil assigns(:pages) |
@@ -856,7 +949,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
856 | 949 | |
|
857 | 950 | def test_export_to_pdf |
|
858 | 951 | @request.session[:user_id] = 2 |
|
859 | get :export, :project_id => 'ecookbook', :format => 'pdf' | |
|
952 | get :export, :params => {:project_id => 'ecookbook', :format => 'pdf'} | |
|
860 | 953 | |
|
861 | 954 | assert_response :success |
|
862 | 955 | assert_not_nil assigns(:pages) |
@@ -869,13 +962,13 class WikiControllerTest < Redmine::ControllerTest | |||
|
869 | 962 | def test_export_without_permission_should_be_denied |
|
870 | 963 | @request.session[:user_id] = 2 |
|
871 | 964 | Role.find_by_name('Manager').remove_permission! :export_wiki_pages |
|
872 | get :export, :project_id => 'ecookbook' | |
|
965 | get :export, :params => {:project_id => 'ecookbook'} | |
|
873 | 966 | |
|
874 | 967 | assert_response 403 |
|
875 | 968 | end |
|
876 | 969 | |
|
877 | 970 | def test_date_index |
|
878 | get :date_index, :project_id => 'ecookbook' | |
|
971 | get :date_index, :params => {:project_id => 'ecookbook'} | |
|
879 | 972 | |
|
880 | 973 | assert_response :success |
|
881 | 974 | assert_template 'date_index' |
@@ -886,7 +979,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
886 | 979 | end |
|
887 | 980 | |
|
888 | 981 | def test_not_found |
|
889 | get :show, :project_id => 999 | |
|
982 | get :show, :params => {:project_id => 999} | |
|
890 | 983 | assert_response 404 |
|
891 | 984 | end |
|
892 | 985 | |
@@ -894,7 +987,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
894 | 987 | page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') |
|
895 | 988 | assert !page.protected? |
|
896 | 989 | @request.session[:user_id] = 2 |
|
897 | post :protect, :project_id => 1, :id => page.title, :protected => '1' | |
|
990 | post :protect, :params => {:project_id => 1, :id => page.title, :protected => '1'} | |
|
898 | 991 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' |
|
899 | 992 | assert page.reload.protected? |
|
900 | 993 | end |
@@ -903,14 +996,14 class WikiControllerTest < Redmine::ControllerTest | |||
|
903 | 996 | page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') |
|
904 | 997 | assert page.protected? |
|
905 | 998 | @request.session[:user_id] = 2 |
|
906 | post :protect, :project_id => 1, :id => page.title, :protected => '0' | |
|
999 | post :protect, :params => {:project_id => 1, :id => page.title, :protected => '0'} | |
|
907 | 1000 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation' |
|
908 | 1001 | assert !page.reload.protected? |
|
909 | 1002 | end |
|
910 | 1003 | |
|
911 | 1004 | def test_show_page_with_edit_link |
|
912 | 1005 | @request.session[:user_id] = 2 |
|
913 | get :show, :project_id => 1 | |
|
1006 | get :show, :params => {:project_id => 1} | |
|
914 | 1007 | assert_response :success |
|
915 | 1008 | assert_template 'show' |
|
916 | 1009 | assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit' |
@@ -918,7 +1011,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
918 | 1011 | |
|
919 | 1012 | def test_show_page_without_edit_link |
|
920 | 1013 | @request.session[:user_id] = 4 |
|
921 | get :show, :project_id => 1 | |
|
1014 | get :show, :params => {:project_id => 1} | |
|
922 | 1015 | assert_response :success |
|
923 | 1016 | assert_template 'show' |
|
924 | 1017 | assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0 |
@@ -926,7 +1019,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
926 | 1019 | |
|
927 | 1020 | def test_show_pdf |
|
928 | 1021 | @request.session[:user_id] = 2 |
|
929 | get :show, :project_id => 1, :format => 'pdf' | |
|
1022 | get :show, :params => {:project_id => 1, :format => 'pdf'} | |
|
930 | 1023 | assert_response :success |
|
931 | 1024 | assert_not_nil assigns(:page) |
|
932 | 1025 | assert_equal 'application/pdf', @response.content_type |
@@ -936,7 +1029,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
936 | 1029 | |
|
937 | 1030 | def test_show_html |
|
938 | 1031 | @request.session[:user_id] = 2 |
|
939 | get :show, :project_id => 1, :format => 'html' | |
|
1032 | get :show, :params => {:project_id => 1, :format => 'html'} | |
|
940 | 1033 | assert_response :success |
|
941 | 1034 | assert_not_nil assigns(:page) |
|
942 | 1035 | assert_equal 'text/html', @response.content_type |
@@ -947,7 +1040,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
947 | 1040 | |
|
948 | 1041 | def test_show_versioned_html |
|
949 | 1042 | @request.session[:user_id] = 2 |
|
950 | get :show, :project_id => 1, :format => 'html', :version => 2 | |
|
1043 | get :show, :params => {:project_id => 1, :format => 'html', :version => 2} | |
|
951 | 1044 | assert_response :success |
|
952 | 1045 | assert_not_nil assigns(:content) |
|
953 | 1046 | assert_equal 2, assigns(:content).version |
@@ -959,7 +1052,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
959 | 1052 | |
|
960 | 1053 | def test_show_txt |
|
961 | 1054 | @request.session[:user_id] = 2 |
|
962 | get :show, :project_id => 1, :format => 'txt' | |
|
1055 | get :show, :params => {:project_id => 1, :format => 'txt'} | |
|
963 | 1056 | assert_response :success |
|
964 | 1057 | assert_not_nil assigns(:page) |
|
965 | 1058 | assert_equal 'text/plain', @response.content_type |
@@ -970,7 +1063,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
970 | 1063 | |
|
971 | 1064 | def test_show_versioned_txt |
|
972 | 1065 | @request.session[:user_id] = 2 |
|
973 | get :show, :project_id => 1, :format => 'txt', :version => 2 | |
|
1066 | get :show, :params => {:project_id => 1, :format => 'txt', :version => 2} | |
|
974 | 1067 | assert_response :success |
|
975 | 1068 | assert_not_nil assigns(:content) |
|
976 | 1069 | assert_equal 2, assigns(:content).version |
@@ -983,7 +1076,7 class WikiControllerTest < Redmine::ControllerTest | |||
|
983 | 1076 | def test_edit_unprotected_page |
|
984 | 1077 | # Non members can edit unprotected wiki pages |
|
985 | 1078 | @request.session[:user_id] = 4 |
|
986 | get :edit, :project_id => 1, :id => 'Another_page' | |
|
1079 | get :edit, :params => {:project_id => 1, :id => 'Another_page'} | |
|
987 | 1080 | assert_response :success |
|
988 | 1081 | assert_template 'edit' |
|
989 | 1082 | end |
@@ -991,30 +1084,32 class WikiControllerTest < Redmine::ControllerTest | |||
|
991 | 1084 | def test_edit_protected_page_by_nonmember |
|
992 | 1085 | # Non members cannot edit protected wiki pages |
|
993 | 1086 | @request.session[:user_id] = 4 |
|
994 | get :edit, :project_id => 1, :id => 'CookBook_documentation' | |
|
1087 | get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} | |
|
995 | 1088 | assert_response 403 |
|
996 | 1089 | end |
|
997 | 1090 | |
|
998 | 1091 | def test_edit_protected_page_by_member |
|
999 | 1092 | @request.session[:user_id] = 2 |
|
1000 | get :edit, :project_id => 1, :id => 'CookBook_documentation' | |
|
1093 | get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} | |
|
1001 | 1094 | assert_response :success |
|
1002 | 1095 | assert_template 'edit' |
|
1003 | 1096 | end |
|
1004 | 1097 | |
|
1005 | 1098 | def test_history_of_non_existing_page_should_return_404 |
|
1006 | get :history, :project_id => 1, :id => 'Unknown_page' | |
|
1099 | get :history, :params => {:project_id => 1, :id => 'Unknown_page'} | |
|
1007 | 1100 | assert_response 404 |
|
1008 | 1101 | end |
|
1009 | 1102 | |
|
1010 | 1103 | def test_add_attachment |
|
1011 | 1104 | @request.session[:user_id] = 2 |
|
1012 | 1105 | assert_difference 'Attachment.count' do |
|
1013 | post :add_attachment, :project_id => 1, :id => 'CookBook_documentation', | |
|
1014 | :attachments => { | |
|
1015 | '1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), | |
|
1016 | 'description' => 'test file'} | |
|
1017 | } | |
|
1106 | post :add_attachment, :params => { | |
|
1107 | :project_id => 1, | |
|
1108 | :id => 'CookBook_documentation', | |
|
1109 | :attachments => { | |
|
1110 | '1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'} | |
|
1111 | } | |
|
1112 | } | |
|
1018 | 1113 | end |
|
1019 | 1114 | attachment = Attachment.order('id DESC').first |
|
1020 | 1115 | assert_equal Wiki.find(1).find_page('CookBook_documentation'), attachment.container |
@@ -29,7 +29,7 class WikisControllerTest < Redmine::ControllerTest | |||
|
29 | 29 | assert_nil Project.find(3).wiki |
|
30 | 30 | |
|
31 | 31 | assert_difference 'Wiki.count' do |
|
32 | xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' } | |
|
32 | xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }} | |
|
33 | 33 | assert_response :success |
|
34 | 34 | assert_template 'edit' |
|
35 | 35 | assert_equal 'text/javascript', response.content_type |
@@ -44,7 +44,7 class WikisControllerTest < Redmine::ControllerTest | |||
|
44 | 44 | @request.session[:user_id] = 1 |
|
45 | 45 | |
|
46 | 46 | assert_no_difference 'Wiki.count' do |
|
47 | xhr :post, :edit, :id => 3, :wiki => { :start_page => '' } | |
|
47 | xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }} | |
|
48 | 48 | assert_response :success |
|
49 | 49 | assert_template 'edit' |
|
50 | 50 | assert_equal 'text/javascript', response.content_type |
@@ -58,7 +58,7 class WikisControllerTest < Redmine::ControllerTest | |||
|
58 | 58 | @request.session[:user_id] = 1 |
|
59 | 59 | |
|
60 | 60 | assert_no_difference 'Wiki.count' do |
|
61 | xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' } | |
|
61 | xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }} | |
|
62 | 62 | assert_response :success |
|
63 | 63 | assert_template 'edit' |
|
64 | 64 | assert_equal 'text/javascript', response.content_type |
@@ -70,7 +70,7 class WikisControllerTest < Redmine::ControllerTest | |||
|
70 | 70 | |
|
71 | 71 | def test_destroy |
|
72 | 72 | @request.session[:user_id] = 1 |
|
73 | post :destroy, :id => 1, :confirm => 1 | |
|
73 | post :destroy, :params => {:id => 1, :confirm => 1} | |
|
74 | 74 | assert_redirected_to :controller => 'projects', |
|
75 | 75 | :action => 'settings', :id => 'ecookbook', :tab => 'wiki' |
|
76 | 76 | assert_nil Project.find(1).wiki |
@@ -78,7 +78,7 class WikisControllerTest < Redmine::ControllerTest | |||
|
78 | 78 | |
|
79 | 79 | def test_not_found |
|
80 | 80 | @request.session[:user_id] = 1 |
|
81 | post :destroy, :id => 999, :confirm => 1 | |
|
81 | post :destroy, :params => {:id => 999, :confirm => 1} | |
|
82 | 82 | assert_response 404 |
|
83 | 83 | end |
|
84 | 84 | end |
@@ -45,7 +45,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
45 | 45 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) |
|
46 | 46 | WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5) |
|
47 | 47 | |
|
48 | get :edit, :role_id => 2, :tracker_id => 1 | |
|
48 | get :edit, :params => {:role_id => 2, :tracker_id => 1} | |
|
49 | 49 | assert_response :success |
|
50 | 50 | assert_template 'edit' |
|
51 | 51 | |
@@ -65,14 +65,14 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
65 | 65 | WorkflowTransition.delete_all |
|
66 | 66 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1) |
|
67 | 67 | |
|
68 | get :edit, :role_id => 1, :tracker_id => 1 | |
|
68 | get :edit, :params => {:role_id => 1, :tracker_id => 1} | |
|
69 | 69 | assert_response :success |
|
70 | 70 | assert_select 'td', 'New issue' |
|
71 | 71 | assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[0][1][always]' |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | def test_get_edit_with_all_roles_and_all_trackers |
|
75 | get :edit, :role_id => 'all', :tracker_id => 'all' | |
|
75 | get :edit, :params => {:role_id => 'all', :tracker_id => 'all'} | |
|
76 | 76 | assert_response :success |
|
77 | 77 | assert_equal Role.sorted.to_a, assigns(:roles) |
|
78 | 78 | assert_equal Tracker.sorted.to_a, assigns(:trackers) |
@@ -81,7 +81,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
81 | 81 | def test_get_edit_with_role_and_tracker_and_all_statuses |
|
82 | 82 | WorkflowTransition.delete_all |
|
83 | 83 | |
|
84 | get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0' | |
|
84 | get :edit, :params => {:role_id => 2, :tracker_id => 1, :used_statuses_only => '0'} | |
|
85 | 85 | assert_response :success |
|
86 | 86 | assert_template 'edit' |
|
87 | 87 | |
@@ -94,11 +94,14 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
94 | 94 | def test_post_edit |
|
95 | 95 | WorkflowTransition.delete_all |
|
96 | 96 | |
|
97 | post :edit, :role_id => 2, :tracker_id => 1, | |
|
97 | post :edit, :params => { | |
|
98 | :role_id => 2, | |
|
99 | :tracker_id => 1, | |
|
98 | 100 | :transitions => { |
|
99 | 101 | '4' => {'5' => {'always' => '1'}}, |
|
100 | 102 | '3' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} |
|
101 | 103 | } |
|
104 | } | |
|
102 | 105 | assert_response 302 |
|
103 | 106 | |
|
104 | 107 | assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count |
@@ -109,10 +112,13 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
109 | 112 | def test_post_edit_with_allowed_statuses_for_new_issues |
|
110 | 113 | WorkflowTransition.delete_all |
|
111 | 114 | |
|
112 | post :edit, :role_id => 2, :tracker_id => 1, | |
|
115 | post :edit, :params => { | |
|
116 | :role_id => 2, | |
|
117 | :tracker_id => 1, | |
|
113 | 118 | :transitions => { |
|
114 | 119 | '0' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} |
|
115 | 120 | } |
|
121 | } | |
|
116 | 122 | assert_response 302 |
|
117 | 123 | |
|
118 | 124 | assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1).any? |
@@ -123,13 +129,16 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
123 | 129 | def test_post_edit_with_additional_transitions |
|
124 | 130 | WorkflowTransition.delete_all |
|
125 | 131 | |
|
126 | post :edit, :role_id => 2, :tracker_id => 1, | |
|
132 | post :edit, :params => { | |
|
133 | :role_id => 2, | |
|
134 | :tracker_id => 1, | |
|
127 | 135 | :transitions => { |
|
128 | 136 | '4' => {'5' => {'always' => '1', 'author' => '0', 'assignee' => '0'}}, |
|
129 | 137 | '3' => {'1' => {'always' => '0', 'author' => '1', 'assignee' => '0'}, |
|
130 | 138 | '2' => {'always' => '0', 'author' => '0', 'assignee' => '1'}, |
|
131 | 139 | '4' => {'always' => '0', 'author' => '1', 'assignee' => '1'}} |
|
132 | 140 | } |
|
141 | } | |
|
133 | 142 | assert_response 302 |
|
134 | 143 | |
|
135 | 144 | assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count |
@@ -161,7 +170,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
161 | 170 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required') |
|
162 | 171 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly') |
|
163 | 172 | |
|
164 | get :permissions, :role_id => 1, :tracker_id => 2 | |
|
173 | get :permissions, :params => {:role_id => 1, :tracker_id => 2} | |
|
165 | 174 | assert_response :success |
|
166 | 175 | assert_template 'permissions' |
|
167 | 176 | |
@@ -202,7 +211,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
202 | 211 | def test_get_permissions_with_required_custom_field_should_not_show_required_option |
|
203 | 212 | cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true) |
|
204 | 213 | |
|
205 | get :permissions, :role_id => 1, :tracker_id => 1 | |
|
214 | get :permissions, :params => {:role_id => 1, :tracker_id => 1} | |
|
206 | 215 | assert_response :success |
|
207 | 216 | assert_template 'permissions' |
|
208 | 217 | |
@@ -220,7 +229,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
220 | 229 | cf2 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1]) |
|
221 | 230 | cf3 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1, 2]) |
|
222 | 231 | |
|
223 | get :permissions, :role_id => 2, :tracker_id => 1 | |
|
232 | get :permissions, :params => {:role_id => 2, :tracker_id => 1} | |
|
224 | 233 | assert_response :success |
|
225 | 234 | assert_template 'permissions' |
|
226 | 235 | |
@@ -236,7 +245,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
236 | 245 | WorkflowPermission.delete_all |
|
237 | 246 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
238 | 247 | |
|
239 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
|
248 | get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |
|
240 | 249 | assert_response :success |
|
241 | 250 | |
|
242 | 251 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
@@ -250,7 +259,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
250 | 259 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
251 | 260 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'readonly') |
|
252 | 261 | |
|
253 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
|
262 | get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |
|
254 | 263 | assert_response :success |
|
255 | 264 | |
|
256 | 265 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
@@ -264,7 +273,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
264 | 273 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
265 | 274 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
266 | 275 | |
|
267 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
|
276 | get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |
|
268 | 277 | assert_response :success |
|
269 | 278 | |
|
270 | 279 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
@@ -276,7 +285,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
276 | 285 | def test_get_permissions_with_role_and_tracker_and_all_statuses_should_show_all_statuses |
|
277 | 286 | WorkflowTransition.delete_all |
|
278 | 287 | |
|
279 | get :permissions, :role_id => 1, :tracker_id => 2, :used_statuses_only => '0' | |
|
288 | get :permissions, :params => {:role_id => 1, :tracker_id => 2, :used_statuses_only => '0'} | |
|
280 | 289 | assert_response :success |
|
281 | 290 | assert_equal IssueStatus.sorted.to_a, assigns(:statuses) |
|
282 | 291 | end |
@@ -287,7 +296,7 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
287 | 296 | cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [2]) |
|
288 | 297 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => cf.id, :rule => 'required') |
|
289 | 298 | |
|
290 | get :permissions, :role_id => 1, :tracker_id => 2 | |
|
299 | get :permissions, :params => {:role_id => 1, :tracker_id => 2} | |
|
291 | 300 | assert_response :success |
|
292 | 301 | assert_select 'td.required > select[name=?]', 'permissions[1][assigned_to_id]' |
|
293 | 302 | assert_select 'td.required > select[name=?]', "permissions[1][#{cf.id}]" |
@@ -296,10 +305,14 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
296 | 305 | def test_post_permissions |
|
297 | 306 | WorkflowPermission.delete_all |
|
298 | 307 | |
|
299 |
post :permissions, : |
|
|
300 | '1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, | |
|
301 | '2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, | |
|
302 | '3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |
|
308 | post :permissions, :params => { | |
|
309 | :role_id => 1, | |
|
310 | :tracker_id => 2, | |
|
311 | :permissions => { | |
|
312 | '1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, | |
|
313 | '2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, | |
|
314 | '3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |
|
315 | } | |
|
303 | 316 | } |
|
304 | 317 | assert_response 302 |
|
305 | 318 | |
@@ -335,8 +348,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
335 | 348 | def test_post_copy_one_to_one |
|
336 | 349 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) |
|
337 | 350 | |
|
338 | post :copy, :source_tracker_id => '1', :source_role_id => '2', | |
|
339 |
|
|
|
351 | post :copy, :params => { | |
|
352 | :source_tracker_id => '1', :source_role_id => '2', | |
|
353 | :target_tracker_ids => ['3'], :target_role_ids => ['1'] | |
|
354 | } | |
|
340 | 355 | assert_response 302 |
|
341 | 356 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) |
|
342 | 357 | end |
@@ -344,8 +359,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
344 | 359 | def test_post_copy_one_to_many |
|
345 | 360 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) |
|
346 | 361 | |
|
347 | post :copy, :source_tracker_id => '1', :source_role_id => '2', | |
|
348 |
|
|
|
362 | post :copy, :params => { | |
|
363 | :source_tracker_id => '1', :source_role_id => '2', | |
|
364 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |
|
365 | } | |
|
349 | 366 | assert_response 302 |
|
350 | 367 | assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) |
|
351 | 368 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) |
@@ -357,8 +374,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
357 | 374 | source_t2 = status_transitions(:tracker_id => 2, :role_id => 2) |
|
358 | 375 | source_t3 = status_transitions(:tracker_id => 3, :role_id => 2) |
|
359 | 376 | |
|
360 | post :copy, :source_tracker_id => 'any', :source_role_id => '2', | |
|
361 |
|
|
|
377 | post :copy, :params => { | |
|
378 | :source_tracker_id => 'any', :source_role_id => '2', | |
|
379 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |
|
380 | } | |
|
362 | 381 | assert_response 302 |
|
363 | 382 | assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) |
|
364 | 383 | assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) |
@@ -368,9 +387,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
368 | 387 | |
|
369 | 388 | def test_post_copy_with_incomplete_source_specification_should_fail |
|
370 | 389 | assert_no_difference 'WorkflowRule.count' do |
|
371 | post :copy, | |
|
390 | post :copy, :params => { | |
|
372 | 391 | :source_tracker_id => '', :source_role_id => '2', |
|
373 | 392 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] |
|
393 | } | |
|
374 | 394 | assert_response 200 |
|
375 | 395 | assert_select 'div.flash.error', :text => 'Please select a source tracker or role' |
|
376 | 396 | end |
@@ -378,9 +398,10 class WorkflowsControllerTest < Redmine::ControllerTest | |||
|
378 | 398 | |
|
379 | 399 | def test_post_copy_with_incomplete_target_specification_should_fail |
|
380 | 400 | assert_no_difference 'WorkflowRule.count' do |
|
381 | post :copy, | |
|
401 | post :copy, :params => { | |
|
382 | 402 | :source_tracker_id => '1', :source_role_id => '2', |
|
383 | 403 | :target_tracker_ids => ['2', '3'] |
|
404 | } | |
|
384 | 405 | assert_response 200 |
|
385 | 406 | assert_select 'div.flash.error', :text => 'Please select target tracker(s) and role(s)' |
|
386 | 407 | end |
@@ -278,10 +278,10 module Redmine | |||
|
278 | 278 | end |
|
279 | 279 | |
|
280 | 280 | class ControllerTest < ActionController::TestCase |
|
281 |
def process(method, path, parameters={}, |
|
|
282 | if parameters.key?(:params) | |
|
283 |
raise ArgumentError if |
|
|
284 | super method, path, parameters[:params], parameters.except(:params) | |
|
281 | def process(method, path, parameters={}, session={}, flash={}) | |
|
282 | if parameters.key?(:params) || parameters.key?(:session) | |
|
283 | raise ArgumentError if session.present? | |
|
284 | super method, path, parameters[:params], parameters[:session], parameters.except(:params, :session) | |
|
285 | 285 | else |
|
286 | 286 | super |
|
287 | 287 | end |
General Comments 0
You need to be logged in to leave comments.
Login now