Commit 5a56f514 authored by Max Woolf's avatar Max Woolf

Create specific CE display_public_email? user helper

FOSS was failing because of calling display_public_email?
which did not exist in CE. This adds a CE specific helper
method to avoid failures.

Changelog: fixed
parent 60af5d34
......@@ -173,10 +173,7 @@ module UsersHelper
end
def display_public_email?(user)
return false if user.public_email.blank?
return true unless user.provisioned_by_group
!Feature.enabled?(:hide_public_email_on_profile, user.provisioned_by_group)
user.public_email.present?
end
private
......
......@@ -2,6 +2,16 @@
module EE
module UsersHelper
extend ::Gitlab::Utils::Override
override :display_public_email?
def display_public_email?(user)
return false if user.public_email.blank?
return true unless user.provisioned_by_group
!::Feature.enabled?(:hide_public_email_on_profile, user.provisioned_by_group)
end
def users_sentence(users, link_class: nil)
users.map { |user| link_to(user.name, user, class: link_class) }.to_sentence.html_safe
end
......
......@@ -10,11 +10,11 @@ RSpec.describe UserDetail do
subject { user.user_detail.provisioned_by_group? }
it 'returns true when user is provisoned by group' do
it 'returns true when user is provisioned by group' do
expect(subject).to eq(true)
end
it 'returns true when user is provisoned by group' do
it 'returns true when user is provisioned by group' do
user.user_detail.update!(provisioned_by_group: nil)
expect(subject).to eq(false)
......
......@@ -11,6 +11,20 @@ RSpec.describe UsersHelper do
badges.reject { |badge| badge[:text] == 'Is using seat' }
end
describe 'display_public_email?' do
let_it_be(:user) { create(:user, :public_email) }
subject { helper.display_public_email?(user) }
it { is_expected.to be true }
context 'when user public email is blank' do
let_it_be(:user) { create(:user, public_email: '') }
it { is_expected.to be false }
end
end
describe '#user_link' do
subject { helper.user_link(user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment