Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding test for blank password confirmation

  • Loading branch information...
commit 884eadde87fd558a2e9ae2de54eb2758914085a8 1 parent bf2fb32
@croaky croaky authored
Showing with 10 additions and 2 deletions.
  1. +3 −2 lib/clearance/user.rb
  2. +7 −0 test/models/user_test.rb
View
5 lib/clearance/user.rb
@@ -12,11 +12,12 @@ def self.included(model)
attr_accessor :password, :password_confirmation
validates_presence_of :email
- validates_presence_of :password, :if => :password_required?
- validates_confirmation_of :password, :if => :password_required?
validates_uniqueness_of :email, :case_sensitive => false
validates_format_of :email, :with => %r{.+@.+\..+}
+ validates_presence_of :password, :if => :password_required?
+ validates_confirmation_of :password, :if => :password_required?
+
before_save :initialize_salt, :encrypt_password, :initialize_token
end
end
View
7 test/models/user_test.rb
@@ -21,6 +21,13 @@ class UserTest < ActiveSupport::TestCase
assert user.errors.on(:password)
end
+ should "require non blank password confirmation on create" do
+ user = Factory.build(:user, :password => 'blah',
+ :password_confirmation => '')
+ assert ! user.save
+ assert user.errors.on(:password)
+ end
+
should "initialize salt" do
assert_not_nil Factory(:user).salt
end
Please sign in to comment.
Something went wrong with that request. Please try again.