Commit 366d16cd authored by Alper Akgun's avatar Alper Akgun

Merge branch '214434-subscription' into 'master'

Avoid GitlabSubscription generation outside SaaS

See merge request gitlab-org/gitlab!73611
parents f675b9ad 39f24f09
......@@ -179,13 +179,15 @@ module EE
override :actual_plan
def actual_plan
strong_memoize(:actual_plan) do
next ::Plan.default unless ::Gitlab.com?
if parent_id
root_ancestor.actual_plan
else
subscription = find_or_create_subscription
hosted_plan_for(subscription)
subscription = gitlab_subscription || generate_subscription
hosted_plan_for(subscription) || ::Plan.free
end
end
end || fallback_plan
end
def closest_gitlab_subscription
......@@ -444,14 +446,6 @@ module EE
projects_query.with_shared_runners.any?
end
def fallback_plan
if ::Gitlab.com?
::Plan.free
else
::Plan.default
end
end
def validate_shared_runner_minutes_support
return if root?
......@@ -487,13 +481,6 @@ module EE
self.file_template_project_id = nil
end
def find_or_create_subscription
# Hosted subscriptions are only available for root groups for now.
return if parent_id
gitlab_subscription || generate_subscription
end
def generate_subscription
return unless persisted?
return if ::Gitlab::Database.read_only?
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Changes GL.com plan for group', :js do
RSpec.describe 'Changes GL.com plan for group', :js, :saas do
include WaitForRequests
let!(:premium_plan) { create(:premium_plan) }
......
......@@ -23,7 +23,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::AfterConfig do
project.add_developer(user)
end
describe 'credit card requirement' do
describe 'credit card requirement', :saas do
context 'when user does not have credit card for pipelines in project' do
before do
allow(user)
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
RSpec.describe Ci::Subscriptions::Project do
let_it_be(:upstream_project) { create(:project, :public) }
let_it_be(:downstream_project) { create(:project) }
let_it_be_with_reload(:upstream_project) { create(:project, :public) }
let_it_be_with_reload(:downstream_project) { create(:project) }
describe 'Relations' do
it { is_expected.to belong_to(:downstream_project).required }
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Dast::ProfileSchedule, type: :model do
let(:dast_profile_schedule) { create(:dast_profile_schedule, project: project) }
let_it_be(:project) { create(:project) }
let_it_be_with_reload(:project) { create(:project) }
let_it_be(:inactive_dast_profile_schedule) { create(:dast_profile_schedule, active: false, project: project) }
subject { dast_profile_schedule }
......
......@@ -735,8 +735,7 @@ RSpec.describe Namespace do
it 'generates a subscription and returns default plan' do
expect(namespace.actual_plan).to eq(Plan.default)
# This should be revisited after https://gitlab.com/gitlab-org/gitlab/-/issues/214434
expect(namespace.gitlab_subscription).to be_present
expect(namespace.gitlab_subscription).to be_nil
end
end
......
......@@ -3,9 +3,9 @@
require 'spec_helper'
RSpec.describe Gitlab::Ci::Pipeline::Quota::Deployments do
let_it_be(:namespace) { create(:namespace) }
let_it_be(:default_plan, reload: true) { create(:default_plan) }
let_it_be(:project, reload: true) { create(:project, :repository, namespace: namespace) }
let_it_be_with_refind(:namespace) { create(:namespace) }
let_it_be_with_reload(:default_plan) { create(:default_plan) }
let_it_be_with_reload(:project) { create(:project, :repository, namespace: namespace) }
let_it_be(:plan_limits) { create(:plan_limits, plan: default_plan) }
let(:pipeline) { build_stubbed(:ci_pipeline, project: project) }
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do
let_it_be(:project) { create(:project, :repository) }
let_it_be_with_reload(:project) { create(:project, :repository) }
let_it_be(:head_sha) { project.repository.head_commit.id }
let(:pipeline) { build(:ci_empty_pipeline, project: project, sha: head_sha) }
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Ci::PipelineSchedule do
let_it_be(:project) { create_default(:project) }
let_it_be_with_reload(:project) { create_default(:project) }
subject { build(:ci_pipeline_schedule) }
......
......@@ -32,8 +32,8 @@ RSpec.describe ProjectHook do
end
describe '#rate_limit' do
let_it_be(:hook) { create(:project_hook) }
let_it_be(:plan_limits) { create(:plan_limits, :default_plan, web_hook_calls: 100) }
let_it_be(:hook) { create(:project_hook) }
it 'returns the default limit' do
expect(hook.rate_limit).to be(100)
......
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