Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-13 19:02:06 +0300
committerAndreas Brandl <abrandl@gitlab.com>2018-02-13 20:04:53 +0300
commitdd1d13b859c4c4cd7b6a64eb93f761c10c9262d4 (patch)
tree171ce3b968edd8b46d0b58b97248f815169d8ab3 /spec/helpers/application_helper_spec.rb
parent6670074c0663be55f28de7cdb04a27432c7304f2 (diff)
Extract repeated logic into #avatar_icon_for.
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/application_helper_spec.rb')
-rw-r--r--spec/helpers/application_helper_spec.rb16
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)) }