diff --git a/test/integration/confirmable_test.rb b/test/integration/confirmable_test.rb index e403077487..c951eb0bbd 100644 --- a/test/integration/confirmable_test.rb +++ b/test/integration/confirmable_test.rb @@ -178,13 +178,13 @@ def resend_confirmation test "should not be able to confirm an email with a blank confirmation token" do visit_user_confirmation_with_token("") - assert_contain "Confirmation token can't be blank" + assert_contain %r{Confirmation token can['’]t be blank} end test "should not be able to confirm an email with a nil confirmation token" do visit_user_confirmation_with_token(nil) - assert_contain "Confirmation token can't be blank" + assert_contain %r{Confirmation token can['’]t be blank} end test "should not be able to confirm user with blank confirmation token" do @@ -193,7 +193,7 @@ def resend_confirmation visit_user_confirmation_with_token("") - assert_contain "Confirmation token can't be blank" + assert_contain %r{Confirmation token can['’]t be blank} end test "should not be able to confirm user with nil confirmation token" do @@ -202,7 +202,7 @@ def resend_confirmation visit_user_confirmation_with_token(nil) - assert_contain "Confirmation token can't be blank" + assert_contain %r{Confirmation token can['’]t be blank} end test 'error message is configurable by resource name' do diff --git a/test/integration/recoverable_test.rb b/test/integration/recoverable_test.rb index 9abf2b1ba7..44cb0b9e2d 100644 --- a/test/integration/recoverable_test.rb +++ b/test/integration/recoverable_test.rb @@ -173,7 +173,7 @@ def reset_password(options = {}, &block) assert_response :success assert_current_url '/users/password' assert_have_selector '#error_explanation' - assert_contain "Password confirmation doesn't match Password" + assert_contain %r{Password confirmation doesn['’]t match Password} assert_not user.reload.valid_password?('987654321') end diff --git a/test/integration/registerable_test.rb b/test/integration/registerable_test.rb index e08933f8e6..038fcf7b91 100644 --- a/test/integration/registerable_test.rb +++ b/test/integration/registerable_test.rb @@ -112,7 +112,7 @@ def user_sign_up assert_template 'registrations/new' assert_have_selector '#error_explanation' assert_contain "Email is invalid" - assert_contain "Password confirmation doesn't match Password" + assert_contain %r{Password confirmation doesn['’]t match Password} assert_contain "2 errors prohibited" assert_nil User.to_adapter.find_first @@ -251,7 +251,7 @@ def user_sign_up fill_in 'current password', with: '12345678' click_button 'Update' - assert_contain "Password confirmation doesn't match Password" + assert_contain %r{Password confirmation doesn['’]t match Password} assert_not User.to_adapter.find_first.valid_password?('pas123') end diff --git a/test/models/authenticatable_test.rb b/test/models/authenticatable_test.rb index a3ddc52f57..fa31f6a88a 100644 --- a/test/models/authenticatable_test.rb +++ b/test/models/authenticatable_test.rb @@ -30,12 +30,12 @@ class AuthenticatableTest < ActiveSupport::TestCase test 'find_or_initialize_with_errors adds blank error' do user_with_error = User.find_or_initialize_with_errors([:email], { email: "" }) - assert_equal ["Email can't be blank"], user_with_error.errors.full_messages_for(:email) + assert user_with_error.errors.added?(:email, :blank) end test 'find_or_initialize_with_errors adds invalid error' do user_with_error = User.find_or_initialize_with_errors([:email], { email: "example@example.com" }) - assert_equal ["Email is invalid"], user_with_error.errors.full_messages_for(:email) + assert user_with_error.errors.added?(:email, :invalid) end if defined?(ActionController::Parameters) diff --git a/test/models/confirmable_test.rb b/test/models/confirmable_test.rb index 9c627e820f..31a955e727 100644 --- a/test/models/confirmable_test.rb +++ b/test/models/confirmable_test.rb @@ -74,7 +74,7 @@ def setup test 'should return a new record with errors when a blank token is given' do confirmed_user = User.confirm_by_token('') assert_not confirmed_user.persisted? - assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join + assert confirmed_user.errors.added?(:confirmation_token, :blank) end test 'should return a new record with errors when a blank token is given and a record exists on the database' do @@ -83,7 +83,7 @@ def setup confirmed_user = User.confirm_by_token('') assert_not user.reload.confirmed? - assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join + assert confirmed_user.errors.added?(:confirmation_token, :blank) end test 'should return a new record with errors when a nil token is given and a record exists on the database' do @@ -92,7 +92,7 @@ def setup confirmed_user = User.confirm_by_token(nil) assert_not user.reload.confirmed? - assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join + assert confirmed_user.errors.added?(:confirmation_token, :blank) end test 'should generate errors for a user email if user is already confirmed' do @@ -314,7 +314,7 @@ def setup user = create_user confirm_user = User.send_confirmation_instructions(email: user.email) assert_not confirm_user.persisted? - assert_equal "can't be blank", confirm_user.errors[:username].join + assert confirm_user.errors.added?(:username, :blank) end end diff --git a/test/models/database_authenticatable_test.rb b/test/models/database_authenticatable_test.rb index 8cdf7228cb..909e010458 100644 --- a/test/models/database_authenticatable_test.rb +++ b/test/models/database_authenticatable_test.rb @@ -172,7 +172,7 @@ def setup assert_not user.update_with_password(password: 'pass4321', password_confirmation: 'pass4321') assert user.reload.valid_password?('12345678') - assert_match "can't be blank", user.errors[:current_password].join + assert user.errors.added?(:current_password, :blank) end test 'should run validations even when current password is invalid or blank' do @@ -181,7 +181,7 @@ def setup assert user.persisted? assert_not user.update_with_password(username: "") assert_match "usertest", user.reload.username - assert_match "can't be blank", user.errors[:username].join + assert user.errors.added?(:username, :blank) end test 'should ignore password and its confirmation if they are blank' do @@ -235,7 +235,7 @@ def setup user = create_user assert_not user.destroy_with_password(nil) assert user.persisted? - assert_match "can't be blank", user.errors[:current_password].join + assert user.errors.added?(:current_password, :blank) end test 'should not email on password change' do diff --git a/test/models/lockable_test.rb b/test/models/lockable_test.rb index d229ce57d2..b1d8cab0d4 100644 --- a/test/models/lockable_test.rb +++ b/test/models/lockable_test.rb @@ -213,7 +213,7 @@ def setup test 'should return a new record with errors when a blank token is given' do locked_user = User.unlock_access_by_token('') assert_not locked_user.persisted? - assert_equal "can't be blank", locked_user.errors[:unlock_token].join + assert locked_user.errors.added?(:unlock_token, :blank) end test 'should find a user to send unlock instructions' do @@ -246,7 +246,7 @@ def setup user = create_user unlock_user = User.send_unlock_instructions(email: user.email) assert_not unlock_user.persisted? - assert_equal "can't be blank", unlock_user.errors[:username].join + assert unlock_user.errors.added?(:username, :blank) end end diff --git a/test/models/recoverable_test.rb b/test/models/recoverable_test.rb index 1c43aa2dcc..b2234ac6ac 100644 --- a/test/models/recoverable_test.rb +++ b/test/models/recoverable_test.rb @@ -134,12 +134,12 @@ def setup end test 'should require all reset_password_keys' do - swap Devise, reset_password_keys: [:username, :email] do - user = create_user - reset_password_user = User.send_reset_password_instructions(email: user.email) - assert_not reset_password_user.persisted? - assert_equal "can't be blank", reset_password_user.errors[:username].join - end + swap Devise, reset_password_keys: [:username, :email] do + user = create_user + reset_password_user = User.send_reset_password_instructions(email: user.email) + assert_not reset_password_user.persisted? + assert reset_password_user.errors.added?(:username, :blank) + end end test 'should reset reset_password_token before send the reset instructions email' do @@ -173,7 +173,7 @@ def setup test 'should return a new record with errors if reset_password_token is blank' do reset_password_user = User.reset_password_by_token(reset_password_token: '') assert_not reset_password_user.persisted? - assert_match "can't be blank", reset_password_user.errors[:reset_password_token].join + assert reset_password_user.errors.added?(:reset_password_token, :blank) end test 'should return a new record with errors if password is blank' do @@ -182,7 +182,7 @@ def setup reset_password_user = User.reset_password_by_token(reset_password_token: raw, password: '') assert_not reset_password_user.errors.empty? - assert_match "can't be blank", reset_password_user.errors[:password].join + assert reset_password_user.errors.added?(:password, :blank) assert_equal raw, reset_password_user.reset_password_token end @@ -192,7 +192,7 @@ def setup reset_password_user = User.reset_password_by_token(reset_password_token: raw) assert_not reset_password_user.errors.empty? - assert_match "can't be blank", reset_password_user.errors[:password].join + assert reset_password_user.errors.added?(:password, :blank) assert_equal raw, reset_password_user.reset_password_token end diff --git a/test/models/validatable_test.rb b/test/models/validatable_test.rb index af5961ef30..e8858de7e3 100644 --- a/test/models/validatable_test.rb +++ b/test/models/validatable_test.rb @@ -8,7 +8,7 @@ class ValidatableTest < ActiveSupport::TestCase user = new_user(email: nil) assert user.invalid? assert user.errors[:email] - assert_equal 'can\'t be blank', user.errors[:email].join + assert user.errors.added?(:email, :blank) end test 'should require uniqueness of email if email has changed, allowing blank' do @@ -52,14 +52,14 @@ class ValidatableTest < ActiveSupport::TestCase test 'should require password to be set when creating a new record' do user = new_user(password: '', password_confirmation: '') assert user.invalid? - assert_equal 'can\'t be blank', user.errors[:password].join + assert user.errors.added?(:password, :blank) end test 'should require confirmation to be set when creating a new record' do user = new_user(password: 'new_password', password_confirmation: 'blabla') assert user.invalid? - assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join + assert user.errors.added?(:password_confirmation, :confirmation, attribute: "Password") end test 'should require password when updating/resetting password' do @@ -69,7 +69,7 @@ class ValidatableTest < ActiveSupport::TestCase user.password_confirmation = '' assert user.invalid? - assert_equal 'can\'t be blank', user.errors[:password].join + assert user.errors.added?(:password, :blank) end test 'should require confirmation when updating/resetting password' do @@ -77,7 +77,7 @@ class ValidatableTest < ActiveSupport::TestCase user.password_confirmation = 'another_password' assert user.invalid? - assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join + assert user.errors.added?(:password_confirmation, :confirmation, attribute: "Password") end test 'should require a password with minimum of 7 characters' do