The requested changes are too big and content was truncated. Show full diff
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,488 +1,482 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class UsersControllerTest < ActionController::TestCase |
|
21 | 21 | include Redmine::I18n |
|
22 | 22 | |
|
23 | 23 | fixtures :users, :projects, :members, :member_roles, :roles, |
|
24 | 24 | :custom_fields, :custom_values, :groups_users, |
|
25 | 25 | :auth_sources |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | User.current = nil |
|
29 | 29 | @request.session[:user_id] = 1 # admin |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | def test_index |
|
33 | 33 | get :index |
|
34 | 34 | assert_response :success |
|
35 | 35 | assert_template 'index' |
|
36 | end | |
|
37 | ||
|
38 | def test_index | |
|
39 | get :index | |
|
40 | assert_response :success | |
|
41 | assert_template 'index' | |
|
42 | 36 | assert_not_nil assigns(:users) |
|
43 | 37 | # active users only |
|
44 | 38 | assert_nil assigns(:users).detect {|u| !u.active?} |
|
45 | 39 | end |
|
46 | 40 | |
|
47 | 41 | def test_index_with_status_filter |
|
48 | 42 | get :index, :status => 3 |
|
49 | 43 | assert_response :success |
|
50 | 44 | assert_template 'index' |
|
51 | 45 | assert_not_nil assigns(:users) |
|
52 | 46 | assert_equal [3], assigns(:users).map(&:status).uniq |
|
53 | 47 | end |
|
54 | 48 | |
|
55 | 49 | def test_index_with_name_filter |
|
56 | 50 | get :index, :name => 'john' |
|
57 | 51 | assert_response :success |
|
58 | 52 | assert_template 'index' |
|
59 | 53 | users = assigns(:users) |
|
60 | 54 | assert_not_nil users |
|
61 | 55 | assert_equal 1, users.size |
|
62 | 56 | assert_equal 'John', users.first.firstname |
|
63 | 57 | end |
|
64 | 58 | |
|
65 | 59 | def test_index_with_group_filter |
|
66 | 60 | get :index, :group_id => '10' |
|
67 | 61 | assert_response :success |
|
68 | 62 | assert_template 'index' |
|
69 | 63 | users = assigns(:users) |
|
70 | 64 | assert users.any? |
|
71 | 65 | assert_equal([], (users - Group.find(10).users)) |
|
72 | 66 | assert_select 'select[name=group_id]' do |
|
73 | 67 | assert_select 'option[value=10][selected=selected]' |
|
74 | 68 | end |
|
75 | 69 | end |
|
76 | 70 | |
|
77 | 71 | def test_show |
|
78 | 72 | @request.session[:user_id] = nil |
|
79 | 73 | get :show, :id => 2 |
|
80 | 74 | assert_response :success |
|
81 | 75 | assert_template 'show' |
|
82 | 76 | assert_not_nil assigns(:user) |
|
83 | 77 | |
|
84 | 78 | assert_tag 'li', :content => /Phone number/ |
|
85 | 79 | end |
|
86 | 80 | |
|
87 | 81 | def test_show_should_not_display_hidden_custom_fields |
|
88 | 82 | @request.session[:user_id] = nil |
|
89 | 83 | UserCustomField.find_by_name('Phone number').update_attribute :visible, false |
|
90 | 84 | get :show, :id => 2 |
|
91 | 85 | assert_response :success |
|
92 | 86 | assert_template 'show' |
|
93 | 87 | assert_not_nil assigns(:user) |
|
94 | 88 | |
|
95 | 89 | assert_no_tag 'li', :content => /Phone number/ |
|
96 | 90 | end |
|
97 | 91 | |
|
98 | 92 | def test_show_should_not_fail_when_custom_values_are_nil |
|
99 | 93 | user = User.find(2) |
|
100 | 94 | |
|
101 | 95 | # Create a custom field to illustrate the issue |
|
102 | 96 | custom_field = CustomField.create!(:name => 'Testing', :field_format => 'text') |
|
103 | 97 | custom_value = user.custom_values.build(:custom_field => custom_field).save! |
|
104 | 98 | |
|
105 | 99 | get :show, :id => 2 |
|
106 | 100 | assert_response :success |
|
107 | 101 | end |
|
108 | 102 | |
|
109 | 103 | def test_show_inactive |
|
110 | 104 | @request.session[:user_id] = nil |
|
111 | 105 | get :show, :id => 5 |
|
112 | 106 | assert_response 404 |
|
113 | 107 | end |
|
114 | 108 | |
|
115 | 109 | def test_show_should_not_reveal_users_with_no_visible_activity_or_project |
|
116 | 110 | @request.session[:user_id] = nil |
|
117 | 111 | get :show, :id => 9 |
|
118 | 112 | assert_response 404 |
|
119 | 113 | end |
|
120 | 114 | |
|
121 | 115 | def test_show_inactive_by_admin |
|
122 | 116 | @request.session[:user_id] = 1 |
|
123 | 117 | get :show, :id => 5 |
|
124 | 118 | assert_response 200 |
|
125 | 119 | assert_not_nil assigns(:user) |
|
126 | 120 | end |
|
127 | 121 | |
|
128 | 122 | def test_show_displays_memberships_based_on_project_visibility |
|
129 | 123 | @request.session[:user_id] = 1 |
|
130 | 124 | get :show, :id => 2 |
|
131 | 125 | assert_response :success |
|
132 | 126 | memberships = assigns(:memberships) |
|
133 | 127 | assert_not_nil memberships |
|
134 | 128 | project_ids = memberships.map(&:project_id) |
|
135 | 129 | assert project_ids.include?(2) #private project admin can see |
|
136 | 130 | end |
|
137 | 131 | |
|
138 | 132 | def test_show_current_should_require_authentication |
|
139 | 133 | @request.session[:user_id] = nil |
|
140 | 134 | get :show, :id => 'current' |
|
141 | 135 | assert_response 302 |
|
142 | 136 | end |
|
143 | 137 | |
|
144 | 138 | def test_show_current |
|
145 | 139 | @request.session[:user_id] = 2 |
|
146 | 140 | get :show, :id => 'current' |
|
147 | 141 | assert_response :success |
|
148 | 142 | assert_template 'show' |
|
149 | 143 | assert_equal User.find(2), assigns(:user) |
|
150 | 144 | end |
|
151 | 145 | |
|
152 | 146 | def test_new |
|
153 | 147 | get :new |
|
154 | 148 | assert_response :success |
|
155 | 149 | assert_template :new |
|
156 | 150 | assert assigns(:user) |
|
157 | 151 | end |
|
158 | 152 | |
|
159 | 153 | def test_create |
|
160 | 154 | Setting.bcc_recipients = '1' |
|
161 | 155 | |
|
162 | 156 | assert_difference 'User.count' do |
|
163 | 157 | assert_difference 'ActionMailer::Base.deliveries.size' do |
|
164 | 158 | post :create, |
|
165 | 159 | :user => { |
|
166 | 160 | :firstname => 'John', |
|
167 | 161 | :lastname => 'Doe', |
|
168 | 162 | :login => 'jdoe', |
|
169 | 163 | :password => 'secret123', |
|
170 | 164 | :password_confirmation => 'secret123', |
|
171 | 165 | :mail => 'jdoe@gmail.com', |
|
172 | 166 | :mail_notification => 'none' |
|
173 | 167 | }, |
|
174 | 168 | :send_information => '1' |
|
175 | 169 | end |
|
176 | 170 | end |
|
177 | 171 | |
|
178 | 172 | user = User.first(:order => 'id DESC') |
|
179 | 173 | assert_redirected_to :controller => 'users', :action => 'edit', :id => user.id |
|
180 | 174 | |
|
181 | 175 | assert_equal 'John', user.firstname |
|
182 | 176 | assert_equal 'Doe', user.lastname |
|
183 | 177 | assert_equal 'jdoe', user.login |
|
184 | 178 | assert_equal 'jdoe@gmail.com', user.mail |
|
185 | 179 | assert_equal 'none', user.mail_notification |
|
186 | 180 | assert user.check_password?('secret123') |
|
187 | 181 | |
|
188 | 182 | mail = ActionMailer::Base.deliveries.last |
|
189 | 183 | assert_not_nil mail |
|
190 | 184 | assert_equal [user.mail], mail.bcc |
|
191 | 185 | assert_mail_body_match 'secret', mail |
|
192 | 186 | end |
|
193 | 187 | |
|
194 | 188 | def test_create_with_preferences |
|
195 | 189 | assert_difference 'User.count' do |
|
196 | 190 | post :create, |
|
197 | 191 | :user => { |
|
198 | 192 | :firstname => 'John', |
|
199 | 193 | :lastname => 'Doe', |
|
200 | 194 | :login => 'jdoe', |
|
201 | 195 | :password => 'secret123', |
|
202 | 196 | :password_confirmation => 'secret123', |
|
203 | 197 | :mail => 'jdoe@gmail.com', |
|
204 | 198 | :mail_notification => 'none' |
|
205 | 199 | }, |
|
206 | 200 | :pref => { |
|
207 | 201 | 'hide_mail' => '1', |
|
208 | 202 | 'time_zone' => 'Paris', |
|
209 | 203 | 'comments_sorting' => 'desc', |
|
210 | 204 | 'warn_on_leaving_unsaved' => '0' |
|
211 | 205 | } |
|
212 | 206 | end |
|
213 | 207 | user = User.first(:order => 'id DESC') |
|
214 | 208 | assert_equal 'jdoe', user.login |
|
215 | 209 | assert_equal true, user.pref.hide_mail |
|
216 | 210 | assert_equal 'Paris', user.pref.time_zone |
|
217 | 211 | assert_equal 'desc', user.pref[:comments_sorting] |
|
218 | 212 | assert_equal '0', user.pref[:warn_on_leaving_unsaved] |
|
219 | 213 | end |
|
220 | 214 | |
|
221 | 215 | def test_create_with_generate_password_should_email_the_password |
|
222 | 216 | assert_difference 'User.count' do |
|
223 | 217 | post :create, :user => { |
|
224 | 218 | :login => 'randompass', |
|
225 | 219 | :firstname => 'Random', |
|
226 | 220 | :lastname => 'Pass', |
|
227 | 221 | :mail => 'randompass@example.net', |
|
228 | 222 | :language => 'en', |
|
229 | 223 | :generate_password => '1', |
|
230 | 224 | :password => '', |
|
231 | 225 | :password_confirmation => '' |
|
232 | 226 | }, :send_information => 1 |
|
233 | 227 | end |
|
234 | 228 | user = User.order('id DESC').first |
|
235 | 229 | assert_equal 'randompass', user.login |
|
236 | 230 | |
|
237 | 231 | mail = ActionMailer::Base.deliveries.last |
|
238 | 232 | assert_not_nil mail |
|
239 | 233 | m = mail_body(mail).match(/Password: ([a-zA-Z0-9]+)/) |
|
240 | 234 | assert m |
|
241 | 235 | password = m[1] |
|
242 | 236 | assert user.check_password?(password) |
|
243 | 237 | end |
|
244 | 238 | |
|
245 | 239 | def test_create_with_failure |
|
246 | 240 | assert_no_difference 'User.count' do |
|
247 | 241 | post :create, :user => {} |
|
248 | 242 | end |
|
249 | 243 | assert_response :success |
|
250 | 244 | assert_template 'new' |
|
251 | 245 | end |
|
252 | 246 | |
|
253 | 247 | def test_edit |
|
254 | 248 | get :edit, :id => 2 |
|
255 | 249 | assert_response :success |
|
256 | 250 | assert_template 'edit' |
|
257 | 251 | assert_equal User.find(2), assigns(:user) |
|
258 | 252 | end |
|
259 | 253 | |
|
260 | 254 | def test_update |
|
261 | 255 | ActionMailer::Base.deliveries.clear |
|
262 | 256 | put :update, :id => 2, |
|
263 | 257 | :user => {:firstname => 'Changed', :mail_notification => 'only_assigned'}, |
|
264 | 258 | :pref => {:hide_mail => '1', :comments_sorting => 'desc'} |
|
265 | 259 | user = User.find(2) |
|
266 | 260 | assert_equal 'Changed', user.firstname |
|
267 | 261 | assert_equal 'only_assigned', user.mail_notification |
|
268 | 262 | assert_equal true, user.pref[:hide_mail] |
|
269 | 263 | assert_equal 'desc', user.pref[:comments_sorting] |
|
270 | 264 | assert ActionMailer::Base.deliveries.empty? |
|
271 | 265 | end |
|
272 | 266 | |
|
273 | 267 | def test_update_with_failure |
|
274 | 268 | assert_no_difference 'User.count' do |
|
275 | 269 | put :update, :id => 2, :user => {:firstname => ''} |
|
276 | 270 | end |
|
277 | 271 | assert_response :success |
|
278 | 272 | assert_template 'edit' |
|
279 | 273 | end |
|
280 | 274 | |
|
281 | 275 | def test_update_with_group_ids_should_assign_groups |
|
282 | 276 | put :update, :id => 2, :user => {:group_ids => ['10']} |
|
283 | 277 | user = User.find(2) |
|
284 | 278 | assert_equal [10], user.group_ids |
|
285 | 279 | end |
|
286 | 280 | |
|
287 | 281 | def test_update_with_activation_should_send_a_notification |
|
288 | 282 | u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr') |
|
289 | 283 | u.login = 'foo' |
|
290 | 284 | u.status = User::STATUS_REGISTERED |
|
291 | 285 | u.save! |
|
292 | 286 | ActionMailer::Base.deliveries.clear |
|
293 | 287 | Setting.bcc_recipients = '1' |
|
294 | 288 | |
|
295 | 289 | put :update, :id => u.id, :user => {:status => User::STATUS_ACTIVE} |
|
296 | 290 | assert u.reload.active? |
|
297 | 291 | mail = ActionMailer::Base.deliveries.last |
|
298 | 292 | assert_not_nil mail |
|
299 | 293 | assert_equal ['foo.bar@somenet.foo'], mail.bcc |
|
300 | 294 | assert_mail_body_match ll('fr', :notice_account_activated), mail |
|
301 | 295 | end |
|
302 | 296 | |
|
303 | 297 | def test_update_with_password_change_should_send_a_notification |
|
304 | 298 | ActionMailer::Base.deliveries.clear |
|
305 | 299 | Setting.bcc_recipients = '1' |
|
306 | 300 | |
|
307 | 301 | put :update, :id => 2, :user => {:password => 'newpass123', :password_confirmation => 'newpass123'}, :send_information => '1' |
|
308 | 302 | u = User.find(2) |
|
309 | 303 | assert u.check_password?('newpass123') |
|
310 | 304 | |
|
311 | 305 | mail = ActionMailer::Base.deliveries.last |
|
312 | 306 | assert_not_nil mail |
|
313 | 307 | assert_equal [u.mail], mail.bcc |
|
314 | 308 | assert_mail_body_match 'newpass123', mail |
|
315 | 309 | end |
|
316 | 310 | |
|
317 | 311 | def test_update_with_generate_password_should_email_the_password |
|
318 | 312 | ActionMailer::Base.deliveries.clear |
|
319 | 313 | Setting.bcc_recipients = '1' |
|
320 | 314 | |
|
321 | 315 | put :update, :id => 2, :user => { |
|
322 | 316 | :generate_password => '1', |
|
323 | 317 | :password => '', |
|
324 | 318 | :password_confirmation => '' |
|
325 | 319 | }, :send_information => '1' |
|
326 | 320 | |
|
327 | 321 | mail = ActionMailer::Base.deliveries.last |
|
328 | 322 | assert_not_nil mail |
|
329 | 323 | m = mail_body(mail).match(/Password: ([a-zA-Z0-9]+)/) |
|
330 | 324 | assert m |
|
331 | 325 | password = m[1] |
|
332 | 326 | assert User.find(2).check_password?(password) |
|
333 | 327 | end |
|
334 | 328 | |
|
335 | 329 | def test_update_without_generate_password_should_not_change_password |
|
336 | 330 | put :update, :id => 2, :user => { |
|
337 | 331 | :firstname => 'changed', |
|
338 | 332 | :generate_password => '0', |
|
339 | 333 | :password => '', |
|
340 | 334 | :password_confirmation => '' |
|
341 | 335 | }, :send_information => '1' |
|
342 | 336 | |
|
343 | 337 | user = User.find(2) |
|
344 | 338 | assert_equal 'changed', user.firstname |
|
345 | 339 | assert user.check_password?('jsmith') |
|
346 | 340 | end |
|
347 | 341 | |
|
348 | 342 | def test_update_user_switchin_from_auth_source_to_password_authentication |
|
349 | 343 | # Configure as auth source |
|
350 | 344 | u = User.find(2) |
|
351 | 345 | u.auth_source = AuthSource.find(1) |
|
352 | 346 | u.save! |
|
353 | 347 | |
|
354 | 348 | put :update, :id => u.id, :user => {:auth_source_id => '', :password => 'newpass123', :password_confirmation => 'newpass123'} |
|
355 | 349 | |
|
356 | 350 | assert_equal nil, u.reload.auth_source |
|
357 | 351 | assert u.check_password?('newpass123') |
|
358 | 352 | end |
|
359 | 353 | |
|
360 | 354 | def test_update_notified_project |
|
361 | 355 | get :edit, :id => 2 |
|
362 | 356 | assert_response :success |
|
363 | 357 | assert_template 'edit' |
|
364 | 358 | u = User.find(2) |
|
365 | 359 | assert_equal [1, 2, 5], u.projects.collect{|p| p.id}.sort |
|
366 | 360 | assert_equal [1, 2, 5], u.notified_projects_ids.sort |
|
367 | 361 | assert_select 'input[name=?][value=?]', 'user[notified_project_ids][]', '1' |
|
368 | 362 | assert_equal 'all', u.mail_notification |
|
369 | 363 | put :update, :id => 2, |
|
370 | 364 | :user => { |
|
371 | 365 | :mail_notification => 'selected', |
|
372 | 366 | :notified_project_ids => [1, 2] |
|
373 | 367 | } |
|
374 | 368 | u = User.find(2) |
|
375 | 369 | assert_equal 'selected', u.mail_notification |
|
376 | 370 | assert_equal [1, 2], u.notified_projects_ids.sort |
|
377 | 371 | end |
|
378 | 372 | |
|
379 | 373 | def test_update_status_should_not_update_attributes |
|
380 | 374 | user = User.find(2) |
|
381 | 375 | user.pref[:no_self_notified] = '1' |
|
382 | 376 | user.pref.save |
|
383 | 377 | |
|
384 | 378 | put :update, :id => 2, :user => {:status => 3} |
|
385 | 379 | assert_response 302 |
|
386 | 380 | user = User.find(2) |
|
387 | 381 | assert_equal 3, user.status |
|
388 | 382 | assert_equal '1', user.pref[:no_self_notified] |
|
389 | 383 | end |
|
390 | 384 | |
|
391 | 385 | def test_destroy |
|
392 | 386 | assert_difference 'User.count', -1 do |
|
393 | 387 | delete :destroy, :id => 2 |
|
394 | 388 | end |
|
395 | 389 | assert_redirected_to '/users' |
|
396 | 390 | assert_nil User.find_by_id(2) |
|
397 | 391 | end |
|
398 | 392 | |
|
399 | 393 | def test_destroy_should_be_denied_for_non_admin_users |
|
400 | 394 | @request.session[:user_id] = 3 |
|
401 | 395 | |
|
402 | 396 | assert_no_difference 'User.count' do |
|
403 | 397 | get :destroy, :id => 2 |
|
404 | 398 | end |
|
405 | 399 | assert_response 403 |
|
406 | 400 | end |
|
407 | 401 | |
|
408 | 402 | def test_destroy_should_redirect_to_back_url_param |
|
409 | 403 | assert_difference 'User.count', -1 do |
|
410 | 404 | delete :destroy, :id => 2, :back_url => '/users?name=foo' |
|
411 | 405 | end |
|
412 | 406 | assert_redirected_to '/users?name=foo' |
|
413 | 407 | end |
|
414 | 408 | |
|
415 | 409 | def test_create_membership |
|
416 | 410 | assert_difference 'Member.count' do |
|
417 | 411 | post :edit_membership, :id => 7, :membership => { :project_id => 3, :role_ids => [2]} |
|
418 | 412 | end |
|
419 | 413 | assert_redirected_to :action => 'edit', :id => '7', :tab => 'memberships' |
|
420 | 414 | member = Member.first(:order => 'id DESC') |
|
421 | 415 | assert_equal User.find(7), member.principal |
|
422 | 416 | assert_equal [2], member.role_ids |
|
423 | 417 | assert_equal 3, member.project_id |
|
424 | 418 | end |
|
425 | 419 | |
|
426 | 420 | def test_create_membership_js_format |
|
427 | 421 | assert_difference 'Member.count' do |
|
428 | 422 | post :edit_membership, :id => 7, :membership => {:project_id => 3, :role_ids => [2]}, :format => 'js' |
|
429 | 423 | assert_response :success |
|
430 | 424 | assert_template 'edit_membership' |
|
431 | 425 | assert_equal 'text/javascript', response.content_type |
|
432 | 426 | end |
|
433 | 427 | member = Member.first(:order => 'id DESC') |
|
434 | 428 | assert_equal User.find(7), member.principal |
|
435 | 429 | assert_equal [2], member.role_ids |
|
436 | 430 | assert_equal 3, member.project_id |
|
437 | 431 | assert_include 'tab-content-memberships', response.body |
|
438 | 432 | end |
|
439 | 433 | |
|
440 | 434 | def test_create_membership_js_format_with_failure |
|
441 | 435 | assert_no_difference 'Member.count' do |
|
442 | 436 | post :edit_membership, :id => 7, :membership => {:project_id => 3}, :format => 'js' |
|
443 | 437 | assert_response :success |
|
444 | 438 | assert_template 'edit_membership' |
|
445 | 439 | assert_equal 'text/javascript', response.content_type |
|
446 | 440 | end |
|
447 | 441 | assert_include 'alert', response.body, "Alert message not sent" |
|
448 | 442 | assert_include 'Role can\\\'t be empty', response.body, "Error message not sent" |
|
449 | 443 | end |
|
450 | 444 | |
|
451 | 445 | def test_update_membership |
|
452 | 446 | assert_no_difference 'Member.count' do |
|
453 | 447 | put :edit_membership, :id => 2, :membership_id => 1, :membership => { :role_ids => [2]} |
|
454 | 448 | assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships' |
|
455 | 449 | end |
|
456 | 450 | assert_equal [2], Member.find(1).role_ids |
|
457 | 451 | end |
|
458 | 452 | |
|
459 | 453 | def test_update_membership_js_format |
|
460 | 454 | assert_no_difference 'Member.count' do |
|
461 | 455 | put :edit_membership, :id => 2, :membership_id => 1, :membership => {:role_ids => [2]}, :format => 'js' |
|
462 | 456 | assert_response :success |
|
463 | 457 | assert_template 'edit_membership' |
|
464 | 458 | assert_equal 'text/javascript', response.content_type |
|
465 | 459 | end |
|
466 | 460 | assert_equal [2], Member.find(1).role_ids |
|
467 | 461 | assert_include 'tab-content-memberships', response.body |
|
468 | 462 | end |
|
469 | 463 | |
|
470 | 464 | def test_destroy_membership |
|
471 | 465 | assert_difference 'Member.count', -1 do |
|
472 | 466 | delete :destroy_membership, :id => 2, :membership_id => 1 |
|
473 | 467 | end |
|
474 | 468 | assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships' |
|
475 | 469 | assert_nil Member.find_by_id(1) |
|
476 | 470 | end |
|
477 | 471 | |
|
478 | 472 | def test_destroy_membership_js_format |
|
479 | 473 | assert_difference 'Member.count', -1 do |
|
480 | 474 | delete :destroy_membership, :id => 2, :membership_id => 1, :format => 'js' |
|
481 | 475 | assert_response :success |
|
482 | 476 | assert_template 'destroy_membership' |
|
483 | 477 | assert_equal 'text/javascript', response.content_type |
|
484 | 478 | end |
|
485 | 479 | assert_nil Member.find_by_id(1) |
|
486 | 480 | assert_include 'tab-content-memberships', response.body |
|
487 | 481 | end |
|
488 | 482 | end |
General Comments 0
You need to be logged in to leave comments.
Login now