diff options
Diffstat (limited to 'activemodel/test/cases/secure_password_test.rb')
-rw-r--r-- | activemodel/test/cases/secure_password_test.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index e59f00c8c5..6d56c8344a 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -20,15 +20,12 @@ class SecurePasswordTest < ActiveModel::TestCase ActiveModel::SecurePassword.min_cost = @original_min_cost end - test "create/update without validations" do - assert @visitor.valid?(:create), 'visitor should be valid' - assert @visitor.valid?(:update), 'visitor should be valid' - - @visitor.password = '123' - @visitor.password_confirmation = '456' + test "automatically include ActiveModel::Validations when validations are enabled" do + assert_respond_to @user, :valid? + end - assert @visitor.valid?(:create), 'visitor should be valid' - assert @visitor.valid?(:update), 'visitor should be valid' + test "don't include ActiveModel::Validations when validations are disabled" do + assert_not_respond_to @visitor, :valid? end test "create a new user with validations and valid password/confirmation" do @@ -43,6 +40,11 @@ class SecurePasswordTest < ActiveModel::TestCase assert @user.valid?(:create), 'user should be valid' end + test "create a new user with validation and a spaces only password" do + @user.password = ' ' * 72 + assert @user.valid?(:create), 'user should be valid' + end + test "create a new user with validation and a blank password" do @user.password = '' assert !@user.valid?(:create), 'user should be invalid' @@ -108,6 +110,11 @@ class SecurePasswordTest < ActiveModel::TestCase assert @existing_user.valid?(:update), 'user should be valid' end + test "updating an existing user with validation and a spaces only password" do + @user.password = ' ' * 72 + assert @user.valid?(:update), 'user should be valid' + end + test "updating an existing user with validation and a blank password and password_confirmation" do @existing_user.password = '' @existing_user.password_confirmation = '' |