Differentiate avatar between unconfirmed users with the same tmp username

This commit is contained in:
Marcin Kulik 2014-11-29 12:26:11 +00:00
parent 45d1d6c18b
commit 9d6a01fa41
2 changed files with 4 additions and 4 deletions

View File

@ -7,8 +7,8 @@ module AvatarHelper
private
def avatar_url
username = model.username || model.temporary_username || model.id
email = model.email || "#{username}@asciinema.org"
username = model.username || model.temporary_username
email = model.email || "#{username}+#{model.id}@asciinema.org"
hash = Digest::MD5.hexdigest(email.downcase)
"//gravatar.com/avatar/#{hash}?s=128&d=retro"
end

View File

@ -8,7 +8,7 @@ describe AvatarHelper do
let(:decorator) { double('decorator', h: h, model: model).
extend(described_class) }
let(:model) { double('model', username: 'satyr', email: email) }
let(:model) { double('model', id: 1, username: 'satyr', email: email) }
describe '#avatar_image_tag' do
subject { decorator.avatar_image_tag }
@ -24,7 +24,7 @@ describe AvatarHelper do
let(:email) { nil }
it { should eq(expected_img(
'//gravatar.com/avatar/9c0388ed63799af1e5f588e610851f0c?s=128&d=retro')) }
'//gravatar.com/avatar/40affe80f7becd02ac38d316f7fe7057?s=128&d=retro')) }
end
end