Commit ccc215e9 authored by James Lopez's avatar James Lopez

Merge branch 'add_is_using_seat_badge_to_users_overview' into 'master'

Add Is using seat badge to admin user overview

See merge request gitlab-org/gitlab!21497
parents 473d9e3d e1dcf71a
......@@ -10,6 +10,16 @@ module EE
new_trial_registration_path
end
def user_badges_in_admin_section(user)
super(user).tap do |badges|
if user.using_license_seat?
it_s_you_index = badges.index { |badge| badge[:text] == "It's you!" } || -1
badges.insert(it_s_you_index, { text: s_('AdminUsers|Is using seat'), variant: 'light' })
end
end
end
private
def trials_allowed?(user)
......
......@@ -3,9 +3,9 @@
require 'spec_helper'
describe UsersHelper do
describe '#current_user_menu_items' do
let(:user) { create(:user) }
let(:user) { create(:user) }
describe '#current_user_menu_items' do
using RSpec::Parameterized::TableSyntax
where(
......@@ -32,4 +32,45 @@ describe UsersHelper do
it { is_expected.to eq(expected_result) }
end
end
describe '#user_badges_in_admin_section' do
subject { helper.user_badges_in_admin_section(user) }
before do
allow(helper).to receive(:current_user).and_return(build(:user))
end
context 'with user who is using a license seat' do
before do
allow(user).to receive(:using_license_seat?).and_return(true)
end
context 'when user is an admin and the current_user' do
before do
allow(helper).to receive(:current_user).and_return(user)
allow(user).to receive(:admin?).and_return(true)
end
it do
expect(subject).to eq(
[
{ text: 'Admin', variant: 'success' },
{ text: 'Is using seat', variant: 'light' },
{ text: "It's you!", variant: nil }
]
)
end
end
it { expect(subject).to eq([text: 'Is using seat', variant: 'light']) }
end
context 'with user who is not using a license seat' do
before do
allow(user).to receive(:using_license_seat?).and_return(false)
end
it { expect(subject).to eq([]) }
end
end
end
......@@ -1350,6 +1350,9 @@ msgstr ""
msgid "AdminUsers|External"
msgstr ""
msgid "AdminUsers|Is using seat"
msgstr ""
msgid "AdminUsers|It's you!"
msgstr ""
......
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