From c3432e57b1019bd369e745f24a8330975b4cff9d Mon Sep 17 00:00:00 2001 From: Chase DuBois Date: Tue, 21 Jun 2011 20:45:07 -0400 Subject: [PATCH] Test for previous commit --- test/models/database_authenticatable_test.rb | 9 +++++++++ test/models_test.rb | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/test/models/database_authenticatable_test.rb b/test/models/database_authenticatable_test.rb index b812fa74..7c3a5b67 100644 --- a/test/models/database_authenticatable_test.rb +++ b/test/models/database_authenticatable_test.rb @@ -120,6 +120,15 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase assert_match "can't be blank", user.errors[:current_password].join end + test 'should run validations even when current password is invalid or blank' do + user = UserWithValidation.create!(valid_attributes) + user.save + 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 + end + test 'should ignore password and its confirmation if they are blank' do user = create_user assert user.update_with_password(:current_password => '123456', :email => "new@example.com") diff --git a/test/models_test.rb b/test/models_test.rb index ad1d8e7d..30bb939f 100644 --- a/test/models_test.rb +++ b/test/models_test.rb @@ -10,6 +10,10 @@ class WithValidation < Admin devise :database_authenticatable, :validatable, :password_length => 2..6 end +class UserWithValidation < User + validates_presence_of :username +end + class Several < Admin devise :validatable devise :lockable