]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/accounts_controller_test.rb
Require display names to have a minimum unicode width of 3 columns
[rails.git] / test / controllers / accounts_controller_test.rb
index 173bcf22c568819bc098a488aa688f0bf5948413..131292f412d90f286b8798b81b84bde1015b2be4 100644 (file)
@@ -60,16 +60,16 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     patch account_path, :params => { :user => new_attributes }
     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 ".alert-success", false
+    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)
     patch account_path, :params => { :user => new_attributes }
     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 ".alert-success", false
+    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")
@@ -79,8 +79,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     get edit_account_path
     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 ".alert-success", /^User information updated successfully/
+    assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester"
 
     # Record the change of name
     user.display_name = "new tester"
@@ -94,8 +94,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     end
     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 ".alert-success", false
+    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
@@ -106,8 +106,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     end
     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 ".alert-success", false
+    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"
@@ -121,8 +121,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     get edit_account_path
     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 ".alert-success", /^User information updated successfully/
+    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
@@ -152,4 +152,23 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     # Make sure we have a button to "go public"
     assert_select "form.button_to[action='/user/go_public']", true
   end
+
+  def test_destroy_allowed
+    user = create(:user)
+    session_for(user)
+
+    delete account_path
+    assert_response :redirect
+  end
+
+  def test_destroy_not_allowed
+    with_user_account_deletion_delay(24) do
+      user = create(:user)
+      create(:changeset, :user => user, :created_at => Time.now.utc)
+      session_for(user)
+
+      delete account_path
+      assert_response :bad_request
+    end
+  end
 end