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
3752f6d0
Commit
3752f6d0
authored
Aug 26, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename seat calculation methods
to free up method names for to-be-added attributes
parent
b63f1584
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
ee/app/models/gitlab_subscription.rb
ee/app/models/gitlab_subscription.rb
+2
-2
ee/app/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker.rb
...ate_max_seats_used_for_gitlab_com_subscriptions_worker.rb
+1
-1
ee/lib/ee/api/entities/gitlab_subscription.rb
ee/lib/ee/api/entities/gitlab_subscription.rb
+2
-2
ee/spec/models/gitlab_subscription_spec.rb
ee/spec/models/gitlab_subscription_spec.rb
+11
-11
No files found.
ee/app/models/gitlab_subscription.rb
View file @
3752f6d0
...
...
@@ -42,7 +42,7 @@ class GitlabSubscription < ApplicationRecord
end
end
def
seats_in_use
def
calculate_
seats_in_use
namespace
.
billable_members_count
end
...
...
@@ -50,7 +50,7 @@ class GitlabSubscription < ApplicationRecord
# with the historical max. We want to know how many extra users the customer
# has added to their group (users above the number purchased on their subscription).
# Then, on the next month we're going to automatically charge the customers for those extra users.
def
seats_owed
def
calculate_
seats_owed
return
0
unless
has_a_paid_hosted_plan?
[
0
,
max_seats_used
-
seats
].
max
...
...
ee/app/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker.rb
View file @
3752f6d0
...
...
@@ -16,7 +16,7 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker # rubocop:disable Scalab
tuples
=
[]
subscriptions
.
each
do
|
subscription
|
seats_in_use
=
subscription
.
seats_in_use
seats_in_use
=
subscription
.
calculate_
seats_in_use
next
if
subscription
.
max_seats_used
>=
seats_in_use
...
...
ee/lib/ee/api/entities/gitlab_subscription.rb
View file @
3752f6d0
...
...
@@ -14,9 +14,9 @@ module EE
expose
:usage
do
expose
:seats
,
as: :seats_in_subscription
expose
:seats_in_use
expose
:
calculate_seats_in_use
,
as: :
seats_in_use
expose
:max_seats_used
expose
:seats_owed
expose
:
calculate_seats_owed
,
as: :
seats_owed
end
expose
:billing
do
...
...
ee/spec/models/gitlab_subscription_spec.rb
View file @
3752f6d0
...
...
@@ -53,7 +53,7 @@ RSpec.describe GitlabSubscription do
end
end
describe
'#seats_in_use'
do
describe
'#
calculate_
seats_in_use'
do
let!
(
:user_1
)
{
create
(
:user
)
}
let!
(
:user_2
)
{
create
(
:user
)
}
let!
(
:blocked_user
)
{
create
(
:user
,
:blocked
)
}
...
...
@@ -68,14 +68,14 @@ RSpec.describe GitlabSubscription do
it
'returns count of members'
do
group
.
add_developer
(
user_1
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
1
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
1
)
end
it
'also counts users from subgroups'
do
group
.
add_developer
(
user_1
)
subgroup_1
.
add_developer
(
user_2
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
2
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
2
)
end
it
'does not count duplicated members'
do
...
...
@@ -83,7 +83,7 @@ RSpec.describe GitlabSubscription do
subgroup_1
.
add_developer
(
user_2
)
subgroup_2
.
add_developer
(
user_2
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
2
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
2
)
end
it
'does not count blocked members'
do
...
...
@@ -91,7 +91,7 @@ RSpec.describe GitlabSubscription do
group
.
add_developer
(
blocked_user
)
expect
(
group
.
member_count
).
to
eq
(
2
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
1
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
1
)
end
context
'with guest members'
do
...
...
@@ -103,7 +103,7 @@ RSpec.describe GitlabSubscription do
it
'excludes these members'
do
gitlab_subscription
.
update!
(
plan_code:
'gold'
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
0
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
0
)
end
end
...
...
@@ -112,7 +112,7 @@ RSpec.describe GitlabSubscription do
it
'excludes these members'
do
gitlab_subscription
.
update!
(
plan_code:
plan
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
1
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
1
)
end
end
end
...
...
@@ -130,13 +130,13 @@ RSpec.describe GitlabSubscription do
[
bronze_plan
,
silver_plan
,
gold_plan
].
each
do
|
plan
|
gitlab_subscription
.
update!
(
hosted_plan:
plan
)
expect
(
gitlab_subscription
.
seats_in_use
).
to
eq
(
1
)
expect
(
gitlab_subscription
.
calculate_
seats_in_use
).
to
eq
(
1
)
end
end
end
end
describe
'#seats_owed'
do
describe
'#
calculate_
seats_owed'
do
let!
(
:gitlab_subscription
)
{
create
(
:gitlab_subscription
,
subscription_attrs
)
}
before
do
...
...
@@ -145,7 +145,7 @@ RSpec.describe GitlabSubscription do
shared_examples
'always returns a total of 0'
do
it
'does not update max_seats_used'
do
expect
(
gitlab_subscription
.
seats_owed
).
to
eq
(
0
)
expect
(
gitlab_subscription
.
calculate_
seats_owed
).
to
eq
(
0
)
end
end
...
...
@@ -171,7 +171,7 @@ RSpec.describe GitlabSubscription do
let
(
:subscription_attrs
)
{
{
hosted_plan:
bronze_plan
}
}
it
'calculates the number of owed seats'
do
expect
(
gitlab_subscription
.
reload
.
seats_owed
).
to
eq
(
5
)
expect
(
gitlab_subscription
.
reload
.
calculate_
seats_owed
).
to
eq
(
5
)
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