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
5aadf831
Commit
5aadf831
authored
Mar 04, 2020
by
Shreyas Agarwal
Committed by
Michael Kozono
Mar 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Use dev or com instead of just Gitlab.com"
This reverts commit 107cfee2354c06f60f93e6cd1601d18768a0731f.
parent
ec23ba88
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
12 deletions
+57
-12
ee/app/models/ee/member.rb
ee/app/models/ee/member.rb
+11
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+10
-9
ee/changelogs/unreleased/207120-the-api-for-group-members-returns-true-for-is_using_seat-even-w.yml
...r-group-members-returns-true-for-is_using_seat-even-w.yml
+5
-0
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+1
-3
ee/spec/models/member_spec.rb
ee/spec/models/member_spec.rb
+30
-0
No files found.
ee/app/models/ee/member.rb
View file @
5aadf831
...
...
@@ -33,5 +33,16 @@ module EE
errors
.
add
(
:user
,
'is not linked to a SAML account'
)
end
end
# The method is exposed in the API as is_using_seat
# in ee/lib/ee/api/entities.rb
#
# rubocop: disable Naming/PredicateName
def
is_using_seat
return
user
.
using_gitlab_com_seat?
(
source
)
if
::
Gitlab
.
com?
user
.
using_license_seat?
end
# rubocop: enable Naming/PredicateName
end
end
ee/app/models/ee/user.rb
View file @
5aadf831
...
...
@@ -250,15 +250,10 @@ module EE
end
def
using_license_seat?
return
false
unless
active?
return
false
if
internal?
return
false
unless
License
.
current
if
License
.
current
.
exclude_guests_from_active_count?
highest_role
>
::
Gitlab
::
Access
::
GUEST
else
true
end
active?
&&
!
internal?
&&
has_current_license?
&&
paid_in_current_license?
end
def
using_gitlab_com_seat?
(
namespace
)
...
...
@@ -353,5 +348,11 @@ module EE
reporter_developer_maintainer_owned_groups
.
select
(
select
).
where
(
parent_id:
nil
)
]).
to_sql
end
def
paid_in_current_license?
return
true
unless
License
.
current
.
exclude_guests_from_active_count?
highest_role
>
::
Gitlab
::
Access
::
GUEST
end
end
end
ee/changelogs/unreleased/207120-the-api-for-group-members-returns-true-for-is_using_seat-even-w.yml
0 → 100644
View file @
5aadf831
---
title
:
API for Namespace members has correct boolean if user using paid seat
merge_request
:
25988
author
:
type
:
fixed
ee/lib/ee/api/entities.rb
View file @
5aadf831
...
...
@@ -93,9 +93,7 @@ module EE
expose
:group_saml_identity
,
using:
::
API
::
Entities
::
Identity
,
if:
->
(
member
,
options
)
{
Ability
.
allowed?
(
options
[
:current_user
],
:read_group_saml_identity
,
member
.
source
)
}
expose
:is_using_seat
,
if:
->
(
member
,
options
)
{
options
[
:show_seat_info
]
}
do
|
member
,
_options
|
!!
member
.
user
&
.
using_license_seat?
end
expose
:is_using_seat
,
if:
->
(
_
,
options
)
{
options
[
:show_seat_info
]
}
end
end
...
...
ee/spec/models/member_spec.rb
View file @
5aadf831
...
...
@@ -13,4 +13,34 @@ describe Member, type: :model do
.
to
be_instance_of
(
::
EE
::
NullNotificationService
)
end
end
describe
'#is_using_seat'
,
:aggregate_failures
do
let
(
:user
)
{
build
:user
}
let
(
:group
)
{
create
:group
}
let
(
:member
)
{
build
:group_member
,
group:
group
,
user:
user
}
context
'when hosted on GL.com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
true
end
it
'calls users check for using the gitlab_com seat method'
do
expect
(
user
).
to
receive
(
:using_gitlab_com_seat?
).
with
(
group
).
once
.
and_return
true
expect
(
user
).
not_to
receive
(
:using_license_seat?
)
expect
(
member
.
is_using_seat
).
to
be_truthy
end
end
context
'when not hosted on GL.com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
false
end
it
'calls users check for using the License seat method'
do
expect
(
user
).
to
receive
(
:using_license_seat?
).
with
(
no_args
).
and_return
true
expect
(
user
).
not_to
receive
(
:using_gitlab_com_seat?
)
expect
(
member
.
is_using_seat
).
to
be_truthy
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