Commit 2a4b477b authored by James Lopez's avatar James Lopez

Merge branch 'remove-early-adopter-plan' into 'master'

Remove early adopter plan

See merge request gitlab-org/gitlab!41792
parents 5b8bf5dc 1eac1d13
......@@ -13,8 +13,7 @@ module EE
NAMESPACE_PLANS_TO_LICENSE_PLANS = {
::Plan::BRONZE => License::STARTER_PLAN,
::Plan::SILVER => License::PREMIUM_PLAN,
::Plan::GOLD => License::ULTIMATE_PLAN,
::Plan::EARLY_ADOPTER => License::EARLY_ADOPTER_PLAN
::Plan::GOLD => License::ULTIMATE_PLAN
}.freeze
LICENSE_PLANS_TO_NAMESPACE_PLANS = NAMESPACE_PLANS_TO_LICENSE_PLANS.invert.freeze
......@@ -322,10 +321,6 @@ module EE
actual_plan_name == ::Plan::FREE
end
def early_adopter_plan?
actual_plan_name == ::Plan::EARLY_ADOPTER
end
def bronze_plan?
actual_plan_name == ::Plan::BRONZE
end
......
......@@ -10,16 +10,11 @@ module EE
BRONZE = 'bronze'.freeze
SILVER = 'silver'.freeze
GOLD = 'gold'.freeze
EARLY_ADOPTER = 'early_adopter'.freeze
EE_DEFAULT_PLANS = (const_get(:DEFAULT_PLANS, false) + [FREE]).freeze
PAID_HOSTED_PLANS = [BRONZE, SILVER, GOLD].freeze
FREE_HOSTED_PLANS = [EARLY_ADOPTER].freeze
EE_ALL_PLANS = (EE_DEFAULT_PLANS + PAID_HOSTED_PLANS + FREE_HOSTED_PLANS).freeze
PLANS_ELIGIBLE_FOR_TRIAL = [*EE_DEFAULT_PLANS, *FREE_HOSTED_PLANS].freeze
# This constant must keep ordered by tier.
ALL_HOSTED_PLANS = (PAID_HOSTED_PLANS + FREE_HOSTED_PLANS).freeze
EE_ALL_PLANS = (EE_DEFAULT_PLANS + PAID_HOSTED_PLANS).freeze
PLANS_ELIGIBLE_FOR_TRIAL = EE_DEFAULT_PLANS
has_many :hosted_subscriptions, class_name: 'GitlabSubscription', foreign_key: 'hosted_plan_id'
......@@ -55,7 +50,7 @@ module EE
::Plan
.joins(:hosted_subscriptions)
.where(name: ALL_HOSTED_PLANS)
.where(name: PAID_HOSTED_PLANS)
.where(gitlab_subscriptions: { namespace_id: namespaces })
.distinct
end
......
......@@ -6,7 +6,6 @@ class License < ApplicationRecord
STARTER_PLAN = 'starter'.freeze
PREMIUM_PLAN = 'premium'.freeze
ULTIMATE_PLAN = 'ultimate'.freeze
EARLY_ADOPTER_PLAN = 'early_adopter'.freeze
EES_FEATURES = %i[
audit_events
......@@ -150,37 +149,10 @@ class License < ApplicationRecord
]
EEU_FEATURES.freeze
# List all features available for early adopters,
# i.e. users that started using GitLab.com before
# the introduction of Bronze, Silver, Gold plans.
# Obs.: Do not extend from other feature constants.
# Early adopters should not earn new features as they're
# introduced.
EARLY_ADOPTER_FEATURES = %i[
audit_events
contribution_analytics
cross_project_pipelines
deploy_board
file_locks
group_webhooks
issuable_default_templates
issue_weights
jenkins_integration
merge_request_approvers
multiple_group_issue_boards
multiple_issue_assignees
protected_refs_for_users
push_rules
related_issues
repository_mirrors
scoped_issue_board
].freeze
FEATURES_BY_PLAN = {
STARTER_PLAN => EES_FEATURES,
PREMIUM_PLAN => EEP_FEATURES,
ULTIMATE_PLAN => EEU_FEATURES,
EARLY_ADOPTER_PLAN => EARLY_ADOPTER_FEATURES
ULTIMATE_PLAN => EEU_FEATURES
}.freeze
PLANS_BY_FEATURE = FEATURES_BY_PLAN.each_with_object({}) do |(plan, features), hash|
......
......@@ -126,7 +126,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
.joins(root_namespaces_join)
.joins('LEFT JOIN gitlab_subscriptions ON gitlab_subscriptions.namespace_id = root_namespaces.id')
.joins('LEFT JOIN plans ON plans.id = gitlab_subscriptions.hosted_plan_id')
.where(['plans.name IN (?) OR projects.visibility_level = ?', ::Plan::ALL_HOSTED_PLANS, ::Gitlab::VisibilityLevel::PUBLIC])
.where(['plans.name IN (?) OR projects.visibility_level = ?', ::Plan::PAID_HOSTED_PLANS, ::Gitlab::VisibilityLevel::PUBLIC])
end
relation
......
# frozen_string_literal: true
Gitlab::Seeder.quiet do
Plan::ALL_HOSTED_PLANS.each do |plan|
Plan::PAID_HOSTED_PLANS.each do |plan|
Plan.create!(name: plan, title: plan.titleize)
print '.'
......
......@@ -18,7 +18,7 @@ module API
end
params do
requires :percentage, type: Integer, values: 0..100
requires :plan, type: String, values: Plan::ALL_HOSTED_PLANS
requires :plan, type: String, values: Plan::PAID_HOSTED_PLANS
end
put 'rollout' do
ElasticNamespaceRolloutWorker.perform_async(params[:plan], params[:percentage], ElasticNamespaceRolloutWorker::ROLLOUT) # rubocop:disable CodeReuse/Worker
......@@ -35,7 +35,7 @@ module API
end
params do
requires :percentage, type: Integer, values: 0..100
requires :plan, type: String, values: Plan::ALL_HOSTED_PLANS
requires :plan, type: String, values: Plan::PAID_HOSTED_PLANS
end
put 'rollback' do
ElasticNamespaceRolloutWorker.perform_async(params[:plan], params[:percentage], ElasticNamespaceRolloutWorker::ROLLBACK) # rubocop:disable CodeReuse/Worker
......
......@@ -32,10 +32,6 @@ FactoryBot.define do
hosted_plan_id { nil }
end
trait :early_adopter do
association :hosted_plan, factory: :early_adopter_plan
end
trait :bronze do
association :hosted_plan, factory: :bronze_plan
end
......
......@@ -9,7 +9,7 @@ RSpec.describe GitlabSubscription do
stub_feature_flags(elasticsearch_index_only_paid_groups: false)
end
%i[free_plan bronze_plan silver_plan gold_plan early_adopter_plan].each do |plan|
%i[free_plan bronze_plan silver_plan gold_plan].each do |plan|
let_it_be(plan) { create(plan) }
end
......@@ -40,14 +40,12 @@ RSpec.describe GitlabSubscription do
describe '.with_hosted_plan' do
let!(:gold_subscription) { create(:gitlab_subscription, hosted_plan: gold_plan) }
let!(:silver_subscription) { create(:gitlab_subscription, hosted_plan: silver_plan) }
let!(:early_adopter_subscription) { create(:gitlab_subscription, hosted_plan: early_adopter_plan) }
let!(:trial_subscription) { create(:gitlab_subscription, hosted_plan: gold_plan, trial: true) }
it 'scopes to the plan' do
expect(described_class.with_hosted_plan('gold')).to contain_exactly(gold_subscription)
expect(described_class.with_hosted_plan('silver')).to contain_exactly(silver_subscription)
expect(described_class.with_hosted_plan('early_adopter')).to contain_exactly(early_adopter_subscription)
expect(described_class.with_hosted_plan('bronze')).to be_empty
end
end
......@@ -161,12 +159,6 @@ RSpec.describe GitlabSubscription do
include_examples 'always returns a total of 0'
end
context 'with an early adopter plan' do
let(:subscription_attrs) { { hosted_plan: early_adopter_plan } }
include_examples 'always returns a total of 0'
end
context 'with a paid plan' do
let(:subscription_attrs) { { hosted_plan: bronze_plan } }
......@@ -242,7 +234,6 @@ RSpec.describe GitlabSubscription do
'bronze' | 1 | true | true
'bronze' | 1 | false | false
'silver' | 1 | true | true
'early_adopter' | 1 | true | false
end
with_them do
......
......@@ -317,11 +317,6 @@ RSpec.describe License do
.to include(:multiple_issue_assignees, :deploy_board, :file_locks)
end
it 'returns features for early adopter plan' do
expect(described_class.features_for_plan('premium'))
.to include(:deploy_board, :file_locks)
end
it 'returns empty array if no features for given plan' do
expect(described_class.features_for_plan('bronze')).to eq([])
end
......@@ -778,7 +773,6 @@ RSpec.describe License do
nil | false
described_class::STARTER_PLAN | false
described_class::PREMIUM_PLAN | false
described_class::EARLY_ADOPTER_PLAN | false
described_class::ULTIMATE_PLAN | true
end
......
......@@ -26,6 +26,6 @@ RSpec.describe Plan do
describe '::PLANS_ELIGIBLE_FOR_TRIAL' do
subject { ::Plan::PLANS_ELIGIBLE_FOR_TRIAL }
it { is_expected.to eq(%w[default free early_adopter]) }
it { is_expected.to eq(%w[default free]) }
end
end
......@@ -6,7 +6,6 @@ RSpec.describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
subject { described_class.new }
let_it_be(:bronze_plan) { create(:bronze_plan) }
let_it_be(:early_adopter_plan) { create(:early_adopter_plan) }
let_it_be(:gitlab_subscription, refind: true) { create(:gitlab_subscription, seats: 1) }
let_it_be(:gitlab_subscription_2, refind: true) { create(:gitlab_subscription, seats: 11) }
......@@ -81,12 +80,6 @@ RSpec.describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
include_examples 'updates only paid plans'
end
context 'with an early adopter plan' do
let(:subscription_attrs) { { hosted_plan: early_adopter_plan } }
include_examples 'updates only paid plans'
end
context 'with a paid plan', :aggregate_failures do
before do
gitlab_subscription.update!(hosted_plan: bronze_plan)
......
......@@ -7,7 +7,6 @@ RSpec.describe MoveLimitsFromPlans do
let(:plans) { table(:plans) }
let(:plan_limits) { table(:plan_limits) }
let!(:early_adopter_plan) { plans.create(name: 'early_adopter', title: 'Early adopter', active_pipelines_limit: 10, pipeline_size_limit: 11, active_jobs_limit: 12) }
let!(:gold_plan) { plans.create(name: 'gold', title: 'Gold', active_pipelines_limit: 20, pipeline_size_limit: 21, active_jobs_limit: 22) }
let!(:silver_plan) { plans.create(name: 'silver', title: 'Silver', active_pipelines_limit: 30, pipeline_size_limit: 31, active_jobs_limit: 32) }
let!(:bronze_plan) { plans.create(name: 'bronze', title: 'Bronze', active_pipelines_limit: 40, pipeline_size_limit: 41, active_jobs_limit: 42) }
......@@ -16,7 +15,7 @@ RSpec.describe MoveLimitsFromPlans do
describe 'migrate' do
it 'populates plan_limits from all the records in plans' do
expect { migrate! }.to change { plan_limits.count }.by 6
expect { migrate! }.to change { plan_limits.count }.by 5
end
it 'copies plan limits and plan.id into to plan_limits table' do
......@@ -24,7 +23,6 @@ RSpec.describe MoveLimitsFromPlans do
new_data = plan_limits.pluck(:plan_id, :ci_active_pipelines, :ci_pipeline_size, :ci_active_jobs)
expected_data = [
[early_adopter_plan.id, 10, 11, 12],
[gold_plan.id, 20, 21, 22],
[silver_plan.id, 30, 31, 32],
[bronze_plan.id, 40, 41, 42],
......
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