Commit 1ba3d52a authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch 'ap-hide-public-email' into 'master'

Selectively hide public email on profile page

See merge request gitlab-org/gitlab!79717
parents 40ae45a9 2233df34
......@@ -172,6 +172,13 @@ 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)
end
private
def admin_users_paths
......
......@@ -112,7 +112,7 @@
- if Feature.enabled?(:security_auto_fix) && @user.bot?
= sprite_icon('question', css_class: 'gl-text-blue-600')
= link_to @user.short_website_url, @user.full_website_url, target: '_blank', rel: 'me noopener noreferrer nofollow', itemprop: 'url'
- unless @user.public_email.blank?
- if display_public_email?(@user)
= render 'middle_dot_divider', stacking: true do
= link_to @user.public_email, "mailto:#{@user.public_email}", itemprop: 'email'
.gl-text-gray-900
......
---
name: hide_public_email_on_profile
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79717
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/351731
milestone: '14.8'
type: development
group: group::optimize
default_enabled: false
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User visits public profile' do
context 'when user profile is provisioned by group' do
let_it_be(:group) { create(:group) }
let_it_be(:scim_identity) { create(:scim_identity, group: group) }
let_it_be(:user) { create(:user, :public_email, provisioned_by_group_id: scim_identity.group.id) }
it 'hide public_email' do
visit(user_path(user))
expect(page).not_to have_content user.public_email
end
context 'when hide_public_email_on_profile feature flag is disabled' do
before do
stub_feature_flags(hide_public_email_on_profile: false)
end
it 'displays public_email' do
visit(user_path(user))
expect(page).to have_content user.public_email
end
end
end
end
......@@ -104,4 +104,43 @@ RSpec.describe UsersHelper do
end
end
end
describe '#display_public_email?' do
let_it_be(:group) { create(:group) }
let_it_be(:scim_identity) { create(:scim_identity, group: group) }
let(:user) { create(:user, :public_email, provisioned_by_group: scim_identity.group) }
subject { helper.display_public_email?(user) }
before do
stub_feature_flags hide_public_email_on_profile: false
end
it { is_expected.to be true }
context 'when public_email is blank' do
before do
user.update!(public_email: '')
end
it { is_expected.to be false }
end
context 'when provisioned_by_group is nil' do
before do
user.update!(provisioned_by_group: nil)
end
it { is_expected.to be true }
end
context 'when hide_public_email_on_profile is true' do
before do
stub_feature_flags hide_public_email_on_profile: true
end
it { is_expected.to be false }
end
end
end
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