Commit 6fcbca5f authored by Tyler Amos's avatar Tyler Amos

Remove .com check in storage alert helper

GL.com checks are not preferred and not needed when an application
setting can be used.  In these cases, the app setting checks were
already in place so the .com checks were not necessary.
parent 7568f740
...@@ -47,8 +47,7 @@ module EE ...@@ -47,8 +47,7 @@ module EE
end end
def can_purchase_storage_for_namespace?(namespace) def can_purchase_storage_for_namespace?(namespace)
::Gitlab.dev_env_or_com? && ::Gitlab::CurrentSettings.automatic_purchased_storage_allocation? &&
::Gitlab::CurrentSettings.automatic_purchased_storage_allocation? &&
::Feature.enabled?(:buy_storage_link) && ::Feature.enabled?(:buy_storage_link) &&
namespace.additional_repo_storage_by_namespace_enabled? namespace.additional_repo_storage_by_namespace_enabled?
end end
...@@ -62,8 +61,7 @@ module EE ...@@ -62,8 +61,7 @@ module EE
end end
def can_purchase_storage? def can_purchase_storage?
::Gitlab.dev_env_or_com? && ::Gitlab::CurrentSettings.enforce_namespace_storage_limit? &&
::Gitlab::CurrentSettings.enforce_namespace_storage_limit? &&
::Feature.enabled?(:buy_storage_link) ::Feature.enabled?(:buy_storage_link)
end end
......
...@@ -75,20 +75,15 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do ...@@ -75,20 +75,15 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
describe '#can_purchase_storage?' do describe '#can_purchase_storage?' do
subject { helper.can_purchase_storage? } subject { helper.can_purchase_storage? }
where(:is_dot_com, :enforcement_setting_enabled, :feature_enabled, :result) do where(:enforcement_setting_enabled, :feature_enabled, :result) do
false | false | false | false false | false | false
false | false | true | false false | true | false
false | true | false | false true | false | false
true | false | false | false true | true | true
false | true | true | false
true | true | false | false
true | false | true | false
true | true | true | true
end end
with_them do with_them do
before do before do
allow(::Gitlab).to receive(:com?).and_return(is_dot_com)
stub_application_setting(enforce_namespace_storage_limit: enforcement_setting_enabled) stub_application_setting(enforce_namespace_storage_limit: enforcement_setting_enabled)
stub_feature_flags(buy_storage_link: feature_enabled) stub_feature_flags(buy_storage_link: feature_enabled)
end end
...@@ -209,7 +204,6 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do ...@@ -209,7 +204,6 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
let_it_be(:namespace) { build(:namespace) } let_it_be(:namespace) { build(:namespace) }
where( where(
is_dev_or_com: [true, false],
auto_storage_allocation_enabled: [true, false], auto_storage_allocation_enabled: [true, false],
buy_storage_link_enabled: [true, false], buy_storage_link_enabled: [true, false],
namespace_storage_limit_enabled: [true, false], namespace_storage_limit_enabled: [true, false],
...@@ -218,15 +212,13 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do ...@@ -218,15 +212,13 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
with_them do with_them do
let(:result) do let(:result) do
is_dev_or_com && auto_storage_allocation_enabled &&
auto_storage_allocation_enabled &&
buy_storage_link_enabled && buy_storage_link_enabled &&
!namespace_storage_limit_enabled && !namespace_storage_limit_enabled &&
additional_storage_enabled additional_storage_enabled
end end
before do before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(is_dev_or_com)
stub_application_setting(automatic_purchased_storage_allocation: auto_storage_allocation_enabled) stub_application_setting(automatic_purchased_storage_allocation: auto_storage_allocation_enabled)
stub_feature_flags( stub_feature_flags(
namespace_storage_limit: namespace_storage_limit_enabled, namespace_storage_limit: namespace_storage_limit_enabled,
......
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