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 > fieldset > div.standard-form-row > input.field_with_errors#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 > fieldset > div.standard-form-row > input.field_with_errors#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 > fieldset > div.standard-form-row > input.field_with_errors#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 > fieldset > div.standard-form-row > input.field_with_errors#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 > fieldset > div.standard-form-row > input.field_with_errors#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 :success
957 assert_template :account
958 assert_select "div#errorExplanation", false
959 assert_select ".notice", /^User information updated successfully/
960 assert_select "form#accountForm > fieldset > div.standard-form-row > div#user_description_container > div#user_description_content > textarea#user_description", user.description
962 # Changing to a invalid editor should fail
963 user.preferred_editor = "unknown"
964 post user_account_path(user), :params => { :user => user.attributes }
965 assert_response :success
966 assert_template :account
967 assert_select ".notice", false
968 assert_select "div#errorExplanation"
969 assert_select "form#accountForm > fieldset > div.standard-form-row > select#user_preferred_editor > option[selected]", false
971 # Changing to a valid editor should work
972 user.preferred_editor = "id"
973 post user_account_path(user), :params => { :user => user.attributes }
974 assert_response :success
975 assert_template :account
976 assert_select "div#errorExplanation", false
977 assert_select ".notice", /^User information updated successfully/
978 assert_select "form#accountForm > fieldset > div.standard-form-row > select#user_preferred_editor > option[selected][value=?]", "id"
980 # Changing to the default editor should work
981 user.preferred_editor = "default"
982 post user_account_path(user), :params => { :user => user.attributes }
983 assert_response :success
984 assert_template :account
985 assert_select "div#errorExplanation", false
986 assert_select ".notice", /^User information updated successfully/
987 assert_select "form#accountForm > fieldset > div.standard-form-row > select#user_preferred_editor > option[selected]", false
989 # Changing to an uploaded image should work
990 image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
991 post user_account_path(user), :params => { :avatar_action => "new", :user => user.attributes.merge(:avatar => image) }
992 assert_response :success
993 assert_template :account
994 assert_select "div#errorExplanation", false
995 assert_select ".notice", /^User information updated successfully/
996 assert_select "form#accountForm > fieldset > div.standard-form-row.accountImage input[name=avatar_action][checked][value=?]", "keep"
998 # Changing to a gravatar image should work
999 post user_account_path(user), :params => { :avatar_action => "gravatar", :user => user.attributes }
1000 assert_response :success
1001 assert_template :account
1002 assert_select "div#errorExplanation", false
1003 assert_select ".notice", /^User information updated successfully/
1004 assert_select "form#accountForm > fieldset > div.standard-form-row.accountImage input[name=avatar_action][checked][value=?]", "gravatar"
1006 # Removing the image should work
1007 post user_account_path(user), :params => { :avatar_action => "delete", :user => user.attributes }
1008 assert_response :success
1009 assert_template :account
1010 assert_select "div#errorExplanation", false
1011 assert_select ".notice", /^User information updated successfully/
1012 assert_select "form#accountForm > fieldset > div.standard-form-row.accountImage input[name=avatar_action][checked]", false
1014 # Adding external authentication should redirect to the auth provider
1015 post user_account_path(user), :params => { :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }
1016 assert_response :redirect
1017 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")
1019 # Changing name to one that exists should fail
1020 new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name)
1021 post user_account_path(user), :params => { :user => new_attributes }
1022 assert_response :success
1023 assert_template :account
1024 assert_select ".notice", false
1025 assert_select "div#errorExplanation"
1026 assert_select "form#accountForm > fieldset > div.standard-form-row > input.field_with_errors#user_display_name"
1028 # Changing name to one that exists should fail, regardless of case
1029 new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name.upcase)
1030 post user_account_path(user), :params => { :user => new_attributes }
1031 assert_response :success
1032 assert_template :account
1033 assert_select ".notice", false
1034 assert_select "div#errorExplanation"
1035 assert_select "form#accountForm > fieldset > div.standard-form-row > input.field_with_errors#user_display_name"
1037 # Changing name to one that doesn't exist should work
1038 new_attributes = user.attributes.dup.merge(:display_name => "new tester")
1039 post user_account_path(user), :params => { :user => new_attributes }
1040 assert_response :success
1041 assert_template :account
1042 assert_select "div#errorExplanation", false
1043 assert_select ".notice", /^User information updated successfully/
1044 assert_select "form#accountForm > fieldset > div.standard-form-row > input#user_display_name[value=?]", "new tester"
1046 # Record the change of name
1047 user.display_name = "new tester"
1049 # Changing email to one that exists should fail
1050 user.new_email = create(:user).email
1051 assert_no_difference "ActionMailer::Base.deliveries.size" do
1052 perform_enqueued_jobs do
1053 post user_account_path(user), :params => { :user => user.attributes }
1056 assert_response :success
1057 assert_template :account
1058 assert_select ".notice", false
1059 assert_select "div#errorExplanation"
1060 assert_select "form#accountForm > fieldset > div.standard-form-row > input.field_with_errors#user_new_email"
1062 # Changing email to one that exists should fail, regardless of case
1063 user.new_email = create(:user).email.upcase
1064 assert_no_difference "ActionMailer::Base.deliveries.size" do
1065 perform_enqueued_jobs do
1066 post user_account_path(user), :params => { :user => user.attributes }
1069 assert_response :success
1070 assert_template :account
1071 assert_select ".notice", false
1072 assert_select "div#errorExplanation"
1073 assert_select "form#accountForm > fieldset > div.standard-form-row > input.field_with_errors#user_new_email"
1075 # Changing email to one that doesn't exist should work
1076 user.new_email = "new_tester@example.com"
1077 assert_difference "ActionMailer::Base.deliveries.size", 1 do
1078 perform_enqueued_jobs do
1079 post user_account_path(user), :params => { :user => user.attributes }
1082 assert_response :success
1083 assert_template :account
1084 assert_select "div#errorExplanation", false
1085 assert_select ".notice", /^User information updated successfully/
1086 assert_select "form#accountForm > fieldset > div.standard-form-row > input#user_new_email[value=?]", user.new_email
1087 email = ActionMailer::Base.deliveries.first
1088 assert_equal 1, email.to.count
1089 assert_equal user.new_email, email.to.first
1090 ActionMailer::Base.deliveries.clear
1093 # Check that the user account page will display and contains some relevant
1094 # information for the user
1096 # Test a non-existent user
1097 get user_path(:display_name => "unknown")
1098 assert_response :not_found
1100 # Test a normal user
1101 user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
1102 friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
1103 create(:friendship, :befriender => user, :befriendee => friend_user)
1104 create(:changeset, :user => friend_user)
1107 assert_response :success
1108 assert_select "div#userinformation" do
1109 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1110 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
1111 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1112 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1113 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
1114 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1115 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1116 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
1119 # Friends shouldn't be visible as we're not logged in
1120 assert_select "div#friends-container", :count => 0
1122 # Test a user who has been blocked
1123 blocked_user = create(:user)
1124 create(:user_block, :user => blocked_user)
1125 get user_path(blocked_user)
1126 assert_response :success
1127 assert_select "div#userinformation" do
1128 assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
1129 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/traces']", 1
1130 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary']", 1
1131 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary/comments']", 1
1132 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']", 0
1133 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']", 1
1134 assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']", 0
1135 assert_select "a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0
1138 # Test a moderator who has applied blocks
1139 moderator_user = create(:moderator_user)
1140 create(:user_block, :creator => moderator_user)
1141 get user_path(moderator_user)
1142 assert_response :success
1143 assert_select "div#userinformation" do
1144 assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
1145 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/traces']", 1
1146 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary']", 1
1147 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary/comments']", 1
1148 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']", 0
1149 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']", 0
1150 assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']", 1
1151 assert_select "a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0
1154 # Login as a normal user
1157 # Test the normal user
1159 assert_response :success
1160 assert_select "div#userinformation" do
1161 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1162 assert_select "a[href='/traces/mine']", 1
1163 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1164 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1165 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 1
1166 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1167 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1168 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
1171 # Friends should be visible as we're now logged in
1172 assert_select "div#friends-container" do
1173 assert_select "div.contact-activity", :count => 1
1176 # Login as a moderator
1177 session_for(create(:moderator_user))
1179 # Test the normal user
1181 assert_response :success
1182 assert_select "div#userinformation" do
1183 assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
1184 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
1185 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
1186 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
1187 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
1188 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
1189 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
1190 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1
1194 # Test whether information about contributor terms is shown for users who haven't agreed
1195 def test_terms_not_agreed
1196 agreed_user = create(:user, :terms_agreed => 3.days.ago)
1197 seen_user = create(:user, :terms_seen => true, :terms_agreed => nil)
1198 not_seen_user = create(:user, :terms_seen => false, :terms_agreed => nil)
1200 get user_path(agreed_user)
1201 assert_response :success
1202 assert_select "div#userinformation" do
1203 assert_select "p", :count => 0, :text => /Contributor terms/
1206 get user_path(seen_user)
1207 assert_response :success
1208 # put @response.body
1209 assert_select "div#userinformation" do
1210 assert_select "p", :count => 1, :text => /Contributor terms/
1211 assert_select "p", /Declined/
1214 get user_path(not_seen_user)
1215 assert_response :success
1216 assert_select "div#userinformation" do
1217 assert_select "p", :count => 1, :text => /Contributor terms/
1218 assert_select "p", /Undecided/
1223 user = create(:user)
1225 # Try without logging in
1226 post set_status_user_path(user), :params => { :status => "suspended" }
1227 assert_response :forbidden
1229 # Now try as a normal user
1231 post set_status_user_path(user), :params => { :status => "suspended" }
1232 assert_response :redirect
1233 assert_redirected_to :controller => :errors, :action => :forbidden
1235 # Finally try as an administrator
1236 session_for(create(:administrator_user))
1237 post set_status_user_path(user), :params => { :status => "suspended" }
1238 assert_response :redirect
1239 assert_redirected_to :action => :show, :display_name => user.display_name
1240 assert_equal "suspended", User.find(user.id).status
1244 user = create(:user, :home_lat => 12.1, :home_lon => 12.1, :description => "test")
1246 # Try without logging in
1247 delete user_path(user), :params => { :status => "suspended" }
1248 assert_response :forbidden
1250 # Now try as a normal user
1252 delete user_path(user), :params => { :status => "suspended" }
1253 assert_response :redirect
1254 assert_redirected_to :controller => :errors, :action => :forbidden
1256 # Finally try as an administrator
1257 session_for(create(:administrator_user))
1258 delete user_path(user), :params => { :status => "suspended" }
1259 assert_response :redirect
1260 assert_redirected_to :action => :show, :display_name => user.display_name
1262 # Check that the user was deleted properly
1264 assert_equal "user_#{user.id}", user.display_name
1265 assert_equal "", user.description
1266 assert_nil user.home_lat
1267 assert_nil user.home_lon
1268 assert_not user.avatar.attached?
1269 assert_not user.email_valid
1270 assert_nil user.new_email
1271 assert_nil user.auth_provider
1272 assert_nil user.auth_uid
1273 assert_equal "deleted", user.status
1277 user = create(:user)
1278 moderator_user = create(:moderator_user)
1279 administrator_user = create(:administrator_user)
1280 _suspended_user = create(:user, :suspended)
1281 _ip_user = create(:user, :creation_ip => "1.2.3.4")
1283 # There are now 7 users - the five above, plus two extra "granters" for the
1284 # moderator_user and administrator_user
1285 assert_equal 7, User.count
1287 # Shouldn't work when not logged in
1289 assert_response :redirect
1290 assert_redirected_to :action => :login, :referer => users_path
1294 # Shouldn't work when logged in as a normal user
1296 assert_response :redirect
1297 assert_redirected_to :controller => :errors, :action => :forbidden
1299 session_for(moderator_user)
1301 # Shouldn't work when logged in as a moderator
1303 assert_response :redirect
1304 assert_redirected_to :controller => :errors, :action => :forbidden
1306 session_for(administrator_user)
1308 # Note there is a header row, so all row counts are users + 1
1309 # Should work when logged in as an administrator
1311 assert_response :success
1312 assert_template :index
1313 assert_select "table#user_list tr", :count => 7 + 1
1315 # Should be able to limit by status
1316 get users_path, :params => { :status => "suspended" }
1317 assert_response :success
1318 assert_template :index
1319 assert_select "table#user_list tr", :count => 1 + 1
1321 # Should be able to limit by IP address
1322 get users_path, :params => { :ip => "1.2.3.4" }
1323 assert_response :success
1324 assert_template :index
1325 assert_select "table#user_list tr", :count => 1 + 1
1328 def test_index_get_paginated
1329 1.upto(100).each do |n|
1330 User.create(:display_name => "extra_#{n}",
1331 :email => "extra#{n}@example.com",
1332 :pass_crypt => "extraextra")
1335 session_for(create(:administrator_user))
1337 # 100 examples, an administrator, and a granter for the admin.
1338 assert_equal 102, User.count
1341 assert_response :success
1342 assert_template :index
1343 assert_select "table#user_list tr", :count => 51
1345 get users_path, :params => { :page => 2 }
1346 assert_response :success
1347 assert_template :index
1348 assert_select "table#user_list tr", :count => 51
1350 get users_path, :params => { :page => 3 }
1351 assert_response :success
1352 assert_template :index
1353 assert_select "table#user_list tr", :count => 3
1356 def test_index_post_confirm
1357 inactive_user = create(:user, :pending)
1358 suspended_user = create(:user, :suspended)
1360 # Shouldn't work when not logged in
1361 assert_no_difference "User.active.count" do
1362 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1364 assert_response :forbidden
1366 assert_equal "pending", inactive_user.reload.status
1367 assert_equal "suspended", suspended_user.reload.status
1369 session_for(create(:user))
1371 # Shouldn't work when logged in as a normal user
1372 assert_no_difference "User.active.count" do
1373 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1375 assert_response :redirect
1376 assert_redirected_to :controller => :errors, :action => :forbidden
1377 assert_equal "pending", inactive_user.reload.status
1378 assert_equal "suspended", suspended_user.reload.status
1380 session_for(create(:moderator_user))
1382 # Shouldn't work when logged in as a moderator
1383 assert_no_difference "User.active.count" do
1384 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1386 assert_response :redirect
1387 assert_redirected_to :controller => :errors, :action => :forbidden
1388 assert_equal "pending", inactive_user.reload.status
1389 assert_equal "suspended", suspended_user.reload.status
1391 session_for(create(:administrator_user))
1393 # Should work when logged in as an administrator
1394 assert_difference "User.active.count", 2 do
1395 post users_path, :params => { :confirm => 1, :user => { inactive_user.id => 1, suspended_user.id => 1 } }
1397 assert_response :redirect
1398 assert_redirected_to :action => :index
1399 assert_equal "confirmed", inactive_user.reload.status
1400 assert_equal "confirmed", suspended_user.reload.status
1403 def test_index_post_hide
1404 normal_user = create(:user)
1405 confirmed_user = create(:user, :confirmed)
1407 # Shouldn't work when not logged in
1408 assert_no_difference "User.active.count" do
1409 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1411 assert_response :forbidden
1413 assert_equal "active", normal_user.reload.status
1414 assert_equal "confirmed", confirmed_user.reload.status
1416 session_for(create(:user))
1418 # Shouldn't work when logged in as a normal user
1419 assert_no_difference "User.active.count" do
1420 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1422 assert_response :redirect
1423 assert_redirected_to :controller => :errors, :action => :forbidden
1424 assert_equal "active", normal_user.reload.status
1425 assert_equal "confirmed", confirmed_user.reload.status
1427 session_for(create(:moderator_user))
1429 # Shouldn't work when logged in as a moderator
1430 assert_no_difference "User.active.count" do
1431 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1433 assert_response :redirect
1434 assert_redirected_to :controller => :errors, :action => :forbidden
1435 assert_equal "active", normal_user.reload.status
1436 assert_equal "confirmed", confirmed_user.reload.status
1438 session_for(create(:administrator_user))
1440 # Should work when logged in as an administrator
1441 assert_difference "User.active.count", -2 do
1442 post users_path, :params => { :hide => 1, :user => { normal_user.id => 1, confirmed_user.id => 1 } }
1444 assert_response :redirect
1445 assert_redirected_to :action => :index
1446 assert_equal "deleted", normal_user.reload.status
1447 assert_equal "deleted", confirmed_user.reload.status