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
e1ce8c0b
Commit
e1ce8c0b
authored
Jul 28, 2021
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed user_cap_reached? method in Group
Updated rspec accordingly.
parent
769e0a7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
24 deletions
+40
-24
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+4
-2
ee/spec/models/ee/group_spec.rb
ee/spec/models/ee/group_spec.rb
+36
-22
No files found.
ee/app/models/ee/group.rb
View file @
e1ce8c0b
...
...
@@ -476,9 +476,11 @@ module EE
def
user_cap_reached?
(
requested_hosted_plan
=
nil
)
return
false
unless
::
Feature
.
enabled?
(
:saas_user_caps
,
self
,
default_enabled: :yaml
)
return
false
unless
new_user_signups_cap
new_user_signups_cap
<=
billable_members_count
(
requested_hosted_plan
)
user_cap
=
root_ancestor
.
new_user_signups_cap
return
false
unless
user_cap
user_cap
<=
billable_members_count
(
requested_hosted_plan
)
end
private
...
...
ee/spec/models/ee/group_spec.rb
View file @
e1ce8c0b
...
...
@@ -1492,12 +1492,6 @@ RSpec.describe Group do
end
describe
'#user_cap_reached?'
do
let
(
:new_user_signups_cap
)
{
nil
}
before
do
allow
(
group
.
namespace_settings
).
to
receive
(
:new_user_signups_cap
).
and_return
(
new_user_signups_cap
)
end
subject
(
:user_cap_reached_for_group?
)
{
group
.
user_cap_reached?
}
context
'when the :saas_user_caps feature flag is not enabled'
do
...
...
@@ -1509,33 +1503,53 @@ RSpec.describe Group do
stub_feature_flags
(
saas_user_caps:
true
)
end
context
'when no user cap has been set'
do
it
{
is_expected
.
to
be_falsey
}
end
context
'when a user cap has been set'
do
let
(
:new_user_signups_cap
)
{
100
}
let
(
:new_user_signups_cap
)
{
nil
}
shared_context
'returning the right value for user_cap_reached?'
do
before
do
allow
(
group
).
to
receive
(
:billable_members_count
).
and_return
(
billable_members_count
)
root_group
.
namespace_settings
.
update!
(
new_user_signups_cap:
new_user_signups_cap
)
end
context
'when this cap is higher than the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
-
10
}
context
'when no user cap has been set to that root ancestor'
do
it
{
is_expected
.
to
be_falsey
}
end
context
'when this cap is the same as the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
}
context
'when a user cap has been set to that root ancestor'
do
let
(
:new_user_signups_cap
)
{
100
}
before
do
allow
(
group
).
to
receive
(
:billable_members_count
).
and_return
(
billable_members_count
)
end
context
'when this cap is higher than the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
-
10
}
it
{
is_expected
.
to
be_falsey
}
end
context
'when this cap is the same as the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
}
it
{
is_expected
.
to
be_truthy
}
end
it
{
is_expected
.
to
be_truthy
}
context
'when this cap is lower than the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
+
10
}
it
{
is_expected
.
to
be_truthy
}
end
end
end
context
'when this cap is lower than the number of billable members'
do
let
(
:billable_members_count
)
{
new_user_signups_cap
+
10
}
context
'when this group has no root ancestor'
do
it_behaves_like
'returning the right value for user_cap_reached?'
do
let
(
:root_group
)
{
group
}
end
end
it
{
is_expected
.
to
be_truthy
}
context
'when this group has a root ancestor'
do
it_behaves_like
'returning the right value for user_cap_reached?'
do
let
(
:root_group
)
{
create
(
:group
,
children:
[
group
])
}
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