Commit dbe84d92 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'exclude_bots_from_license_seat_usage' into 'master'

Exclude GitLab generated bot users from using a license seat

See merge request gitlab-org/gitlab!24275
parents 95edb274 762f5222
...@@ -275,7 +275,7 @@ module EE ...@@ -275,7 +275,7 @@ module EE
def using_license_seat? def using_license_seat?
return false unless active? return false unless active?
return false if support_bot? || ghost? return false if internal?
return false unless License.current return false unless License.current
if License.current.exclude_guests_from_active_count? if License.current.exclude_guests_from_active_count?
......
---
title: Exclude GitLab generated bot users from using a license seat
merge_request: 24275
author:
type: changed
...@@ -638,13 +638,22 @@ describe User do ...@@ -638,13 +638,22 @@ describe User do
end end
context 'when user is active' do context 'when user is active' do
context 'when user is a support bot' do context 'when user is internal' do
let(:user) { create(:user, bot_type: 'support_bot') } using RSpec::Parameterized::TableSyntax
where(:bot_type) do
User.bot_types.keys
end
with_them do
context 'when user is a bot' do
let(:user) { create(:user, bot_type: bot_type) }
it 'returns false' do it 'returns false' do
expect(user.using_license_seat?).to eq false expect(user.using_license_seat?).to eq false
end end
end end
end
context 'when user is a ghost' do context 'when user is a ghost' do
let(:user) { create(:user, ghost: true) } let(:user) { create(:user, ghost: true) }
...@@ -653,7 +662,9 @@ describe User do ...@@ -653,7 +662,9 @@ describe User do
expect(user.using_license_seat?).to eq false expect(user.using_license_seat?).to eq false
end end
end end
end
context 'when user is not internal' do
context 'when license is nil (core/free/default)' do context 'when license is nil (core/free/default)' do
before do before do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
...@@ -697,6 +708,7 @@ describe User do ...@@ -697,6 +708,7 @@ describe User do
end end
end end
end end
end
describe '#using_gitlab_com_seat?' do describe '#using_gitlab_com_seat?' do
let(:user) { create(:user) } let(:user) { create(:user) }
......
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