Commit c3a7f364 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'vij-billable-members-entity' into 'master'

Use public email for seat usage group members

See merge request gitlab-org/gitlab!50290
parents ab3b75de 57646f34
...@@ -67,7 +67,7 @@ export default { ...@@ -67,7 +67,7 @@ export default {
}, },
avatarSize: AVATAR_SIZE, avatarSize: AVATAR_SIZE,
emailNotVisibleTooltipText: s__( emailNotVisibleTooltipText: s__(
'Billing|An email address is only visible for users managed through Group Managed Accounts.', 'Billing|An email address is only visible for users with public emails.',
), ),
}; };
</script> </script>
......
---
title: Display public emails for billable members
merge_request: 50290
author:
type: changed
# frozen_string_literal: true
module EE
module API
module Entities
class BillableMember < ::API::Entities::UserBasic
expose :public_email, as: :email
end
end
end
end
...@@ -63,7 +63,7 @@ module EE ...@@ -63,7 +63,7 @@ module EE
order_by: sorting).execute order_by: sorting).execute
) )
present users, with: ::API::Entities::UserBasic, current_user: current_user present users, with: ::EE::API::Entities::BillableMember, current_user: current_user
end end
end end
end end
......
...@@ -34,7 +34,7 @@ Array [ ...@@ -34,7 +34,7 @@ Array [
}, },
Object { Object {
"email": "Private", "email": "Private",
"tooltip": "An email address is only visible for users managed through Group Managed Accounts.", "tooltip": "An email address is only visible for users with public emails.",
"user": Object { "user": Object {
"avatarLabeled": Object { "avatarLabeled": Object {
"size": "32", "size": "32",
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::EE::API::Entities::BillableMember do
let(:member) { build(:user, public_email: public_email, email: 'private@email.com') }
subject(:entity_representation) { described_class.new(member).as_json }
context 'when the user has a public_email assigned' do
let(:public_email) { 'public@email.com' }
it 'exposes public_email instead of email' do
aggregate_failures do
expect(entity_representation.keys).to include(:email)
expect(entity_representation[:email]).to eq public_email
expect(entity_representation[:email]).not_to eq member.email
end
end
end
context 'when the user has no public_email assigned' do
let(:public_email) { nil }
it 'returns a nil value for email' do
aggregate_failures do
expect(entity_representation.keys).to include(:email)
expect(entity_representation[:email]).to be nil
end
end
end
end
...@@ -484,14 +484,20 @@ RSpec.describe API::Members do ...@@ -484,14 +484,20 @@ RSpec.describe API::Members do
group.add_owner(owner) group.add_owner(owner)
end end
include_context "group managed account with group members" include_context 'group managed account with group members'
it_behaves_like 'members response with exposed emails' do context 'when members have a public_email' do
let(:emails) { gma_member.email } before do
allow_next_found_instance_of(User) do |instance|
allow(instance).to receive(:public_email).and_return('public@email.com')
end
end
it { is_expected.to include(a_hash_including('email' => 'public@email.com')) }
end end
it_behaves_like 'members response with hidden emails' do context 'when members have no public_email' do
let(:emails) { member.email } it { is_expected.to include(a_hash_including('email' => '')) }
end end
end end
end end
......
...@@ -4478,7 +4478,7 @@ msgstr "" ...@@ -4478,7 +4478,7 @@ msgstr ""
msgid "BillingPlan|Upgrade" msgid "BillingPlan|Upgrade"
msgstr "" msgstr ""
msgid "Billing|An email address is only visible for users managed through Group Managed Accounts." msgid "Billing|An email address is only visible for users with public emails."
msgstr "" msgstr ""
msgid "Billing|An error occurred while loading billable members list" msgid "Billing|An error occurred while loading billable members list"
......
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