Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

forced email to be downcase.

  • Loading branch information...
commit 25a32e2fe3d28434fcc5dea82d18ac256ecaa73c 1 parent 6b45973
@acconrad acconrad authored croaky committed
Showing with 7 additions and 2 deletions.
  1. +5 −0 lib/clearance/user.rb
  2. +2 −2 spec/models/user_spec.rb
View
5 lib/clearance/user.rb
@@ -66,6 +66,7 @@ module Callbacks
# salt, token, password encryption are handled before_save.
def self.included(model)
model.class_eval do
+ before_validation :downcase_email
before_save :initialize_salt,
:encrypt_password
before_create :generate_remember_token
@@ -176,6 +177,10 @@ def password_required?
# warn "[DEPRECATION] password_required?: use !password_optional? instead"
!password_optional?
end
+
+ def downcase_email
+ self.email = email.to_s.downcase
+ end
end
module ClassMethods
View
4 spec/models/user_spec.rb
@@ -55,9 +55,9 @@ def @user.initialize_salt; end
end
end
- it "should store email in exact case" do
+ it "should store email in down case" do
user = Factory(:user, :email => "John.Doe@example.com")
- user.email.should == "John.Doe@example.com"
+ user.email.should == "john.doe@example.com"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.