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
30576e75
Commit
30576e75
authored
Oct 06, 2021
by
Jason Goodman
Committed by
Etienne Baqué
Oct 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set New Subgroup Members to Awaiting if Root Group User Cap Reached
parent
934fa18b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
22 deletions
+33
-22
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+2
-2
ee/app/models/ee/member.rb
ee/app/models/ee/member.rb
+1
-1
ee/spec/models/ee/group_spec.rb
ee/spec/models/ee/group_spec.rb
+2
-1
ee/spec/models/member_spec.rb
ee/spec/models/member_spec.rb
+28
-18
No files found.
ee/app/models/ee/group.rb
View file @
30576e75
...
...
@@ -475,12 +475,12 @@ module EE
end
def
user_cap_reached?
(
requested_hosted_plan
=
nil
)
return
false
unless
::
Feature
.
enabled?
(
:saas_user_caps
,
self
,
default_enabled: :yaml
)
return
false
unless
::
Feature
.
enabled?
(
:saas_user_caps
,
root_ancestor
,
default_enabled: :yaml
)
user_cap
=
root_ancestor
.
namespace_settings
&
.
new_user_signups_cap
return
false
unless
user_cap
user_cap
<=
billable_members_count
(
requested_hosted_plan
)
user_cap
<=
root_ancestor
.
billable_members_count
(
requested_hosted_plan
)
end
private
...
...
ee/app/models/ee/member.rb
View file @
30576e75
...
...
@@ -143,7 +143,7 @@ module EE
end
def
set_membership_activation
return
unless
group
&&
::
Feature
.
enabled?
(
:saas_user_caps
,
group
,
default_enabled: :yaml
)
return
unless
group
&&
::
Feature
.
enabled?
(
:saas_user_caps
,
group
.
root_ancestor
,
default_enabled: :yaml
)
self
.
state
=
group
.
user_cap_reached?
?
STATE_AWAITING
:
STATE_ACTIVE
end
...
...
ee/spec/models/ee/group_spec.rb
View file @
30576e75
...
...
@@ -1518,7 +1518,8 @@ RSpec.describe Group do
let
(
:new_user_signups_cap
)
{
100
}
before
do
allow
(
group
).
to
receive
(
:billable_members_count
).
and_return
(
billable_members_count
)
allow
(
root_group
).
to
receive
(
:billable_members_count
).
and_return
(
billable_members_count
)
allow
(
group
).
to
receive
(
:root_ancestor
).
and_return
(
root_group
)
end
context
'when this cap is higher than the number of billable members'
do
...
...
ee/spec/models/member_spec.rb
View file @
30576e75
...
...
@@ -163,44 +163,48 @@ RSpec.describe Member, type: :model do
end
context
'check if user cap has been reached'
do
let_it_be
(
:group
)
{
create
(
:group_with_plan
,
plan: :ultimate_plan
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
group
)}
let_it_be
(
:group
,
refind:
true
)
do
create
(
:group_with_plan
,
plan: :ultimate_plan
,
namespace_settings:
create
(
:namespace_settings
,
new_user_signups_cap:
1
))
end
let!
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
,
namespace:
group
)}
let_it_be
(
:user
)
{
create
(
:user
)
}
subject
(
:add_user_to_group
)
{
group
.
add_developer
(
user
)
}
before_all
do
group
.
add_developer
(
create
(
:user
))
end
context
'when the :saas_user_caps feature flag is disabled'
do
before
do
stub_feature_flags
(
saas_user_caps:
false
)
end
it
'
leave
s the group member state to created'
do
add_user_to_group
it
'
set
s the group member state to created'
do
group
.
add_developer
(
user
)
expect
(
user
.
group_members
.
last
).
to
be_created
end
it
'
leave
s the project member state to created'
do
it
'
set
s the project member state to created'
do
project
.
add_developer
(
user
)
expect
(
user
.
project_members
.
last
).
to
be_created
end
end
context
'when the :saas_user_caps feature flag is enabled'
do
context
'when the :saas_user_caps feature flag is enabled
for the root group
'
do
before
do
stub_feature_flags
(
saas_user_caps:
group
)
allow
(
project
.
group
).
to
receive
(
:user_cap_reached?
).
and_return
(
user_cap_reached
)
allow
(
group
).
to
receive
(
:user_cap_reached?
).
and_return
(
user_cap_reached
)
end
context
'when the user cap for this group has not been reached'
do
let
(
:user_cap_reached
)
{
false
}
context
'when the user cap has not been reached'
do
before
do
group
.
namespace_settings
.
update!
(
new_user_signups_cap:
10
)
end
it
'sets the group member to active'
do
add_user_to_group
group
.
add_developer
(
user
)
expect
(
user
.
group_members
.
last
).
to
be_active
end
...
...
@@ -212,11 +216,17 @@ RSpec.describe Member, type: :model do
end
end
context
'when the user cap for this group has been reached'
do
let
(
:user_cap_reached
)
{
true
}
context
'when the user cap has been reached'
do
it
'sets the group member to awaiting'
do
add_user_to_group
group
.
add_developer
(
user
)
expect
(
user
.
group_members
.
last
).
to
be_awaiting
end
it
'sets the group member to awaiting when added to a subgroup'
do
subgroup
=
create
(
:group
,
parent:
group
)
subgroup
.
add_developer
(
user
)
expect
(
user
.
group_members
.
last
).
to
be_awaiting
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