diff options
author | Nick Thomas <nick@gitlab.com> | 2019-08-29 21:56:25 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-08-29 21:56:25 +0300 |
commit | e31e4aeb8c6b2f0df8f1c8fde059b5d93138b785 (patch) | |
tree | cc983a70cc8417c546d2a21e3d20518688341c4d | |
parent | 5db02773f7dcd5638d7797cd39cf9cd70b03abfd (diff) | |
parent | cc704112b39660ca12a0dc3faee81fdedb6f24cf (diff) |
Merge branch 'patch-git-private-email-instruction' into 'master'
fix: show preferred commit email in empty project page
See merge request gitlab-org/gitlab-ce!32182
-rw-r--r-- | app/helpers/projects_helper.rb | 2 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 33bf2d57fae..14f947a03a3 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -448,7 +448,7 @@ module ProjectsHelper def git_user_email if current_user - current_user.email + current_user.commit_email else "your@email.com" end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 29c43d1977e..d2a4ce6540d 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -549,6 +549,42 @@ describe ProjectsHelper do end end + describe '#git_user_email' do + context 'not logged-in' do + before do + allow(helper).to receive(:current_user).and_return(nil) + end + + it 'returns your@email.com' do + expect(helper.send(:git_user_email)).to eq('your@email.com') + end + end + + context 'user logged in' do + let(:user) { create(:user) } + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'user has no configured commit email' do + it 'returns the primary email' do + expect(helper.send(:git_user_email)).to eq(user.email) + end + end + + context 'user has a configured commit email' do + before do + confirmed_email = create(:email, :confirmed, user: user) + user.update(commit_email: confirmed_email) + end + + it 'returns the commit email' do + expect(helper.send(:git_user_email)).to eq(user.commit_email) + end + end + end + end + describe 'show_xcode_link' do let!(:project) { create(:project) } let(:mac_ua) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' } |