X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/16434ef1ba6b00121d1d45a80e540f2b522612d1..2dfe6f3f2e911101f4e4e3b90a00e2ae97725d04:/test/controllers/users_controller_test.rb diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index e979e5f6d..a530a6f85 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -151,7 +151,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > div.form-group > input.is-invalid#user_email" + assert_select "form > div > input.is-invalid#user_email" end def test_save_duplicate_email @@ -180,7 +180,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > div.form-group > input.is-invalid#user_email" + assert_select "form > div > input.is-invalid#user_email" end def test_save_duplicate_email_uppercase @@ -209,7 +209,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > div.form-group > input.is-invalid#user_email" + assert_select "form > div > input.is-invalid#user_email" end def test_save_duplicate_name @@ -238,7 +238,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > div.form-group > input.is-invalid#user_display_name" + assert_select "form > div > input.is-invalid#user_display_name" end def test_save_duplicate_name_uppercase @@ -267,7 +267,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > div.form-group > input.is-invalid#user_display_name" + assert_select "form > div > input.is-invalid#user_display_name" end def test_save_blocked_domain @@ -312,15 +312,13 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_difference "User.count", 1 do assert_difference "ActionMailer::Base.deliveries.size", 1 do - perform_enqueued_jobs do - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } - end + post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + assert_enqueued_with :job => ActionMailer::MailDeliveryJob, + :args => proc { |args| args[3][:args][2] == welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3) } + perform_enqueued_jobs end end - assert_equal welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3), - User.find_by(:email => user.email).tokens.order("id DESC").first.referer - ActionMailer::Base.deliveries.clear end @@ -495,6 +493,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0 + assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 0 end # Login as a moderator @@ -512,6 +511,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0 assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0 assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1 + assert_select "a[href='/api/0.6/user/#{ERB::Util.u(user.id)}']", 1 end end @@ -529,7 +529,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest get user_path(seen_user) assert_response :success - # put @response.body assert_select "div.content-heading" do assert_select "dt", :count => 1, :text => /Contributor terms/ assert_select "dd", /Declined/ @@ -547,21 +546,21 @@ class UsersControllerTest < ActionDispatch::IntegrationTest user = create(:user) # Try without logging in - post set_status_user_path(user), :params => { :status => "suspended" } + post set_status_user_path(user), :params => { :event => "confirm" } assert_response :forbidden # Now try as a normal user session_for(user) - post set_status_user_path(user), :params => { :status => "suspended" } + post set_status_user_path(user), :params => { :event => "confirm" } assert_response :redirect assert_redirected_to :controller => :errors, :action => :forbidden # Finally try as an administrator session_for(create(:administrator_user)) - post set_status_user_path(user), :params => { :status => "suspended" } + post set_status_user_path(user), :params => { :event => "confirm" } assert_response :redirect assert_redirected_to :action => :show, :display_name => user.display_name - assert_equal "suspended", User.find(user.id).status + assert_equal "confirmed", User.find(user.id).status end def test_destroy