Commit 57646f34 authored by Vijay Hawoldar's avatar Vijay Hawoldar Committed by Douglas Barbosa Alexandre

Adding new entity for billable members

When viewing billable members, their email should be
visibile if they have selected a public email in their
profile
parent 281fda79
......@@ -67,7 +67,7 @@ export default {
},
avatarSize: AVATAR_SIZE,
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>
......
---
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
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
......
......@@ -34,7 +34,7 @@ Array [
},
Object {
"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 {
"avatarLabeled": Object {
"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
group.add_owner(owner)
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
let(:emails) { gma_member.email }
context 'when members have a public_email' do
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
it_behaves_like 'members response with hidden emails' do
let(:emails) { member.email }
context 'when members have no public_email' do
it { is_expected.to include(a_hash_including('email' => '')) }
end
end
end
......
......@@ -4478,7 +4478,7 @@ msgstr ""
msgid "BillingPlan|Upgrade"
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 ""
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