Commit 093f4dea authored by Tyler Amos's avatar Tyler Amos

Replace .com checks with app setting checks

.com checks are replaced or enhanced by
::Gitlab::CurrentSettings.enforce_namespace_storage_limit?
as it relates to enforcement of storage limits.
parent d57379f8
......@@ -56,6 +56,7 @@ module EE
def purchase_storage_url
return unless ::Gitlab.dev_env_or_com?
return unless ::Gitlab::CurrentSettings.enforce_namespace_storage_limit?
return unless ::Feature.enabled?(:buy_storage_link)
EE::SUBSCRIPTIONS_MORE_STORAGE_URL
......
......@@ -33,7 +33,7 @@ module EE
end
def temporary_storage_increase_visible?(namespace)
return false unless ::Gitlab.dev_env_or_com?
return false unless ::Gitlab::CurrentSettings.enforce_namespace_storage_limit?
return false unless ::Feature.enabled?(:temporary_storage_increase, namespace)
current_user.can?(:admin_namespace, namespace.root_ancestor)
......
......@@ -187,7 +187,7 @@ module EE
end
def over_storage_limit?
::Gitlab.dev_env_or_com? &&
::Gitlab::CurrentSettings.enforce_namespace_storage_limit? &&
::Feature.enabled?(:namespace_storage_limit, root_ancestor) &&
RootStorageSize.new(root_ancestor).above_size_limit?
end
......
---
title: Replace .com check with an app setting to enforce namespace storage limit
merge_request: 39150
author:
type: changed
......@@ -35,28 +35,25 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
describe '#purchase_storage_url' do
subject { helper.purchase_storage_url }
context 'when on .com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
it { is_expected.to eq(EE::SUBSCRIPTIONS_MORE_STORAGE_URL) }
context 'when feature flag disabled' do
before do
stub_feature_flags(buy_storage_link: false)
end
it { is_expected.to be_nil }
end
where(:is_dot_com, :enforcement_setting_enabled, :feature_enabled, :result) do
false | false | false | nil
false | false | true | nil
false | true | false | nil
true | false | false | nil
false | true | true | nil
true | true | false | nil
true | false | true | nil
true | true | true | EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
context 'when not on .com' do
with_them do
before do
allow(::Gitlab).to receive(:com?).and_return(false)
allow(::Gitlab).to receive(:com?).and_return(is_dot_com)
stub_application_setting(enforce_namespace_storage_limit: enforcement_setting_enabled)
stub_feature_flags(buy_storage_link: feature_enabled)
end
it { is_expected.to be_nil }
it { is_expected.to eq(result) }
end
end
......
......@@ -112,9 +112,9 @@ RSpec.describe EE::NamespacesHelper do
let_it_be(:admin) { create(:user, namespace: namespace) }
let_it_be(:user) { create(:user) }
context 'when on .com' do
context 'when enforce_namespace_storage_limit setting enabled' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
stub_application_setting(enforce_namespace_storage_limit: true)
end
context 'when current_user is admin of namespace' do
......@@ -142,7 +142,11 @@ RSpec.describe EE::NamespacesHelper do
end
end
context 'when not on .com' do
context 'when enforce_namespace_storage_limit setting disabled' do
before do
stub_application_setting(enforce_namespace_storage_limit: false)
end
context 'when current_user is admin of namespace' do
before do
allow(helper).to receive(:current_user).and_return(admin)
......
......@@ -1400,7 +1400,7 @@ RSpec.describe Namespace do
describe '#over_storage_limit?' do
using RSpec::Parameterized::TableSyntax
where(:is_dot_com, :feature_enabled, :above_size_limit, :result) do
where(:enforcement_setting_enabled, :feature_enabled, :above_size_limit, :result) do
false | false | false | false
false | false | true | false
false | true | false | false
......@@ -1413,7 +1413,7 @@ RSpec.describe Namespace do
with_them do
before do
allow(Gitlab).to receive(:dev_env_or_com?).and_return(is_dot_com)
stub_application_setting(enforce_namespace_storage_limit: enforcement_setting_enabled)
stub_feature_flags(namespace_storage_limit: feature_enabled)
allow_next_instance_of(EE::Namespace::RootStorageSize, namespace.root_ancestor) do |project|
allow(project).to receive(:above_size_limit?).and_return(above_size_limit)
......
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