3 class UsersControllerTest < ActionDispatch::IntegrationTest
5 # test all routes which lead to this controller
8 { :path => "/login", :method => :get },
9 { :controller => "users", :action => "login" }
12 { :path => "/login", :method => :post },
13 { :controller => "users", :action => "login" }
16 { :controller => "users", :action => "login", :format => "html" },
17 { :path => "/login.html", :method => :get }
21 { :path => "/logout", :method => :get },
22 { :controller => "users", :action => "logout" }
25 { :path => "/logout", :method => :post },
26 { :controller => "users", :action => "logout" }
29 { :controller => "users", :action => "logout", :format => "html" },
30 { :path => "/logout.html", :method => :get }
34 { :path => "/user/new", :method => :get },
35 { :controller => "users", :action => "new" }
39 { :path => "/user/new", :method => :post },
40 { :controller => "users", :action => "create" }
44 { :path => "/user/terms", :method => :get },
45 { :controller => "users", :action => "terms" }
49 { :path => "/user/save", :method => :post },
50 { :controller => "users", :action => "save" }
54 { :path => "/user/username/confirm", :method => :get },
55 { :controller => "users", :action => "confirm", :display_name => "username" }
58 { :path => "/user/username/confirm", :method => :post },
59 { :controller => "users", :action => "confirm", :display_name => "username" }
62 { :path => "/user/username/confirm/resend", :method => :get },
63 { :controller => "users", :action => "confirm_resend", :display_name => "username" }
67 { :path => "/user/confirm", :method => :get },
68 { :controller => "users", :action => "confirm" }
71 { :path => "/user/confirm", :method => :post },
72 { :controller => "users", :action => "confirm" }
75 { :path => "/user/confirm-email", :method => :get },
76 { :controller => "users", :action => "confirm_email" }
79 { :path => "/user/confirm-email", :method => :post },
80 { :controller => "users", :action => "confirm_email" }
84 { :path => "/user/go_public", :method => :post },
85 { :controller => "users", :action => "go_public" }
89 { :path => "/user/forgot-password", :method => :get },
90 { :controller => "users", :action => "lost_password" }
93 { :path => "/user/forgot-password", :method => :post },
94 { :controller => "users", :action => "lost_password" }
97 { :path => "/user/reset-password", :method => :get },
98 { :controller => "users", :action => "reset_password" }
101 { :path => "/user/reset-password", :method => :post },
102 { :controller => "users", :action => "reset_password" }
106 { :path => "/user/suspended", :method => :get },
107 { :controller => "users", :action => "suspended" }
111 { :path => "/user/username", :method => :get },
112 { :controller => "users", :action => "show", :display_name => "username" }
116 { :path => "/user/username/account", :method => :get },
117 { :controller => "users", :action => "account", :display_name => "username" }
120 { :path => "/user/username/account", :method => :post },
121 { :controller => "users", :action => "account", :display_name => "username" }
125 { :path => "/user/username/set_status", :method => :post },
126 { :controller => "users", :action => "set_status", :display_name => "username" }
129 { :path => "/user/username", :method => :delete },
130 { :controller => "users", :action => "destroy", :display_name => "username" }
134 { :path => "/users", :method => :get },
135 { :controller => "users", :action => "index" }
138 { :path => "/users", :method => :post },
139 { :controller => "users", :action => "index" }
142 { :path => "/users/status", :method => :get },
143 { :controller => "users", :action => "index", :status => "status" }
146 { :path => "/users/status", :method => :post },
147 { :controller => "users", :action => "index", :status => "status" }
151 # The user creation page loads
154 assert_response :redirect
155 assert_redirected_to user_new_path(:cookie_test => "true")
157 get user_new_path, :params => { :cookie_test => "true" }
158 assert_response :success
160 assert_select "html", :count => 1 do
161 assert_select "head", :count => 1 do
162 assert_select "title", :text => /Sign Up/, :count => 1
164 assert_select "body", :count => 1 do
165 assert_select "div#content", :count => 1 do
166 assert_select "form[action='/user/new'][method='post']", :count => 1 do
167 assert_select "input[id='user_email']", :count => 1
168 assert_select "input[id='user_email_confirmation']", :count => 1
169 assert_select "input[id='user_display_name']", :count => 1
170 assert_select "input[id='user_pass_crypt'][type='password']", :count => 1
171 assert_select "input[id='user_pass_crypt_confirmation'][type='password']", :count => 1
172 assert_select "input[type='submit'][value='Sign Up']", :count => 1
179 def test_new_view_logged_in
180 session_for(create(:user))
183 assert_response :redirect
184 assert_redirected_to root_path
186 get user_new_path, :params => { :referer => "/test" }
187 assert_response :redirect
188 assert_redirected_to "/test"
192 user = build(:user, :pending)
194 assert_no_difference "User.count" do
195 assert_no_difference "ActionMailer::Base.deliveries.size" do
196 perform_enqueued_jobs do
197 post user_new_path, :params => { :user => user.attributes }
202 assert_difference "User.count", 1 do
203 assert_difference "ActionMailer::Base.deliveries.size", 1 do
204 perform_enqueued_jobs do
205 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
211 register_email = ActionMailer::Base.deliveries.first
213 assert_equal register_email.to[0], user.email
214 assert_match(/#{@url}/, register_email.body.to_s)
217 assert_redirected_to :action => "confirm", :display_name => user.display_name
219 ActionMailer::Base.deliveries.clear
222 def test_new_duplicate_email
223 user = build(:user, :pending)
224 create(:user, :email => user.email)
226 assert_no_difference "User.count" do
227 assert_no_difference "ActionMailer::Base.deliveries.size" do
228 perform_enqueued_jobs do
229 post user_new_path, :params => { :user => user.attributes }
234 assert_response :success
235 assert_template "new"
236 assert_select "form > div.form-group > input.is-invalid#user_email"
239 def test_save_duplicate_email
240 user = build(:user, :pending)
242 # Set up our user as being half-way through registration
243 assert_no_difference "User.count" do
244 assert_no_difference "ActionMailer::Base.deliveries.size" do
245 perform_enqueued_jobs do
246 post user_new_path, :params => { :user => user.attributes }
251 # Now create another user with that email
252 create(:user, :email => user.email)
254 # Check that the second half of registration fails
255 assert_no_difference "User.count" do
256 assert_no_difference "ActionMailer::Base.deliveries.size" do
257 perform_enqueued_jobs do
258 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
263 assert_response :success
264 assert_template "new"
265 assert_select "form > div.form-group > input.is-invalid#user_email"
268 def test_save_duplicate_email_uppercase
269 user = build(:user, :pending)
271 # Set up our user as being half-way through registration
272 assert_no_difference "User.count" do
273 assert_no_difference "ActionMailer::Base.deliveries.size" do
274 perform_enqueued_jobs do
275 post user_new_path, :params => { :user => user.attributes }
280 # Now create another user with that email, but uppercased
281 create(:user, :email => user.email.upcase)
283 # Check that the second half of registration fails
284 assert_no_difference "User.count" do
285 assert_no_difference "ActionMailer::Base.deliveries.size" do
286 perform_enqueued_jobs do
287 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
292 assert_response :success
293 assert_template "new"
294 assert_select "form > div.form-group > input.is-invalid#user_email"
297 def test_save_duplicate_name
298 user = build(:user, :pending)
300 # Set up our user as being half-way through registration
301 assert_no_difference "User.count" do
302 assert_no_difference "ActionMailer::Base.deliveries.size" do
303 perform_enqueued_jobs do
304 post user_new_path, :params => { :user => user.attributes }
309 # Now create another user with that display name
310 create(:user, :display_name => user.display_name)
312 # Check that the second half of registration fails
313 assert_no_difference "User.count" do
314 assert_no_difference "ActionMailer::Base.deliveries.size" do
315 perform_enqueued_jobs do
316 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
321 assert_response :success
322 assert_template "new"
323 assert_select "form > div.form-group > input.is-invalid#user_display_name"
326 def test_save_duplicate_name_uppercase
327 user = build(:user, :pending)
329 # Set up our user as being half-way through registration
330 assert_no_difference "User.count" do
331 assert_no_difference "ActionMailer::Base.deliveries.size" do
332 perform_enqueued_jobs do
333 post user_new_path, :params => { :user => user.attributes }
338 # Now create another user with that display_name, but uppercased
339 create(:user, :display_name => user.display_name.upcase)
341 # Check that the second half of registration fails
342 assert_no_difference "User.count" do
343 assert_no_difference "ActionMailer::Base.deliveries.size" do
344 perform_enqueued_jobs do
345 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
350 assert_response :success
351 assert_template "new"
352 assert_select "form > div.form-group > input.is-invalid#user_display_name"
355 def test_save_blocked_domain
356 user = build(:user, :pending, :email => "user@example.net")
358 # Set up our user as being half-way through registration
359 assert_no_difference "User.count" do
360 assert_no_difference "ActionMailer::Base.deliveries.size" do
361 perform_enqueued_jobs do
362 post user_new_path, :params => { :user => user.attributes }
367 # Now block that domain
368 create(:acl, :domain => "example.net", :k => "no_account_creation")
370 # Check that the second half of registration fails
371 assert_no_difference "User.count" do
372 assert_no_difference "ActionMailer::Base.deliveries.size" do
373 perform_enqueued_jobs do
374 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
379 assert_response :success
380 assert_template "blocked"
383 def test_save_referer_params
384 user = build(:user, :pending)
386 # Set up our user as being half-way through registration
387 assert_no_difference "User.count" do
388 assert_no_difference "ActionMailer::Base.deliveries.size" do
389 perform_enqueued_jobs do
390 post user_new_path, :params => { :user => user.attributes, :referer => "/edit?editor=id#map=1/2/3" }
395 assert_difference "User.count", 1 do
396 assert_difference "ActionMailer::Base.deliveries.size", 1 do
397 perform_enqueued_jobs do
398 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
403 assert_equal welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3),
404 User.find_by(:email => user.email).tokens.order("id DESC").first.referer
406 ActionMailer::Base.deliveries.clear
409 def test_logout_without_referer
411 assert_response :redirect
412 assert_redirected_to root_path
415 def test_logout_with_referer
416 post logout_path, :params => { :referer => "/test" }
417 assert_response :redirect
418 assert_redirected_to "/test"
421 def test_logout_fallback_without_referer
423 assert_response :success
424 assert_template :logout
425 assert_select "input[name=referer]:not([value])"
428 def test_logout_fallback_with_referer
429 get logout_path, :params => { :referer => "/test" }
430 assert_response :success
431 assert_template :logout
432 assert_select "input[name=referer][value=?]", "/test"
435 def test_logout_removes_session_token
436 user = build(:user, :pending)
437 post user_new_path, :params => { :user => user.attributes }
438 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
440 assert_difference "User.find_by(:email => user.email).tokens.count", -1 do
443 assert_response :redirect
444 assert_redirected_to root_path
448 user = build(:user, :pending)
449 post user_new_path, :params => { :user => user.attributes }
450 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
451 confirm_string = User.find_by(:email => user.email).tokens.create.token
453 get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
454 assert_response :success
455 assert_template :confirm
458 def test_confirm_get_already_confirmed
459 user = build(:user, :pending)
460 stub_gravatar_request(user.email)
461 post user_new_path, :params => { :user => user.attributes }
462 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
463 confirm_string = User.find_by(:email => user.email).tokens.create.token
465 # Get the confirmation page
466 get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
467 assert_response :success
468 assert_template :confirm
471 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
472 assert_redirected_to welcome_path
474 # Now try to get the confirmation page again
475 get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
476 assert_response :redirect
477 assert_redirected_to root_path
480 def test_confirm_success_no_token_no_referer
481 user = build(:user, :pending)
482 stub_gravatar_request(user.email)
483 post user_new_path, :params => { :user => user.attributes }
484 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
485 confirm_string = User.find_by(:email => user.email).tokens.create.token
489 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
490 assert_redirected_to login_path
491 assert_match(/Confirmed your account/, flash[:notice])
494 def test_confirm_success_good_token_no_referer
495 user = build(:user, :pending)
496 stub_gravatar_request(user.email)
497 post user_new_path, :params => { :user => user.attributes }
498 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
499 confirm_string = User.find_by(:email => user.email).tokens.create.token
501 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
502 assert_redirected_to welcome_path
505 def test_confirm_success_bad_token_no_referer
506 user = build(:user, :pending)
507 stub_gravatar_request(user.email)
508 post user_new_path, :params => { :user => user.attributes }
509 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
510 confirm_string = User.find_by(:email => user.email).tokens.create.token
513 session_for(create(:user))
515 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
516 assert_redirected_to login_path
517 assert_match(/Confirmed your account/, flash[:notice])
520 def test_confirm_success_no_token_with_referer
521 user = build(:user, :pending)
522 stub_gravatar_request(user.email)
523 post user_new_path, :params => { :user => user.attributes }
524 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
525 confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
529 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
530 assert_redirected_to login_path(:referer => new_diary_entry_path)
531 assert_match(/Confirmed your account/, flash[:notice])
534 def test_confirm_success_good_token_with_referer
535 user = build(:user, :pending)
536 stub_gravatar_request(user.email)
537 post user_new_path, :params => { :user => user.attributes }
538 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
539 confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
541 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
542 assert_redirected_to new_diary_entry_path
545 def test_confirm_success_bad_token_with_referer
546 user = build(:user, :pending)
547 stub_gravatar_request(user.email)
548 post user_new_path, :params => { :user => user.attributes }
549 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
550 confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
553 session_for(create(:user))
555 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
556 assert_redirected_to login_path(:referer => new_diary_entry_path)
557 assert_match(/Confirmed your account/, flash[:notice])
560 def test_confirm_expired_token
561 user = build(:user, :pending)
562 stub_gravatar_request(user.email)
563 post user_new_path, :params => { :user => user.attributes }
564 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
565 confirm_string = User.find_by(:email => user.email).tokens.create(:expiry => 1.day.ago).token
567 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
568 assert_redirected_to :action => "confirm"
569 assert_match(/confirmation code has expired/, flash[:error])
572 def test_confirm_already_confirmed
573 user = build(:user, :pending)
574 stub_gravatar_request(user.email)
575 post user_new_path, :params => { :user => user.attributes }
576 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
577 confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
579 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
580 assert_redirected_to new_diary_entry_path
584 confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
585 post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
586 assert_redirected_to :action => "login"
587 assert_match(/already been confirmed/, flash[:error])
590 def test_confirm_resend_success
591 user = build(:user, :pending)
592 post user_new_path, :params => { :user => user.attributes }
593 post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
595 assert_difference "ActionMailer::Base.deliveries.size", 1 do
596 perform_enqueued_jobs do
597 get user_confirm_resend_path(user)
601 assert_response :redirect
602 assert_redirected_to login_path
603 assert_match(/sent a new confirmation/, flash[:notice])
605 email = ActionMailer::Base.deliveries.last
607 assert_equal user.email, email.to.first
609 ActionMailer::Base.deliveries.clear
612 def test_confirm_resend_no_token
613 user = build(:user, :pending)
614 # only complete first half of registration
615 post user_new_path, :params => { :user => user.attributes }
617 assert_no_difference "ActionMailer::Base.deliveries.size" do
618 perform_enqueued_jobs do
619 get user_confirm_resend_path(user)
623 assert_response :redirect
624 assert_redirected_to login_path
625 assert_match "User #{user.display_name} not found.", flash[:error]
628 def test_confirm_resend_unknown_user
629 assert_no_difference "ActionMailer::Base.deliveries.size" do
630 perform_enqueued_jobs do
631 get user_confirm_resend_path(:display_name => "No Such User")
635 assert_response :redirect
636 assert_redirected_to login_path
637 assert_match "User No Such User not found.", flash[:error]
640 def test_confirm_email_get
642 confirm_string = user.tokens.create.token
644 get user_confirm_email_path, :params => { :confirm_string => confirm_string }
645 assert_response :success
646 assert_template :confirm_email
649 def test_confirm_email_success
650 user = create(:user, :new_email => "test-new@example.com")
651 stub_gravatar_request(user.new_email)
652 confirm_string = user.tokens.create.token
654 post user_confirm_email_path, :params => { :confirm_string => confirm_string }
655 assert_response :redirect
656 assert_redirected_to :action => :account, :display_name => user.display_name
657 assert_match(/Confirmed your change of email address/, flash[:notice])
660 def test_confirm_email_already_confirmed
662 confirm_string = user.tokens.create.token
664 post user_confirm_email_path, :params => { :confirm_string => confirm_string }
665 assert_response :redirect
666 assert_redirected_to :action => :account, :display_name => user.display_name
667 assert_match(/already been confirmed/, flash[:error])
670 def test_confirm_email_bad_token
671 post user_confirm_email_path, :params => { :confirm_string => "XXXXX" }
672 assert_response :success
673 assert_template :confirm_email
674 assert_match(/confirmation code has expired or does not exist/, flash[:error])
678 # test if testing for a gravatar works
679 # this happens when the email is actually changed
680 # which is triggered by the confirmation mail
681 def test_gravatar_auto_enable
682 # switch to email that has a gravatar
683 user = create(:user, :new_email => "test-new@example.com")
684 stub_gravatar_request(user.new_email, 200)
685 confirm_string = user.tokens.create.token
686 # precondition gravatar should be turned off
687 assert_not user.image_use_gravatar
688 post user_confirm_email_path, :params => { :confirm_string => confirm_string }
689 assert_response :redirect
690 assert_redirected_to :action => :account, :display_name => user.display_name
691 assert_match(/Confirmed your change of email address/, flash[:notice])
692 # gravatar use should now be enabled
693 assert User.find(user.id).image_use_gravatar
696 def test_gravatar_auto_disable
697 # switch to email without a gravatar
698 user = create(:user, :new_email => "test-new@example.com", :image_use_gravatar => true)
699 stub_gravatar_request(user.new_email, 404)
700 confirm_string = user.tokens.create.token
701 # precondition gravatar should be turned on
702 assert user.image_use_gravatar
703 post user_confirm_email_path, :params => { :confirm_string => confirm_string }
704 assert_response :redirect
705 assert_redirected_to :action => :account, :display_name => user.display_name
706 assert_match(/Confirmed your change of email address/, flash[:notice])
707 # gravatar use should now be disabled
708 assert_not User.find(user.id).image_use_gravatar
711 def test_terms_new_user
712 user = build(:user, :pending)
714 # Set up our user as being half-way through registration
715 assert_no_difference "User.count" do
716 assert_no_difference "ActionMailer::Base.deliveries.size" do
717 perform_enqueued_jobs do
718 post user_new_path, :params => { :user => user.attributes }
725 assert_response :success
726 assert_template :terms
729 def test_terms_agreed
730 user = create(:user, :terms_seen => true, :terms_agreed => Date.yesterday)
735 assert_response :redirect
736 assert_redirected_to :action => :account, :display_name => user.display_name
739 def test_terms_not_seen_without_referer
740 user = create(:user, :terms_seen => false, :terms_agreed => nil)
745 assert_response :success
746 assert_template :terms
748 post user_save_path, :params => { :user => { :consider_pd => true }, :read_ct => 1, :read_tou => 1 }
749 assert_response :redirect
750 assert_redirected_to :action => :account, :display_name => user.display_name
751 assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
755 assert user.consider_pd
756 assert_not_nil user.terms_agreed
757 assert user.terms_seen
760 def test_terms_not_seen_with_referer
761 user = create(:user, :terms_seen => false, :terms_agreed => nil)
765 get user_terms_path, :params => { :referer => "/test" }
766 assert_response :success
767 assert_template :terms
769 post user_save_path, :params => { :user => { :consider_pd => true }, :referer => "/test", :read_ct => 1, :read_tou => 1 }
770 assert_response :redirect
771 assert_redirected_to "/test"
772 assert_equal "Thanks for accepting the new contributor terms!", flash[:notice]
776 assert user.consider_pd
777 assert_not_nil user.terms_agreed
778 assert user.terms_seen
781 # Check that if you haven't seen the terms, and make a request that requires authentication,
782 # that your request is redirected to view the terms
783 def test_terms_not_seen_redirection
784 user = create(:user, :terms_seen => false, :terms_agreed => nil)
787 get user_account_path(user)
788 assert_response :redirect
789 assert_redirected_to :action => :terms, :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
793 user = create(:user, :data_public => false)
796 post user_go_public_path
798 assert_response :redirect
799 assert_redirected_to :action => :account, :display_name => user.display_name
800 assert User.find(user.id).data_public
803 def test_lost_password
804 # Test fetching the lost password page
805 get user_forgot_password_path
806 assert_response :success
807 assert_template :lost_password
808 assert_select "div#notice", false
810 # Test resetting using the address as recorded for a user that has an
811 # address which is duplicated in a different case by another user
813 uppercase_user = build(:user, :email => user.email.upcase).tap { |u| u.save(:validate => false) }
815 assert_difference "ActionMailer::Base.deliveries.size", 1 do
816 perform_enqueued_jobs do
817 post user_forgot_password_path, :params => { :email => user.email }
820 assert_response :redirect
821 assert_redirected_to :action => :login
822 assert_match(/^Sorry you lost it/, flash[:notice])
823 email = ActionMailer::Base.deliveries.first
824 assert_equal 1, email.to.count
825 assert_equal user.email, email.to.first
826 ActionMailer::Base.deliveries.clear
828 # Test resetting using an address that matches a different user
829 # that has the same address in a different case
830 assert_difference "ActionMailer::Base.deliveries.size", 1 do
831 perform_enqueued_jobs do
832 post user_forgot_password_path, :params => { :email => user.email.upcase }
835 assert_response :redirect
836 assert_redirected_to :action => :login
837 assert_match(/^Sorry you lost it/, flash[:notice])
838 email = ActionMailer::Base.deliveries.first
839 assert_equal 1, email.to.count
840 assert_equal uppercase_user.email, email.to.first
841 ActionMailer::Base.deliveries.clear
843 # Test resetting using an address that is a case insensitive match
844 # for more than one user but not an exact match for either
845 assert_no_difference "ActionMailer::Base.deliveries.size" do
846 perform_enqueued_jobs do
847 post user_forgot_password_path, :params => { :email => user.email.titlecase }
850 assert_response :success
851 assert_template :lost_password
852 assert_select ".error", /^Could not find that email address/
854 # Test resetting using the address as recorded for a user that has an
855 # address which is case insensitively unique
856 third_user = create(:user)
857 assert_difference "ActionMailer::Base.deliveries.size", 1 do
858 perform_enqueued_jobs do
859 post user_forgot_password_path, :params => { :email => third_user.email }
862 assert_response :redirect
863 assert_redirected_to :action => :login
864 assert_match(/^Sorry you lost it/, flash[:notice])
865 email = ActionMailer::Base.deliveries.first
866 assert_equal 1, email.to.count
867 assert_equal third_user.email, email.to.first
868 ActionMailer::Base.deliveries.clear
870 # Test resetting using an address that matches a user that has the
871 # same (case insensitively unique) address in a different case
872 assert_difference "ActionMailer::Base.deliveries.size", 1 do
873 perform_enqueued_jobs do
874 post user_forgot_password_path, :params => { :email => third_user.email.upcase }
877 assert_response :redirect
878 assert_redirected_to :action => :login
879 assert_match(/^Sorry you lost it/, flash[:notice])
880 email = ActionMailer::Base.deliveries.first
881 assert_equal 1, email.to.count
882 assert_equal third_user.email, email.to.first
883 ActionMailer::Base.deliveries.clear
886 def test_reset_password
887 user = create(:user, :pending)
888 # Test a request with no token
889 get user_reset_password_path
890 assert_response :bad_request
892 # Test a request with a bogus token
893 get user_reset_password_path, :params => { :token => "made_up_token" }
894 assert_response :redirect
895 assert_redirected_to :action => :lost_password
897 # Create a valid token for a user
898 token = user.tokens.create
900 # Test a request with a valid token
901 get user_reset_password_path, :params => { :token => token.token }
902 assert_response :success
903 assert_template :reset_password
905 # Test that errors are reported for erroneous submissions
906 post user_reset_password_path, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "different_password" } }
907 assert_response :success
908 assert_template :reset_password
909 assert_select "div.invalid-feedback"
911 # Test setting a new password
912 post user_reset_password_path, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } }
913 assert_response :redirect
914 assert_redirected_to root_path
915 assert_equal user.id, session[:user]
917 assert_equal "active", user.status
918 assert user.email_valid
919 assert_equal user, User.authenticate(:username => user.email, :password => "new_password")
923 # Get a user to work with - note that this user deliberately
924 # conflicts with uppercase_user in the email and display name
925 # fields to test that we can change other fields without any
926 # validation errors being reported
927 user = create(:user, :languages => [])
928 _uppercase_user = build(:user, :email => user.email.upcase, :display_name => user.display_name.upcase).tap { |u| u.save(:validate => false) }
930 # Make sure that you are redirected to the login page when
931 # you are not logged in
932 get user_account_path(user)
933 assert_response :redirect
934 assert_redirected_to :action => "login", :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
936 # Make sure that you are blocked when not logged in as the right user
937 session_for(create(:user))
938 get user_account_path(user)
939 assert_response :forbidden
941 # Make sure we get the page when we are logged in as the right user
943 get user_account_path(user)
944 assert_response :success
945 assert_template :account
946 assert_select "form#accountForm" do |form|
947 assert_equal "post", form.attr("method").to_s
948 assert_select "input[name='_method']", false
949 assert_equal "/user/#{ERB::Util.u(user.display_name)}/account", form.attr("action").to_s
952 # Updating the description should work
953 user.description = "new description"
954 user.preferred_editor = "default"
955 post user_account_path(user), :params => { :user => user.attributes }
956 assert_response :redirect
957 assert_redirected_to user_account_url(user)
958 get user_account_path(user)
959 assert_response :success
960 assert_template :account
961 assert_select ".notice", /^User information updated successfully/
962 assert_select "form#accountForm > div.form-group > div#user_description_container > div#user_description_content > textarea#user_description", user.description
964 # Changing to a invalid editor should fail
965 user.preferred_editor = "unknown"
966 post user_account_path(user), :params => { :user => user.attributes }
967 assert_response :success
968 assert_template :account
969 assert_select ".notice", false
970 assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected]", false
972 # Changing to a valid editor should work
973 user.preferred_editor = "id"
974 post user_account_path(user), :params => { :user => user.attributes }
975 assert_response :redirect
976 assert_redirected_to user_account_url(user)
977 get user_account_path(user)
978 assert_response :success
979 assert_template :account
980 assert_select ".notice", /^User information updated successfully/
981 assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected][value=?]", "id"
983 # Changing to the default editor should work
984 user.preferred_editor = "default"
985 post user_account_path(user), :params => { :user => user.attributes }
986 assert_response :redirect
987 assert_redirected_to user_account_url(user)
988 get user_account_path(user)
989 assert_response :success
990 assert_template :account
991 assert_select ".notice", /^User information updated successfully/
992 assert_select "form#accountForm > div.form-group > select#user_preferred_editor > option[selected]", false
994 # Changing to an uploaded image should work
995 image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
996 post user_account_path(user), :params => { :avatar_action => "new", :user => user.attributes.merge(:avatar => image) }
997 assert_response :redirect
998 assert_redirected_to user_account_url(user)
999 get user_account_path(user)
1000 assert_response :success
1001 assert_template :account
1002 assert_select ".notice", /^User information updated successfully/
1003 assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
1005 # Changing to a gravatar image should work
1006 post user_account_path(user), :params => { :avatar_action => "gravatar", :user => user.attributes }
1007 assert_response :redirect
1008 assert_redirected_to user_account_url(user)
1009 get user_account_path(user)
1010 assert_response :success
1011 assert_template :account
1012 assert_select ".notice", /^User information updated successfully/
1013 assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-group > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
1015 # Removing the image should work
1016 post user_account_path(user), :params => { :avatar_action => "delete", :user => user.attributes }
1017 assert_response :redirect
1018 assert_redirected_to user_account_url(user)
1019 get user_account_path(user)
1020 assert_response :success
1021 assert_template :account
1022 assert_select ".notice", /^User information updated successfully/
1023 assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-check > input[name=avatar_action][checked]", false
1024 assert_select "form#accountForm > fieldset.form-group > div.form-row > div.col-sm-10 > div.form-group > div.form-check > input[name=avatar_action][checked]", false
1026 # Adding external authentication should redirect to the auth provider
1027 post user_account_path(user), :params => { :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }
1028 assert_response :redirect
1029 assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{ERB::Util.u(user.display_name)}/account")
1031 # Changing name to one that exists should fail
1032 new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name)
1033 post user_account_path(user), :params => { :user => new_attributes }
1034 assert_response :success
1035 assert_template :account
1036 assert_select ".notice", false
1037 assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
1039 # Changing name to one that exists should fail, regardless of case
1040 new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name.upcase)
1041 post user_account_path(user), :params => { :user => new_attributes }
1042 assert_response :success
1043 assert_template :account
1044 assert_select ".notice", false
1045 assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name"
1047 # Changing name to one that doesn't exist should work
1048 new_attributes = user.attributes.dup.merge(:display_name => "new tester")
1049 post user_account_path(user), :params => { :user => new_attributes }
1050 assert_response :redirect
1051 assert_redirected_to user_account_url(:display_name => "new tester")
1052 get user_account_path(:display_name => "new tester")
1053 assert_response :success
1054 assert_template :account
1055 assert_select ".notice", /^User information updated successfully/
1056 assert_select "form#accountForm > div.form-group > input#user_display_name[value=?]", "new tester"
1058 # Record the change of name
1059 user.display_name = "new tester"
1061 # Changing email to one that exists should fail
1062 user.new_email = create(:user).email
1063 assert_no_difference "ActionMailer::Base.deliveries.size" do
1064 perform_enqueued_jobs do
1065 post user_account_path(user), :params => { :user => user.attributes }
1068 assert_response :success
1069 assert_template :account
1070 assert_select ".notice", false
1071 assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
1073 # Changing email to one that exists should fail, regardless of case
1074 user.new_email = create(:user).email.upcase
1075 assert_no_difference "ActionMailer::Base.deliveries.size" do
1076 perform_enqueued_jobs do
1077 post user_account_path(user), :params => { :user => user.attributes }
1080 assert_response :success
1081 assert_template :account
1082 assert_select ".notice", false
1083 assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email"
1085 # Changing email to one that doesn't exist should work
1086 user.new_email = "new_tester@example.com"
1087 assert_difference "ActionMailer::Base.deliveries.size", 1 do
1088 perform_enqueued_jobs do
1089 post user_account_path(user), :params => { :user => user.attributes }
1092 assert_response :redirect
1093 assert_redirected_to user_account_url(user)
1094 get user_account_path(user)
1095 assert_response :success
1096 assert_template :account
1097 assert_select ".notice", /^User information updated successfully/
1098 assert_select "form#accountForm > div.form-group > input#user_new_email[value=?]", user.new_email
1099 email = ActionMailer::Base.deliveries.first
1100 assert_equal 1, email.to.count
1101 assert_equal user.new_email, email.to.first
1102 ActionMailer::Base.deliveries.clear
1105 # Check that the user account page will display and contains some relevant
1106 # information for the user
1108 # Test a non-existent user
1109 get user_path(:display_name => "unknown")
1110 assert_response :not_found
1112 # Test a normal user
1113 user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
1114 friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
1115 create(:friendship, :befriender => user, :befriendee => friend_user)
1116 create(:changeset, :user => friend_user)
1119 assert_response :success
1120 assert_select "div#userinformation" do
1121 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1122 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
1123 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1124 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1125 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
1126 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1127 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1128 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
1131 # Friends shouldn't be visible as we're not logged in
1132 assert_select "div#friends-container", :count => 0
1134 # Test a user who has been blocked
1135 blocked_user = create(:user)
1136 create(:user_block, :user => blocked_user)
1137 get user_path(blocked_user)
1138 assert_response :success
1139 assert_select "div#userinformation" do
1140 assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
1141 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/traces']", 1
1142 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary']", 1
1143 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary/comments']", 1
1144 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']", 0
1145 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']", 1
1146 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']", 0
1147 assert_select "a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0
1150 # Test a moderator who has applied blocks
1151 moderator_user = create(:moderator_user)
1152 create(:user_block, :creator => moderator_user)
1153 get user_path(moderator_user)
1154 assert_response :success
1155 assert_select "div#userinformation" do
1156 assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
1157 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/traces']", 1
1158 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary']", 1
1159 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary/comments']", 1
1160 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']", 0
1161 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']", 0
1162 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']", 1
1163 assert_select "a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0
1166 # Login as a normal user
1169 # Test the normal user
1171 assert_response :success
1172 assert_select "div#userinformation" do
1173 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1174 assert_select "a[href='/traces/mine']", 1
1175 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1176 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1177 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 1
1178 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1179 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1180 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
1183 # Friends should be visible as we're now logged in
1184 assert_select "div#friends-container" do
1185 assert_select "div.contact-activity", :count => 1
1188 # Login as a moderator
1189 session_for(create(:moderator_user))
1191 # Test the normal user
1193 assert_response :success
1194 assert_select "div#userinformation" do
1195 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1196 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
1197 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1198 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1199 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
1200 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1201 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1202 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1
1206 # Test whether information about contributor terms is shown for users who haven't agreed
1207 def test_terms_not_agreed
1208 agreed_user = create(:user, :terms_agreed => 3.days.ago)
1209 seen_user = create(:user, :terms_seen => true, :terms_agreed => nil)
1210 not_seen_user = create(:user, :terms_seen => false, :terms_agreed => nil)
1212 get user_path(agreed_user)
1213 assert_response :success
1214 assert_select "div#userinformation" do
1215 assert_select "p", :count => 0, :text => /Contributor terms/
1218 get user_path(seen_user)
1219 assert_response :success
1220 # put @response.body
1221 assert_select "div#userinformation" do
1222 assert_select "p", :count => 1, :text => /Contributor terms/
1223 assert_select "p", /Declined/
1226 get user_path(not_seen_user)
1227 assert_response :success
1228 assert_select "div#userinformation" do
1229 assert_select "p", :count => 1, :text => /Contributor terms/
1230 assert_select "p", /Undecided/
1235 user = create(:user)
1237 # Try without logging in
1238 post set_status_user_path(user), :params => { :status => "suspended" }
1239 assert_response :forbidden
1241 # Now try as a normal user
1243 post set_status_user_path(user), :params => { :status => "suspended" }
1244 assert_response :redirect
1245 assert_redirected_to :controller => :errors, :action => :forbidden
1247 # Finally try as an administrator
1248 session_for(create(:administrator_user))
1249 post set_status_user_path(user), :params => { :status => "suspended" }
1250 assert_response :redirect
1251 assert_redirected_to :action => :show, :display_name => user.display_name
1252 assert_equal "suspended", User.find(user.id).status
1256 user = create(:user, :home_lat => 12.1, :home_lon => 12.1, :description => "test")
1258 # Try without logging in
1259 delete user_path(user), :params => { :status => "suspended" }
1260 assert_response :forbidden
1262 # Now try as a normal user
1264 delete user_path(user), :params => { :status => "suspended" }
1265 assert_response :redirect
1266 assert_redirected_to :controller => :errors, :action => :forbidden
1268 # Finally try as an administrator
1269 session_for(create(:administrator_user))
1270 delete user_path(user), :params => { :status => "suspended" }
1271 assert_response :redirect
1272 assert_redirected_to :action => :show, :display_name => user.display_name
1274 # Check that the user was deleted properly
1276 assert_equal "user_#{user.id}", user.display_name
1277 assert_equal "", user.description
1278 assert_nil user.home_lat
1279 assert_nil user.home_lon
1280 assert_not user.avatar.attached?
1281 assert_not user.email_valid
1282 assert_nil user.new_email
1283 assert_nil user.auth_provider
1284 assert_nil user.auth_uid
1285 assert_equal "deleted", user.status
1289 user = create(:user)
1290 moderator_user = create(:moderator_user)
1291 administrator_user = create(:administrator_user)
1292 _suspended_user = create(:user, :suspended)
1293 _ip_user = create(:user, :creation_ip => "1.2.3.4")
1295 # There are now 7 users - the five above, plus two extra "granters" for the
1296 # moderator_user and administrator_user
1297 assert_equal 7, User.count
1299 # Shouldn't work when not logged in
1301 assert_response :redirect
1302 assert_redirected_to :action => :login, :referer => users_path
1306 # Shouldn't work when logged in as a normal user
1308 assert_response :redirect
1309 assert_redirected_to :controller => :errors, :action => :forbidden
1311 session_for(moderator_user)
1313 # Shouldn't work when logged in as a moderator
1315 assert_response :redirect
1316 assert_redirected_to :controller => :errors, :action => :forbidden
1318 session_for(administrator_user)
1320 # Note there is a header row, so all row counts are users + 1
1321 # Should work when logged in as an administrator
1323 assert_response :success
1324 assert_template :index
1325 assert_select "table#user_list tr", :count => 7 + 1
1327 # Should be able to limit by status
1328 get users_path, :params => { :status => "suspended" }
1329 assert_response :success
1330 assert_template :index
1331 assert_select "table#user_list tr", :count => 1 + 1
1333 # Should be able to limit by IP address
1334 get users_path, :params => { :ip => "1.2.3.4" }
1335 assert_response :success
1336 assert_template :index
1337 assert_select "table#user_list tr", :count => 1 + 1
1340 def test_index_get_paginated
1341 1.upto(100).each do |n|
1342 User.create(:display_name => "extra_#{n}",
1343 :email => "extra#{n}@example.com",
1344 :pass_crypt => "extraextra")
1347 session_for(create(:administrator_user))
1349 # 100 examples, an administrator, and a granter for the admin.
1350 assert_equal 102, User.count
1353 assert_response :success
1354 assert_template :index
1355 assert_select "table#user_list tr", :count => 51
1357 get users_path, :params => { :page => 2 }
1358 assert_response :success
1359 assert_template :index
1360 assert_select "table#user_list tr", :count => 51
1362 get users_path, :params => { :page => 3 }
1363 assert_response :success
1364 assert_template :index
1365 assert_select "table#user_list tr", :count => 3
1368 def test_index_post_confirm
1369 inactive_user = create(:user, :pending)
1370 suspended_user = create(:user, :suspended)
1372 # Shouldn't work when not logged in
1373 assert_no_difference "User.active.count" do
1374 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1376 assert_response :forbidden
1378 assert_equal "pending", inactive_user.reload.status
1379 assert_equal "suspended", suspended_user.reload.status
1381 session_for(create(:user))
1383 # Shouldn't work when logged in as a normal user
1384 assert_no_difference "User.active.count" do
1385 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1387 assert_response :redirect
1388 assert_redirected_to :controller => :errors, :action => :forbidden
1389 assert_equal "pending", inactive_user.reload.status
1390 assert_equal "suspended", suspended_user.reload.status
1392 session_for(create(:moderator_user))
1394 # Shouldn't work when logged in as a moderator
1395 assert_no_difference "User.active.count" do
1396 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1398 assert_response :redirect
1399 assert_redirected_to :controller => :errors, :action => :forbidden
1400 assert_equal "pending", inactive_user.reload.status
1401 assert_equal "suspended", suspended_user.reload.status
1403 session_for(create(:administrator_user))
1405 # Should work when logged in as an administrator
1406 assert_difference "User.active.count", 2 do
1407 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1409 assert_response :redirect
1410 assert_redirected_to :action => :index
1411 assert_equal "confirmed", inactive_user.reload.status
1412 assert_equal "confirmed", suspended_user.reload.status
1415 def test_index_post_hide
1416 normal_user = create(:user)
1417 confirmed_user = create(:user, :confirmed)
1419 # Shouldn't work when not logged in
1420 assert_no_difference "User.active.count" do
1421 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1423 assert_response :forbidden
1425 assert_equal "active", normal_user.reload.status
1426 assert_equal "confirmed", confirmed_user.reload.status
1428 session_for(create(:user))
1430 # Shouldn't work when logged in as a normal user
1431 assert_no_difference "User.active.count" do
1432 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1434 assert_response :redirect
1435 assert_redirected_to :controller => :errors, :action => :forbidden
1436 assert_equal "active", normal_user.reload.status
1437 assert_equal "confirmed", confirmed_user.reload.status
1439 session_for(create(:moderator_user))
1441 # Shouldn't work when logged in as a moderator
1442 assert_no_difference "User.active.count" do
1443 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1445 assert_response :redirect
1446 assert_redirected_to :controller => :errors, :action => :forbidden
1447 assert_equal "active", normal_user.reload.status
1448 assert_equal "confirmed", confirmed_user.reload.status
1450 session_for(create(:administrator_user))
1452 # Should work when logged in as an administrator
1453 assert_difference "User.active.count", -2 do
1454 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1456 assert_response :redirect
1457 assert_redirected_to :action => :index
1458 assert_equal "deleted", normal_user.reload.status
1459 assert_equal "deleted", confirmed_user.reload.status