X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/4549de5f327adba0938a95198aa21c15ff98521a..b7887b049fa1aae17f8b7020fe43542fffde1260:/test/controllers/accounts_controller_test.rb?ds=sidebyside diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb index 27e05379c..1e39a7329 100644 --- a/test/controllers/accounts_controller_test.rb +++ b/test/controllers/accounts_controller_test.rb @@ -61,7 +61,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", false - assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name" + assert_select "form#accountForm > div > input.is-invalid#user_display_name" # Changing name to one that exists should fail, regardless of case new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name.upcase) @@ -69,7 +69,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", false - assert_select "form#accountForm > div.form-group > input.is-invalid#user_display_name" + assert_select "form#accountForm > div > input.is-invalid#user_display_name" # Changing name to one that doesn't exist should work new_attributes = user.attributes.dup.merge(:display_name => "new tester") @@ -80,7 +80,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > div.form-group > input#user_display_name[value=?]", "new tester" + assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester" # Record the change of name user.display_name = "new tester" @@ -95,7 +95,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", false - assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email" + assert_select "form#accountForm > div > input.is-invalid#user_new_email" # Changing email to one that exists should fail, regardless of case user.new_email = create(:user).email.upcase @@ -107,7 +107,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", false - assert_select "form#accountForm > div.form-group > input.is-invalid#user_new_email" + assert_select "form#accountForm > div > input.is-invalid#user_new_email" # Changing email to one that doesn't exist should work user.new_email = "new_tester@example.com" @@ -122,10 +122,34 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template :edit assert_select ".notice", /^User information updated successfully/ - assert_select "form#accountForm > div.form-group > input#user_new_email[value=?]", user.new_email + assert_select "form#accountForm > div > input#user_new_email[value=?]", user.new_email email = ActionMailer::Base.deliveries.first assert_equal 1, email.to.count assert_equal user.new_email, email.to.first ActionMailer::Base.deliveries.clear end + + def test_private_account + user = create(:user, :data_public => false) + + # Make sure that you are redirected to the login page when + # you are not logged in + get edit_account_path + assert_response :redirect + assert_redirected_to login_path(:referer => "/account/edit") + + # Make sure we get the page when we are logged in as the right user + session_for(user) + get edit_account_path + assert_response :success + assert_template :edit + assert_select "form#accountForm" do |form| + assert_equal "post", form.attr("method").to_s + assert_select "input[name='_method']", true + assert_equal "/account", form.attr("action").to_s + end + + # Make sure we have a button to "go public" + assert_select "form.button_to[action='/user/go_public']", true + end end