From 9d6a01fa41f3741488df27ec37028d96aa466cf4 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 29 Nov 2014 12:26:11 +0000 Subject: [PATCH] Differentiate avatar between unconfirmed users with the same tmp username --- app/decorators/helpers/avatar_helper.rb | 4 ++-- spec/decorators/helpers/avatar_helper_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/decorators/helpers/avatar_helper.rb b/app/decorators/helpers/avatar_helper.rb index 254e78f..950c1d7 100644 --- a/app/decorators/helpers/avatar_helper.rb +++ b/app/decorators/helpers/avatar_helper.rb @@ -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 diff --git a/spec/decorators/helpers/avatar_helper_spec.rb b/spec/decorators/helpers/avatar_helper_spec.rb index a6f6b60..f4fab1a 100644 --- a/spec/decorators/helpers/avatar_helper_spec.rb +++ b/spec/decorators/helpers/avatar_helper_spec.rb @@ -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