Merge pull request #21 from 5thWall/gravatar_hash

Updated email hash to Gravatar specifications
This commit is contained in:
Sam 2013-02-05 20:51:46 -08:00
commit d92a0e9b54
3 changed files with 2138 additions and 84 deletions

View file

@ -176,7 +176,7 @@ class User < ActiveRecord::Base
end
def self.email_hash(email)
Digest::MD5.hexdigest(email)
Digest::MD5.hexdigest(email.strip.downcase)
end
def email_hash

File diff suppressed because it is too large Load diff

View file

@ -291,6 +291,22 @@ describe User do
it 'should have a sane email hash' do
@user.email_hash.should =~ /^[0-9a-f]{32}$/
end
it 'should use downcase email' do
@user.email = "example@example.com"
@user2 = Fabricate(:user)
@user2.email = "ExAmPlE@eXaMpLe.com"
@user.email_hash.should == @user2.email_hash
end
it 'should trim whitespace before hashing' do
@user.email = "example@example.com"
@user2 = Fabricate(:user)
@user2.email = " example@example.com "
@user.email_hash.should == @user2.email_hash
end
end
describe 'name heuristics' do