Differentiate avatar between unconfirmed users with the same tmp username

private-asciicasts
Marcin Kulik 10 years ago
parent 45d1d6c18b
commit 9d6a01fa41

@ -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

@ -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

Loading…
Cancel
Save