diff --git a/.rubocop_todo/gitlab/avoid_gitlab_instance_checks.yml b/.rubocop_todo/gitlab/avoid_gitlab_instance_checks.yml index 8a10208663e52235501e2222da11a8396f7a1018..ef5b876b4174413a9922e5e17aa5ea23217879c0 100644 --- a/.rubocop_todo/gitlab/avoid_gitlab_instance_checks.yml +++ b/.rubocop_todo/gitlab/avoid_gitlab_instance_checks.yml @@ -78,7 +78,6 @@ Gitlab/AvoidGitlabInstanceChecks: - 'ee/app/models/gitlab_subscription.rb' - 'ee/app/models/gitlab_subscriptions/add_on_purchase.rb' - 'ee/app/models/gitlab_subscriptions/upcoming_reconciliation.rb' - - 'ee/app/models/namespaces/storage/cost_factor.rb' - 'ee/app/models/namespaces/storage/enforcement.rb' - 'ee/app/policies/ee/global_policy.rb' - 'ee/app/policies/ee/group_policy.rb' diff --git a/ee/app/models/namespaces/storage/cost_factor.rb b/ee/app/models/namespaces/storage/cost_factor.rb index 6b1c0a695df1c0ec1b8b3b855fd636d9e90421dd..5e9e8ca4fe9740e735ac49bb88c98ab91a8c4aa4 100644 --- a/ee/app/models/namespaces/storage/cost_factor.rb +++ b/ee/app/models/namespaces/storage/cost_factor.rb @@ -22,7 +22,7 @@ def inverted_cost_factor_for_forks private def forks_cost_factor - if ::Gitlab::CurrentSettings.should_check_namespace_plan? + if ::Gitlab::Saas.feature_available?(:gitlab_com_subscriptions) ::Gitlab::CurrentSettings.namespace_storage_forks_cost_factor else FULL_COST diff --git a/ee/spec/models/namespaces/storage/cost_factor_spec.rb b/ee/spec/models/namespaces/storage/cost_factor_spec.rb index 96eccaeb8111ec1b61e38917702c2cd304edf932..f746bd87cb008e67bd2a483f9aa5f564c0e54e71 100644 --- a/ee/spec/models/namespaces/storage/cost_factor_spec.rb +++ b/ee/spec/models/namespaces/storage/cost_factor_spec.rb @@ -10,7 +10,7 @@ before do stub_ee_application_setting(namespace_storage_forks_cost_factor: forks_cost_factor) - stub_ee_application_setting(check_namespace_plan: true) + stub_saas_features(gitlab_com_subscriptions: true) end describe '.cost_factor_for' do @@ -32,8 +32,8 @@ expect(described_class.cost_factor_for(project)).to eq(full_cost) end - it 'returns full cost when namespace plans are not checked' do - stub_ee_application_setting(check_namespace_plan: false) + it 'returns full cost when gitlab_com_subscriptions feature is not available' do + stub_saas_features(gitlab_com_subscriptions: false) project = build_fork(group: paid_group) expect(described_class.cost_factor_for(project)).to eq(full_cost) @@ -45,8 +45,8 @@ expect(described_class.inverted_cost_factor_for_forks).to eq(0.8) end - it 'returns the inverse of full cost when namespace plans are not checked' do - stub_ee_application_setting(check_namespace_plan: false) + it 'returns the inverse of full cost when gitlab_com_subscriptions feature is not available' do + stub_saas_features(gitlab_com_subscriptions: false) expect(described_class.inverted_cost_factor_for_forks).to eq(0) end diff --git a/ee/spec/presenters/ee/project_presenter_spec.rb b/ee/spec/presenters/ee/project_presenter_spec.rb index 4ce50bc972bdd7fcbbd55d353f4ccfb16185cab2..e566ce151426049def45ad5e38267c77e5e0340b 100644 --- a/ee/spec/presenters/ee/project_presenter_spec.rb +++ b/ee/spec/presenters/ee/project_presenter_spec.rb @@ -10,7 +10,7 @@ let(:presenter) { described_class.new(project, current_user: user) } before do - stub_application_setting(check_namespace_plan: true) + stub_saas_features(gitlab_com_subscriptions: true) stub_application_setting(namespace_storage_forks_cost_factor: 0.1) allow(presenter).to receive(:can?).with(user, :admin_project, project).and_return(true) allow(project).to receive(:empty_repo?).and_return(false) diff --git a/ee/spec/support/helpers/namespace_storage_helpers.rb b/ee/spec/support/helpers/namespace_storage_helpers.rb index e6b5f1f5cf0163b684c2be73b19dab6e6170af49..7e35f71d415c6fa91f1a150183db8791c5b2c005 100644 --- a/ee/spec/support/helpers/namespace_storage_helpers.rb +++ b/ee/spec/support/helpers/namespace_storage_helpers.rb @@ -27,7 +27,7 @@ def enforce_namespace_storage_limit(root_namespace) stub_ee_application_setting(enforce_namespace_storage_limit: true) stub_ee_application_setting(automatic_purchased_storage_allocation: true) stub_feature_flags(namespace_storage_limit: root_namespace) - stub_saas_features(namespaces_storage_limit: true) + stub_saas_features(namespaces_storage_limit: true, gitlab_com_subscriptions: true) allow(::Namespaces::Storage::Enforcement).to receive(:enforceable_namespace?).and_return true end