Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
762f5222
Commit
762f5222
authored
Feb 03, 2020
by
Corinna Wiesner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude bot users from using a license seat
GitLab generated bot users do not use license seat.
parent
e01f24f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
36 deletions
+53
-36
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+1
-1
ee/changelogs/unreleased/exclude_bots_from_license_seat_usage.yml
...elogs/unreleased/exclude_bots_from_license_seat_usage.yml
+5
-0
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+47
-35
No files found.
ee/app/models/ee/user.rb
View file @
762f5222
...
...
@@ -275,7 +275,7 @@ module EE
def
using_license_seat?
return
false
unless
active?
return
false
if
support_bot?
||
ghost
?
return
false
if
internal
?
return
false
unless
License
.
current
if
License
.
current
.
exclude_guests_from_active_count?
...
...
ee/changelogs/unreleased/exclude_bots_from_license_seat_usage.yml
0 → 100644
View file @
762f5222
---
title
:
Exclude GitLab generated bot users from using a license seat
merge_request
:
24275
author
:
type
:
changed
ee/spec/models/user_spec.rb
View file @
762f5222
...
...
@@ -638,61 +638,73 @@ describe User do
end
context
'when user is active'
do
context
'when user is
a support bot
'
do
let
(
:user
)
{
create
(
:user
,
bot_type:
'support_bot'
)
}
context
'when user is
internal
'
do
using
RSpec
::
Parameterized
::
TableSyntax
it
'returns false'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
where
(
:bot_type
)
do
User
.
bot_types
.
keys
end
end
context
'when user is a ghost'
do
let
(
:user
)
{
create
(
:user
,
ghost:
true
)
}
with_them
do
context
'when user is a bot'
do
let
(
:user
)
{
create
(
:user
,
bot_type:
bot_type
)
}
it
'returns false'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
it
'returns false'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
end
end
end
end
context
'when license is nil (core/free/default)'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
context
'when user is a ghost'
do
let
(
:user
)
{
create
(
:user
,
ghost:
true
)
}
it
'returns false if license is nil (core/free/default)'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
it
'returns false'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
end
end
end
context
'
user is guest
'
do
let
(
:project_guest_user
)
{
create
(
:project_member
,
:guest
).
user
}
it
'returns false if license is ultimate'
do
create
(
:license
,
plan:
License
::
ULTIMATE_PLAN
)
context
'
when user is not internal
'
do
context
'when license is nil (core/free/default)'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
expect
(
project_guest_user
.
using_license_seat?
).
to
eq
false
it
'returns false if license is nil (core/free/default)'
do
expect
(
user
.
using_license_seat?
).
to
eq
false
end
end
it
'returns true if license is not ultimate and not nil
'
do
create
(
:license
,
plan:
License
::
STARTER_PLAN
)
context
'user is guest
'
do
let
(
:project_guest_user
)
{
create
(
:project_member
,
:guest
).
user
}
expect
(
project_guest_user
.
using_license_seat?
).
to
eq
true
end
end
it
'returns false if license is ultimate'
do
create
(
:license
,
plan:
License
::
ULTIMATE_PLAN
)
context
'user is admin without projects'
do
let
(
:user
)
{
create
(
:user
,
admin:
true
)
}
expect
(
project_guest_user
.
using_license_seat?
).
to
eq
false
end
it
'returns false if license is ultimate
'
do
create
(
:license
,
plan:
License
::
ULTIMATE
_PLAN
)
it
'returns true if license is not ultimate and not nil
'
do
create
(
:license
,
plan:
License
::
STARTER
_PLAN
)
expect
(
user
.
using_license_seat?
).
to
eq
false
expect
(
project_guest_user
.
using_license_seat?
).
to
eq
true
end
end
it
'returns true if license is not ultimate and not nil'
do
create
(
:license
,
plan:
License
::
STARTER_PLAN
)
context
'user is admin without projects'
do
let
(
:user
)
{
create
(
:user
,
admin:
true
)
}
it
'returns false if license is ultimate'
do
create
(
:license
,
plan:
License
::
ULTIMATE_PLAN
)
expect
(
user
.
using_license_seat?
).
to
eq
false
end
it
'returns true if license is not ultimate and not nil'
do
create
(
:license
,
plan:
License
::
STARTER_PLAN
)
expect
(
user
.
using_license_seat?
).
to
eq
true
expect
(
user
.
using_license_seat?
).
to
eq
true
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment