Commit 563e95e3 authored by Corinna Wiesner's avatar Corinna Wiesner

Show license badge in member overview

Show license badge in a group's member overview if current user is the
owner of the group
parent fe3981bf
......@@ -22,6 +22,8 @@
- if user == current_user
%span.badge.badge-success.prepend-left-5= _("It's you")
= render_if_exists 'shared/members/ee/license_badge', user: user, group: @group
- if user.blocked?
%label.badge.badge-danger
%strong= _("Blocked")
......
......@@ -284,6 +284,18 @@ module EE
end
end
def using_gitlab_com_seat?(namespace)
return false unless ::Gitlab.com?
return false unless namespace.present?
return false if namespace.free_plan?
if namespace.gold_plan?
highest_role > ::Gitlab::Access::GUEST
else
true
end
end
def group_sso?(group)
return false unless group
......
- if group.present? && group.has_owner?(current_user) && user.using_gitlab_com_seat?(group)
%span.badge.badge-light= _("Is using seat")
---
title: Show license badge for Gitlab.com member overview
merge_request: 23521
author:
type: added
......@@ -682,6 +682,76 @@ describe User do
end
end
describe '#using_gitlab_com_seat?' do
let(:user) { create(:user) }
context 'when Gitlab.com? is false' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
end
it 'returns false' do
expect(user.using_gitlab_com_seat?(nil)).to eq(false)
end
end
context 'when Gitlab.com? is true' do
let(:namespace) { create(:namespace) }
before do
allow(Gitlab).to receive(:com?).and_return(true)
allow(namespace).to receive(:gold_plan?).and_return(false)
allow(namespace).to receive(:free_plan?).and_return(false)
end
context 'when namespace is nil' do
let(:namespace) { nil }
it 'returns false' do
expect(user.using_gitlab_com_seat?(namespace)).to eq(false)
end
end
context 'when namespace is on a free plan' do
before do
allow(namespace).to receive(:free_plan?).and_return(true)
end
it 'returns false' do
expect(user.using_gitlab_com_seat?(namespace)).to eq(false)
end
end
context 'when namespace is on a gold plan' do
before do
allow(namespace).to receive(:gold_plan?).and_return(true)
end
context 'user is not a guest' do
let(:user) { create(:project_member, :developer).user }
it 'returns true' do
expect(user.using_gitlab_com_seat?(namespace)).to eq(true)
end
end
context 'user is guest' do
let(:user) { create(:project_member, :guest).user }
it 'returns false' do
expect(user.using_gitlab_com_seat?(namespace)).to eq(false)
end
end
end
context 'when namespace is on a plan that is not free or gold' do
it 'returns true' do
expect(user.using_gitlab_com_seat?(namespace)).to eq(true)
end
end
end
end
describe '.username_suggestion' do
context 'namespace with input name does not exist' do
let(:name) { 'Arthur Morgan' }
......
......@@ -10329,6 +10329,9 @@ msgstr ""
msgid "Is using license seat:"
msgstr ""
msgid "Is using seat"
msgstr ""
msgid "IssuableStatus|Closed"
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