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
f7af9f81
Commit
f7af9f81
authored
Feb 16, 2021
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added/Replaced plan constants with new ones
Added/Replaced plan constants with new ones
parent
fa0da1ee
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
224 additions
and
179 deletions
+224
-179
ee/app/helpers/billing_plans_helper.rb
ee/app/helpers/billing_plans_helper.rb
+1
-1
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+4
-4
ee/app/models/ee/namespace.rb
ee/app/models/ee/namespace.rb
+13
-5
ee/app/models/ee/plan.rb
ee/app/models/ee/plan.rb
+3
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+2
-2
ee/app/models/gitlab_subscription.rb
ee/app/models/gitlab_subscription.rb
+2
-0
ee/spec/factories/gitlab_subscriptions.rb
ee/spec/factories/gitlab_subscriptions.rb
+8
-0
ee/spec/helpers/ee/user_callouts_helper_spec.rb
ee/spec/helpers/ee/user_callouts_helper_spec.rb
+9
-7
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
+160
-150
ee/spec/models/ee/namespace_spec.rb
ee/spec/models/ee/namespace_spec.rb
+22
-9
No files found.
ee/app/helpers/billing_plans_helper.rb
View file @
f7af9f81
...
...
@@ -85,7 +85,7 @@ module BillingPlansHelper
end
def
show_plans?
(
namespace
)
namespace
.
trial_active?
||
!
namespace
.
gold_plan?
namespace
.
trial_active?
||
!
(
namespace
.
gold_plan?
||
namespace
.
ultimate_plan?
)
end
def
show_trial_banner?
(
namespace
)
...
...
ee/app/models/ee/group.rb
View file @
f7af9f81
...
...
@@ -290,21 +290,21 @@ module EE
end
# For now, we are not billing for members with a Guest role for subscriptions
# with a Gold plan. The other plans will treat Guest members as a regular member
# with a Gold
/Ultimate
plan. The other plans will treat Guest members as a regular member
# for billing purposes.
#
# We are plucking the user_ids from the "Members" table in an array and
# converting the array of user_ids to a Set which will have unique user_ids.
def
billed_user_ids
(
requested_hosted_plan
=
nil
)
if
[
actual_plan_name
,
requested_hosted_plan
].
include?
(
::
Plan
::
GOLD
)
strong_memoize
(
:
gold_
billed_user_ids
)
do
if
([
actual_plan_name
,
requested_hosted_plan
]
&
[
::
Plan
::
GOLD
,
::
Plan
::
ULTIMATE
]).
any?
strong_memoize
(
:billed_user_ids
)
do
(
billed_group_members
.
non_guests
.
distinct
.
pluck
(
:user_id
)
+
billed_project_members
.
non_guests
.
distinct
.
pluck
(
:user_id
)
+
billed_shared_non_guests_group_members
.
non_guests
.
distinct
.
pluck
(
:user_id
)
+
billed_invited_non_guests_group_to_project_members
.
non_guests
.
distinct
.
pluck
(
:user_id
)).
to_set
end
else
strong_memoize
(
:non_
gold_
billed_user_ids
)
do
strong_memoize
(
:non_billed_user_ids
)
do
(
billed_group_members
.
distinct
.
pluck
(
:user_id
)
+
billed_project_members
.
distinct
.
pluck
(
:user_id
)
+
billed_shared_group_members
.
distinct
.
pluck
(
:user_id
)
+
...
...
ee/app/models/ee/namespace.rb
View file @
f7af9f81
...
...
@@ -11,13 +11,13 @@ module EE
include
::
Gitlab
::
Utils
::
StrongMemoize
NAMESPACE_PLANS_TO_LICENSE_PLANS
=
{
::
Plan
::
BRONZE
=>
License
::
STARTER_PLAN
,
::
Plan
::
SILVER
=>
License
::
PREMIUM_PLAN
,
::
Plan
::
GOLD
=>
License
::
ULTIMATE_PLAN
::
Plan
::
BRONZE
=>
License
::
STARTER_PLAN
,
[
::
Plan
::
SILVER
,
::
Plan
::
PREMIUM
]
=>
License
::
PREMIUM_PLAN
,
[
::
Plan
::
GOLD
,
::
Plan
::
ULTIMATE
]
=>
License
::
ULTIMATE_PLAN
}.
freeze
LICENSE_PLANS_TO_NAMESPACE_PLANS
=
NAMESPACE_PLANS_TO_LICENSE_PLANS
.
invert
.
freeze
PLANS
=
(
NAMESPACE_PLANS_TO_LICENSE_PLANS
.
keys
+
[
Plan
::
FREE
]).
freeze
PLANS
=
(
NAMESPACE_PLANS_TO_LICENSE_PLANS
.
keys
+
[
Plan
::
FREE
]).
f
latten
.
f
reeze
TEMPORARY_STORAGE_INCREASE_DAYS
=
30
prepended
do
...
...
@@ -110,7 +110,7 @@ module EE
extend
::
Gitlab
::
Utils
::
Override
def
plans_with_feature
(
feature
)
LICENSE_PLANS_TO_NAMESPACE_PLANS
.
values_at
(
*
License
.
plans_with_feature
(
feature
))
LICENSE_PLANS_TO_NAMESPACE_PLANS
.
values_at
(
*
License
.
plans_with_feature
(
feature
))
.
flatten
end
end
...
...
@@ -336,10 +336,18 @@ module EE
actual_plan_name
==
::
Plan
::
SILVER
end
def
premium_plan?
actual_plan_name
==
::
Plan
::
PREMIUM
end
def
gold_plan?
actual_plan_name
==
::
Plan
::
GOLD
end
def
ultimate_plan?
actual_plan_name
==
::
Plan
::
ULTIMATE
end
def
plan_eligible_for_trial?
::
Plan
::
PLANS_ELIGIBLE_FOR_TRIAL
.
include?
(
actual_plan_name
)
end
...
...
ee/app/models/ee/plan.rb
View file @
f7af9f81
...
...
@@ -9,10 +9,12 @@ module EE
FREE
=
'free'
.
freeze
BRONZE
=
'bronze'
.
freeze
SILVER
=
'silver'
.
freeze
PREMIUM
=
'premium'
.
freeze
GOLD
=
'gold'
.
freeze
ULTIMATE
=
'ultimate'
.
freeze
EE_DEFAULT_PLANS
=
(
const_get
(
:DEFAULT_PLANS
,
false
)
+
[
FREE
]).
freeze
PAID_HOSTED_PLANS
=
[
BRONZE
,
SILVER
,
GOLD
].
freeze
PAID_HOSTED_PLANS
=
[
BRONZE
,
SILVER
,
PREMIUM
,
GOLD
,
ULTIMATE
].
freeze
EE_ALL_PLANS
=
(
EE_DEFAULT_PLANS
+
PAID_HOSTED_PLANS
).
freeze
PLANS_ELIGIBLE_FOR_TRIAL
=
EE_DEFAULT_PLANS
...
...
ee/app/models/ee/user.rb
View file @
f7af9f81
...
...
@@ -357,8 +357,8 @@ module EE
end
def
owns_upgradeable_namespace?
!
owns_paid_namespace?
(
plans:
[
::
Plan
::
GOLD
])
&&
owns_paid_namespace?
(
plans:
[
::
Plan
::
BRONZE
,
::
Plan
::
SILVER
])
!
owns_paid_namespace?
(
plans:
[
::
Plan
::
GOLD
,
::
Plan
::
ULTIMATE
])
&&
owns_paid_namespace?
(
plans:
[
::
Plan
::
BRONZE
,
::
Plan
::
SILVER
,
::
Plan
::
PREMIUM
])
end
# Returns the groups a user has access to, either through a membership or a project authorization
...
...
ee/app/models/gitlab_subscription.rb
View file @
f7af9f81
...
...
@@ -86,6 +86,8 @@ class GitlabSubscription < ApplicationRecord
end
def
upgradable?
return
false
if
[
::
Plan
::
GOLD
,
::
Plan
::
ULTIMATE
].
include?
(
plan_name
)
has_a_paid_hosted_plan?
&&
!
expired?
&&
plan_name
!=
Plan
::
PAID_HOSTED_PLANS
[
-
1
]
...
...
ee/spec/factories/gitlab_subscriptions.rb
View file @
f7af9f81
...
...
@@ -42,8 +42,16 @@ FactoryBot.define do
association
:hosted_plan
,
factory: :silver_plan
end
trait
:premium
do
association
:hosted_plan
,
factory: :premium_plan
end
trait
:gold
do
association
:hosted_plan
,
factory: :gold_plan
end
trait
:ultimate
do
association
:hosted_plan
,
factory: :ultimate_plan
end
end
end
ee/spec/helpers/ee/user_callouts_helper_spec.rb
View file @
f7af9f81
...
...
@@ -377,13 +377,15 @@ RSpec.describe EE::UserCalloutsHelper do
shared_examples
'shows and hides the banner depending on circumstances'
do
where
(
:show_billing_eoa_banner
,
:actual_plan_name
,
:dismissed_callout
,
:travel_to_date
,
:result
)
do
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
true
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
|
false
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
+
1
.
day
|
false
true
|
::
Plan
::
BRONZE
|
true
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
SILVER
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
GOLD
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
false
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
true
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
|
false
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
+
1
.
day
|
false
true
|
::
Plan
::
BRONZE
|
true
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
SILVER
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
PREMIUM
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
GOLD
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
ULTIMATE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
false
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
end
with_them
do
...
...
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
View file @
f7af9f81
This diff is collapsed.
Click to expand it.
ee/spec/models/ee/namespace_spec.rb
View file @
f7af9f81
...
...
@@ -207,11 +207,13 @@ RSpec.describe Namespace do
subject
{
described_class
.
in_default_plan
.
ids
}
where
(
:plan_name
,
:expect_in_default_plan
)
do
::
Plan
::
FREE
|
true
::
Plan
::
DEFAULT
|
true
::
Plan
::
BRONZE
|
false
::
Plan
::
SILVER
|
false
::
Plan
::
GOLD
|
false
::
Plan
::
FREE
|
true
::
Plan
::
DEFAULT
|
true
::
Plan
::
BRONZE
|
false
::
Plan
::
SILVER
|
false
::
Plan
::
PREMIUM
|
false
::
Plan
::
GOLD
|
false
::
Plan
::
ULTIMATE
|
false
end
with_them
do
...
...
@@ -274,12 +276,23 @@ RSpec.describe Namespace do
end
context
'in active trial gold plan'
do
before
do
create
:gitlab_subscription
,
::
Plan
::
GOLD
,
:active_trial
,
namespace:
namespace
create
:gitlab_subscription
,
::
Plan
::
GOLD
,
:active_trial
,
namespace:
sub_namespace
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:plan_name
)
do
[
[
::
Plan
::
GOLD
],
[
::
Plan
::
ULTIMATE
]
]
end
it
{
is_expected
.
to
eq
([
namespace
.
id
])
}
with_them
do
before
do
create
:gitlab_subscription
,
plan_name
,
:active_trial
,
namespace:
namespace
create
:gitlab_subscription
,
plan_name
,
:active_trial
,
namespace:
sub_namespace
end
it
{
is_expected
.
to
eq
([
namespace
.
id
])
}
end
end
context
'with a paid plan and not in trial'
do
...
...
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