diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-02-13 17:02:06 +0100 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-02-13 18:04:53 +0100 |
commit | dd1d13b859c4c4cd7b6a64eb93f761c10c9262d4 (patch) | |
tree | 171ce3b968edd8b46d0b58b97248f815169d8ab3 /spec/helpers | |
parent | 6670074c0663be55f28de7cdb04a27432c7304f2 (diff) | |
download | gitlab-ce-dd1d13b859c4c4cd7b6a64eb93f761c10c9262d4.tar.gz |
Extract repeated logic into #avatar_icon_for.42800-change-usage-of-avatar_icon
This essentially allows to pass both user and email, so that we can
either prefer the user to retrieve the avatar or (if user is not
present) fall back to the email lookup.
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/application_helper_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 96bd4c96ae4..43cb0dfe163 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -63,6 +63,22 @@ describe ApplicationHelper do end end + describe 'avatar_icon_for' do + let!(:user) { create(:user, avatar: File.open(uploaded_image_temp_path), email: 'bar@example.com') } + let(:email) { 'foo@example.com' } + let!(:another_user) { create(:user, avatar: File.open(uploaded_image_temp_path), email: email) } + + it 'prefers the user to retrieve the avatar_url' do + expect(helper.avatar_icon_for(user, email).to_s) + .to eq(user.avatar.url) + end + + it 'falls back to email lookup if no user given' do + expect(helper.avatar_icon_for(nil, email).to_s) + .to eq(another_user.avatar.url) + end + end + describe 'avatar_icon_for_email' do let(:user) { create(:user, avatar: File.open(uploaded_image_temp_path)) } |