Commit 07551703 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '321364-implement-new-plan-constants' into 'master'

Use new plan constants in Plan/Namespace logic

See merge request gitlab-org/gitlab!54191
parents 61a32e5e f7af9f81
...@@ -85,7 +85,7 @@ module BillingPlansHelper ...@@ -85,7 +85,7 @@ module BillingPlansHelper
end end
def show_plans?(namespace) def show_plans?(namespace)
namespace.trial_active? || !namespace.gold_plan? namespace.trial_active? || !(namespace.gold_plan? || namespace.ultimate_plan?)
end end
def show_trial_banner?(namespace) def show_trial_banner?(namespace)
......
...@@ -290,21 +290,21 @@ module EE ...@@ -290,21 +290,21 @@ module EE
end end
# For now, we are not billing for members with a Guest role for subscriptions # 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. # for billing purposes.
# #
# We are plucking the user_ids from the "Members" table in an array and # 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. # converting the array of user_ids to a Set which will have unique user_ids.
def billed_user_ids(requested_hosted_plan = nil) def billed_user_ids(requested_hosted_plan = nil)
if [actual_plan_name, requested_hosted_plan].include?(::Plan::GOLD) if ([actual_plan_name, requested_hosted_plan] & [::Plan::GOLD, ::Plan::ULTIMATE]).any?
strong_memoize(:gold_billed_user_ids) do strong_memoize(:billed_user_ids) do
(billed_group_members.non_guests.distinct.pluck(:user_id) + (billed_group_members.non_guests.distinct.pluck(:user_id) +
billed_project_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_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 billed_invited_non_guests_group_to_project_members.non_guests.distinct.pluck(:user_id)).to_set
end end
else else
strong_memoize(:non_gold_billed_user_ids) do strong_memoize(:non_billed_user_ids) do
(billed_group_members.distinct.pluck(:user_id) + (billed_group_members.distinct.pluck(:user_id) +
billed_project_members.distinct.pluck(:user_id) + billed_project_members.distinct.pluck(:user_id) +
billed_shared_group_members.distinct.pluck(:user_id) + billed_shared_group_members.distinct.pluck(:user_id) +
......
...@@ -11,13 +11,13 @@ module EE ...@@ -11,13 +11,13 @@ module EE
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
NAMESPACE_PLANS_TO_LICENSE_PLANS = { NAMESPACE_PLANS_TO_LICENSE_PLANS = {
::Plan::BRONZE => License::STARTER_PLAN, ::Plan::BRONZE => License::STARTER_PLAN,
::Plan::SILVER => License::PREMIUM_PLAN, [::Plan::SILVER, ::Plan::PREMIUM] => License::PREMIUM_PLAN,
::Plan::GOLD => License::ULTIMATE_PLAN [::Plan::GOLD, ::Plan::ULTIMATE] => License::ULTIMATE_PLAN
}.freeze }.freeze
LICENSE_PLANS_TO_NAMESPACE_PLANS = NAMESPACE_PLANS_TO_LICENSE_PLANS.invert.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]).flatten.freeze
TEMPORARY_STORAGE_INCREASE_DAYS = 30 TEMPORARY_STORAGE_INCREASE_DAYS = 30
prepended do prepended do
...@@ -108,7 +108,7 @@ module EE ...@@ -108,7 +108,7 @@ module EE
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
def plans_with_feature(feature) 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
end end
...@@ -334,10 +334,18 @@ module EE ...@@ -334,10 +334,18 @@ module EE
actual_plan_name == ::Plan::SILVER actual_plan_name == ::Plan::SILVER
end end
def premium_plan?
actual_plan_name == ::Plan::PREMIUM
end
def gold_plan? def gold_plan?
actual_plan_name == ::Plan::GOLD actual_plan_name == ::Plan::GOLD
end end
def ultimate_plan?
actual_plan_name == ::Plan::ULTIMATE
end
def plan_eligible_for_trial? def plan_eligible_for_trial?
::Plan::PLANS_ELIGIBLE_FOR_TRIAL.include?(actual_plan_name) ::Plan::PLANS_ELIGIBLE_FOR_TRIAL.include?(actual_plan_name)
end end
......
...@@ -9,10 +9,12 @@ module EE ...@@ -9,10 +9,12 @@ module EE
FREE = 'free'.freeze FREE = 'free'.freeze
BRONZE = 'bronze'.freeze BRONZE = 'bronze'.freeze
SILVER = 'silver'.freeze SILVER = 'silver'.freeze
PREMIUM = 'premium'.freeze
GOLD = 'gold'.freeze GOLD = 'gold'.freeze
ULTIMATE = 'ultimate'.freeze
EE_DEFAULT_PLANS = (const_get(:DEFAULT_PLANS, false) + [FREE]).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 EE_ALL_PLANS = (EE_DEFAULT_PLANS + PAID_HOSTED_PLANS).freeze
PLANS_ELIGIBLE_FOR_TRIAL = EE_DEFAULT_PLANS PLANS_ELIGIBLE_FOR_TRIAL = EE_DEFAULT_PLANS
......
...@@ -357,8 +357,8 @@ module EE ...@@ -357,8 +357,8 @@ module EE
end end
def owns_upgradeable_namespace? def owns_upgradeable_namespace?
!owns_paid_namespace?(plans: [::Plan::GOLD]) && !owns_paid_namespace?(plans: [::Plan::GOLD, ::Plan::ULTIMATE]) &&
owns_paid_namespace?(plans: [::Plan::BRONZE, ::Plan::SILVER]) owns_paid_namespace?(plans: [::Plan::BRONZE, ::Plan::SILVER, ::Plan::PREMIUM])
end end
# Returns the groups a user has access to, either through a membership or a project authorization # Returns the groups a user has access to, either through a membership or a project authorization
......
...@@ -86,6 +86,8 @@ class GitlabSubscription < ApplicationRecord ...@@ -86,6 +86,8 @@ class GitlabSubscription < ApplicationRecord
end end
def upgradable? def upgradable?
return false if [::Plan::GOLD, ::Plan::ULTIMATE].include?(plan_name)
has_a_paid_hosted_plan? && has_a_paid_hosted_plan? &&
!expired? && !expired? &&
plan_name != Plan::PAID_HOSTED_PLANS[-1] plan_name != Plan::PAID_HOSTED_PLANS[-1]
......
...@@ -42,8 +42,16 @@ FactoryBot.define do ...@@ -42,8 +42,16 @@ FactoryBot.define do
association :hosted_plan, factory: :silver_plan association :hosted_plan, factory: :silver_plan
end end
trait :premium do
association :hosted_plan, factory: :premium_plan
end
trait :gold do trait :gold do
association :hosted_plan, factory: :gold_plan association :hosted_plan, factory: :gold_plan
end end
trait :ultimate do
association :hosted_plan, factory: :ultimate_plan
end
end end
end end
...@@ -326,13 +326,15 @@ RSpec.describe EE::UserCalloutsHelper do ...@@ -326,13 +326,15 @@ RSpec.describe EE::UserCalloutsHelper do
shared_examples 'shows and hides the banner depending on circumstances' 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 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 - 1.day | true
true | ::Plan::BRONZE | false | eoa_bronze_plan_end_date | false 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 | false | eoa_bronze_plan_end_date + 1.day | false
true | ::Plan::BRONZE | true | 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::SILVER | false | eoa_bronze_plan_end_date - 1.day | false
true | ::Plan::GOLD | false | eoa_bronze_plan_end_date - 1.day | false true | ::Plan::PREMIUM | false | eoa_bronze_plan_end_date - 1.day | false
false | ::Plan::BRONZE | 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 end
with_them do with_them do
......
...@@ -6,6 +6,8 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -6,6 +6,8 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
describe 'message' do describe 'message' do
using RSpec::Parameterized::TableSyntax
subject { strip_tags(message) } subject { strip_tags(message) }
let(:subscribable) { double(:license) } let(:subscribable) { double(:license) }
...@@ -22,238 +24,246 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -22,238 +24,246 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let(:grace_period_effective_from) { expired_date - 35.days } let(:grace_period_effective_from) { expired_date - 35.days }
let(:today) { Time.utc(2020, 3, 7, 10) } let(:today) { Time.utc(2020, 3, 7, 10) }
let(:expired_date) { Time.utc(2020, 3, 9, 10).to_date } let(:expired_date) { Time.utc(2020, 3, 9, 10).to_date }
let(:plan_name) { ::Plan::GOLD }
before do
allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(grace_period_effective_from)
end
around do |example| where(:plan_name) do
travel_to(today) do [
example.run [::Plan::GOLD],
end [::Plan::ULTIMATE]
]
end end
context 'subscribable installed' do with_them do
let(:auto_renew) { false }
before do before do
allow(subscribable).to receive(:plan).and_return(plan_name) allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(grace_period_effective_from)
allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:auto_renew).and_return(auto_renew)
end end
context 'subscribable should not notify admins' do around do |example|
it 'returns nil' do travel_to(today) do
allow(subscribable).to receive(:notify_admins?).and_return(false) example.run
allow(subscribable).to receive(:notify_users?).and_return(false)
expect(subject).to be nil
end end
end end
context 'subscribable should notify admins' do context 'subscribable installed' do
let(:auto_renew) { false }
before do before do
allow(subscribable).to receive(:notify_admins?).and_return(true) allow(subscribable).to receive(:plan).and_return(plan_name)
allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:auto_renew).and_return(auto_renew)
end end
context 'admin signed in' do context 'subscribable should not notify admins' do
let(:signed_in) { true } it 'returns nil' do
let(:is_admin) { true } allow(subscribable).to receive(:notify_admins?).and_return(false)
allow(subscribable).to receive(:notify_users?).and_return(false)
expect(subject).to be nil
end
end
context 'subscribable expired' do context 'subscribable should notify admins' do
let(:expired_date) { Time.utc(2020, 3, 1, 10).to_date } before do
allow(subscribable).to receive(:notify_admins?).and_return(true)
end
before do context 'admin signed in' do
allow(subscribable).to receive(:expired?).and_return(true) let(:signed_in) { true }
allow(subscribable).to receive(:expires_at).and_return(expired_date) let(:is_admin) { true }
end
context 'subscribable expired' do
let(:expired_date) { Time.utc(2020, 3, 1, 10).to_date }
context 'when it blocks changes' do
before do before do
allow(subscribable).to receive(:will_block_changes?).and_return(true) allow(subscribable).to receive(:expired?).and_return(true)
allow(subscribable).to receive(:expires_at).and_return(expired_date)
end end
context 'when it is currently blocking changes' do context 'when it blocks changes' do
let(:plan_name) { ::Plan::FREE }
before do before do
allow(subscribable).to receive(:block_changes?).and_return(true) allow(subscribable).to receive(:will_block_changes?).and_return(true)
allow(subscribable).to receive(:block_changes_at).and_return(expired_date)
end end
context "when the subscription hasn't been properly downgraded yet" do context 'when it is currently blocking changes' do
let(:plan_name) { ::Plan::SILVER } let(:plan_name) { ::Plan::FREE }
it "shows the expiring message" do before do
expect(subject).to include('Your subscription expired! No worries, you can still use all the Silver features for now. You have 0 days to renew your subscription.') allow(subscribable).to receive(:block_changes?).and_return(true)
allow(subscribable).to receive(:block_changes_at).and_return(expired_date)
end end
end
it 'has a nice subject' do context "when the subscription hasn't been properly downgraded yet" do
expect(subject).to include('Your subscription has been downgraded.') let(:plan_name) { ::Plan::PREMIUM }
end
context 'no namespace' do it "shows the expiring message" do
it 'has an expiration blocking message' do expect(subject).to include('Your subscription expired! No worries, you can still use all the Premium features for now. You have 0 days to renew your subscription.')
expect(subject).to include("You didn't renew your subscription so it was downgraded to the GitLab Core Plan") end
end end
end
context 'with namespace' do it 'has a nice subject' do
let(:namespace) { double(:namespace, name: 'No Limit Records') } expect(subject).to include('Your subscription has been downgraded.')
end
it 'has an expiration blocking message' do context 'no namespace' do
expect(subject).to include("You didn't renew your subscription for No Limit Records so it was downgraded to the free plan") it 'has an expiration blocking message' do
expect(subject).to include("You didn't renew your subscription so it was downgraded to the GitLab Core Plan")
end
end end
context 'is auto_renew' do context 'with namespace' do
let(:auto_renew) { true } let(:namespace) { double(:namespace, name: 'No Limit Records') }
it 'has a nice subject' do it 'has an expiration blocking message' do
expect(subject).to include('Something went wrong with your automatic subscription renewal') expect(subject).to include("You didn't renew your subscription for No Limit Records so it was downgraded to the free plan")
end end
it 'has an expiration blocking message' do context 'is auto_renew' do
expect(subject).to include("We tried to automatically renew your subscription for No Limit Records on 2020-03-01 but something went wrong so your subscription was downgraded to the free plan. Don't worry, your data is safe. We suggest you check your payment method and get in touch with our support team (support@gitlab.com). They'll gladly help with your subscription renewal.") let(:auto_renew) { true }
it 'has a nice subject' do
expect(subject).to include('Something went wrong with your automatic subscription renewal')
end
it 'has an expiration blocking message' do
expect(subject).to include("We tried to automatically renew your subscription for No Limit Records on 2020-03-01 but something went wrong so your subscription was downgraded to the free plan. Don't worry, your data is safe. We suggest you check your payment method and get in touch with our support team (support@gitlab.com). They'll gladly help with your subscription renewal.")
end
end end
end end
end end
end
context 'when it is not currently blocking changes' do context 'when it is not currently blocking changes' do
let(:plan_name) { ::Plan::GOLD } let(:plan_name) { ::Plan::ULTIMATE }
before do before do
allow(subscribable).to receive(:block_changes?).and_return(false) allow(subscribable).to receive(:block_changes?).and_return(false)
allow(subscribable).to receive(:block_changes_at).and_return((today + 4.days).to_date) allow(subscribable).to receive(:block_changes_at).and_return((today + 4.days).to_date)
end end
it 'has a nice subject' do it 'has a nice subject' do
allow(subscribable).to receive(:will_block_changes?).and_return(false) allow(subscribable).to receive(:will_block_changes?).and_return(false)
expect(subject).to include('Your subscription expired!') expect(subject).to include('Your subscription expired!')
end end
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
allow(subscribable).to receive(:block_changes_at).and_return(Time.utc(2020, 3, 9, 10).to_date) allow(subscribable).to receive(:block_changes_at).and_return(Time.utc(2020, 3, 9, 10).to_date)
allow(subscribable).to receive(:is_a?).with(::License).and_return(true) allow(subscribable).to receive(:is_a?).with(::License).and_return(true)
expect(subject).to include('No worries, you can still use all the Gold features for now. You have 2 days to renew your subscription.') expect(subject).to include('No worries, you can still use all the Ultimate features for now. You have 2 days to renew your subscription.')
end
end end
end end
end end
end
context 'subscribable is expiring soon' do context 'subscribable is expiring soon' do
before do before do
allow(subscribable).to receive(:expired?).and_return(false) allow(subscribable).to receive(:expired?).and_return(false)
allow(subscribable).to receive(:will_block_changes?).and_return(true) allow(subscribable).to receive(:will_block_changes?).and_return(true)
allow(subscribable).to receive(:block_changes_at).and_return(expired_date) allow(subscribable).to receive(:block_changes_at).and_return(expired_date)
end end
it 'has a nice subject' do
expect(subject).to include('Your subscription will expire in 2 days')
end
context 'without namespace' do it 'has a nice subject' do
it 'has an expiration blocking message' do expect(subject).to include('Your subscription will expire in 2 days')
expect(subject).to include('Your Gold subscription will expire on 2020-03-09. After that, you will not be able to create issues or merge requests as well as many other features.')
end end
end
context 'when a future dated license is applied' do context 'without namespace' do
before do it 'has an expiration blocking message' do
create(:license, created_at: Time.current, data: build(:gitlab_license, starts_at: expired_date, expires_at: Date.current + 13.months).export) expect(subject).to include("Your #{plan_name.capitalize} subscription will expire on 2020-03-09. After that, you will not be able to create issues or merge requests as well as many other features.")
end
end end
it 'returns nil' do context 'when a future dated license is applied' do
expect(subject).to be nil before do
create(:license, created_at: Time.current, data: build(:gitlab_license, starts_at: expired_date, expires_at: Date.current + 13.months).export)
end
it 'returns nil' do
expect(subject).to be nil
end
end end
end
context 'with namespace' do context 'with namespace' do
let(:namespace) { double(:namespace, name: 'No Limit Records') } let(:namespace) { double(:namespace, name: 'No Limit Records') }
it 'has gold plan specific messaging' do it 'has gold plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('gold') allow(subscribable).to receive(:plan).and_return('gold')
expect(subject).to include('Your Gold subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or epics as well as many security features.') expect(subject).to include('Your Gold subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or epics as well as many security features.')
end end
it 'has silver plan specific messaging' do it 'has silver plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('silver') allow(subscribable).to receive(:plan).and_return('silver')
expect(subject).to include('Your Silver subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or epics as well as many other features.') expect(subject).to include('Your Silver subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or epics as well as many other features.')
end end
it 'has bronze plan specific messaging' do it 'has bronze plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('bronze') allow(subscribable).to receive(:plan).and_return('bronze')
expect(subject).to include('Your Bronze subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or code quality as well as many other features.') expect(subject).to include('Your Bronze subscription for No Limit Records will expire on 2020-03-09. After that, you will not be able to use merge approvals or code quality as well as many other features.')
end end
context 'is auto_renew nil' do context 'is auto_renew nil' do
let(:auto_renew) { nil } let(:auto_renew) { nil }
it 'returns nil' do it 'returns nil' do
expect(subject).to be nil expect(subject).to be nil
end
end end
end
context 'is auto_renew' do context 'is auto_renew' do
let(:auto_renew) { true } let(:auto_renew) { true }
it 'returns nil' do it 'returns nil' do
expect(subject).to be nil expect(subject).to be nil
end
end end
end end
end end
end
context 'subscribable expired a long time ago' do context 'subscribable expired a long time ago' do
let(:expired_date) { today.to_date - 1.year } let(:expired_date) { today.to_date - 1.year }
let(:grace_period_effective_from) { today.to_date - 25.days } let(:grace_period_effective_from) { today.to_date - 25.days }
before do
allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:block_changes_at).and_return(expired_date)
allow(subscribable).to receive(:expired?).and_return(true)
allow(subscribable).to receive(:will_block_changes?).and_return(true)
allow(subscribable).to receive(:block_changes?).and_return(true)
allow(subscribable).to receive(:plan).and_return('free')
end
context 'and is past the cutoff date' do before do
let(:grace_period_effective_from) { today.to_date - 40.days } allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:block_changes_at).and_return(expired_date)
allow(subscribable).to receive(:expired?).and_return(true)
allow(subscribable).to receive(:will_block_changes?).and_return(true)
allow(subscribable).to receive(:block_changes?).and_return(true)
allow(subscribable).to receive(:plan).and_return('free')
end
it 'has a nice subject' do context 'and is past the cutoff date' do
expect(subject).to include('Your subscription has been downgraded') let(:grace_period_effective_from) { today.to_date - 40.days }
it 'has a nice subject' do
expect(subject).to include('Your subscription has been downgraded')
end
end end
end
context 'and is 30 days past the cutoff date' do context 'and is 30 days past the cutoff date' do
let(:grace_period_effective_from) { today.to_date - 60.days } let(:grace_period_effective_from) { today.to_date - 60.days }
it 'stops displaying' do it 'stops displaying' do
expect(subject).to be nil expect(subject).to be nil
end
end end
end
context 'and not past the cutoff date' do context 'and not past the cutoff date' do
it 'has a nice subject' do it 'has a nice subject' do
expect(subject).to include('Your subscription will expire in 5 days') expect(subject).to include('Your subscription will expire in 5 days')
end
end end
end end
end end
end end
end end
end
context 'no subscribable installed' do context 'no subscribable installed' do
let(:subscribable) { nil } let(:subscribable) { nil }
it { is_expected.to be_blank } it { is_expected.to be_blank }
end
end end
end end
end end
...@@ -196,11 +196,13 @@ RSpec.describe Namespace do ...@@ -196,11 +196,13 @@ RSpec.describe Namespace do
subject { described_class.in_default_plan.ids } subject { described_class.in_default_plan.ids }
where(:plan_name, :expect_in_default_plan) do where(:plan_name, :expect_in_default_plan) do
::Plan::FREE | true ::Plan::FREE | true
::Plan::DEFAULT | true ::Plan::DEFAULT | true
::Plan::BRONZE | false ::Plan::BRONZE | false
::Plan::SILVER | false ::Plan::SILVER | false
::Plan::GOLD | false ::Plan::PREMIUM | false
::Plan::GOLD | false
::Plan::ULTIMATE | false
end end
with_them do with_them do
...@@ -263,12 +265,23 @@ RSpec.describe Namespace do ...@@ -263,12 +265,23 @@ RSpec.describe Namespace do
end end
context 'in active trial gold plan' do context 'in active trial gold plan' do
before do using RSpec::Parameterized::TableSyntax
create :gitlab_subscription, ::Plan::GOLD, :active_trial, namespace: namespace
create :gitlab_subscription, ::Plan::GOLD, :active_trial, namespace: sub_namespace where(:plan_name) do
[
[::Plan::GOLD],
[::Plan::ULTIMATE]
]
end 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 end
context 'with a paid plan and not in trial' do context 'with a paid plan and not in trial' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment