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