Commit 874f40aa authored by Krasimir Angelov's avatar Krasimir Angelov

Change how we export email for seat usage data

to actually match the API endpoint - use `User#public_email`.

https://gitlab.com/gitlab-org/gitlab/-/issues/262877.
parent c4901d87
...@@ -44,7 +44,7 @@ module Groups ...@@ -44,7 +44,7 @@ module Groups
'Id' => 'id', 'Id' => 'id',
'Name' => 'name', 'Name' => 'name',
'Username' => 'username', 'Username' => 'username',
'Email' => -> (user) { user.email if user.managed_by?(current_user) }, 'Email' => -> (user) { user.public_email.presence },
'State' => 'state' 'State' => 'state'
} }
end end
......
...@@ -10,7 +10,7 @@ RSpec.describe Groups::SeatUsageExportService do ...@@ -10,7 +10,7 @@ RSpec.describe Groups::SeatUsageExportService do
subject(:result) { described_class.new(group, owner).execute } subject(:result) { described_class.new(group, owner).execute }
context 'when user is allowed to export seat usage data' do context 'when user is allowed to export seat usage data' do
let(:developer) { create(:user, name: 'Dev', username: 'dev', email: 'dev@example.org', state: 'active', managing_group: group) } let(:developer) { create(:user, name: 'Dev', username: 'dev', email: 'dev@example.org', state: 'active') }
let(:reporter) { create(:user, name: 'Reporter', username: 'reporter', state: 'active') } let(:reporter) { create(:user, name: 'Reporter', username: 'reporter', state: 'active') }
before do before do
...@@ -22,6 +22,9 @@ RSpec.describe Groups::SeatUsageExportService do ...@@ -22,6 +22,9 @@ RSpec.describe Groups::SeatUsageExportService do
context 'when group has members' do context 'when group has members' do
before do before do
public_email = create(:email, :confirmed, user: developer, email: 'public@email.org')
developer.update!(public_email: public_email.email)
group.add_developer(developer) group.add_developer(developer)
group.add_reporter(reporter) group.add_reporter(reporter)
end end
...@@ -30,7 +33,7 @@ RSpec.describe Groups::SeatUsageExportService do ...@@ -30,7 +33,7 @@ RSpec.describe Groups::SeatUsageExportService do
expect(payload).to eq([ expect(payload).to eq([
"Id,Name,Username,Email,State\n", "Id,Name,Username,Email,State\n",
"#{owner.id},Owner,owner,,active\n", "#{owner.id},Owner,owner,,active\n",
"#{developer.id},Dev,dev,dev@example.org,active\n", "#{developer.id},Dev,dev,public@email.org,active\n",
"#{reporter.id},Reporter,reporter,,active\n" "#{reporter.id},Reporter,reporter,,active\n"
]) ])
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