Commit 0135802c authored by Serena Fang's avatar Serena Fang

Move namespace helper method to ee

parent 96cf6f50
......@@ -88,12 +88,6 @@ module NamespacesHelper
}.to_json
end
def show_minute_limit_banner?(namespace)
return false unless Gitlab.com? && ::Feature.enabled?(:show_minute_limit_banner)
namespace.root_ancestor.free_plan? && !minute_limit_banner_dismissed? ? true : false
end
private
# Many importers create a temporary Group, so use the real
......
......@@ -61,6 +61,12 @@ module EE
buy_storage_subscriptions_url(selected_group: namespace.id)
end
def show_minute_limit_banner?(namespace)
return false unless ::Gitlab.com? && ::Feature.enabled?(:show_minute_limit_banner)
namespace.root_ancestor.free_plan? && !minute_limit_banner_dismissed? ? true : false
end
private
def use_customers_dot_for_addon_path?(namespace)
......
......@@ -222,4 +222,46 @@ RSpec.describe EE::NamespacesHelper do
end
end
end
describe '#show_minute_limit_banner?' do
let(:project) { create(:project) }
context 'on dot com' do
using RSpec::Parameterized::TableSyntax
where(:feature_flag_enabled, :free_project, :user_dismissed_banner, :should_show_banner) do
true | true | false | true
true | true | true | false
true | false | false | false
false | true | false | false
end
with_them do
before do
allow(Gitlab).to receive(:com?).and_return(true)
stub_feature_flags(show_minute_limit_banner: feature_flag_enabled)
allow(project.root_ancestor).to receive(:free_plan?).and_return(free_project)
allow(helper).to receive(:user_dismissed?).with('minute_limit_banner').and_return(user_dismissed_banner)
end
it 'shows the banner if required' do
expect(helper.show_minute_limit_banner?(project)).to eq(should_show_banner)
end
end
end
context 'not dot com' do
context 'when feature flag is enabled for a free project and user has not dismissed callout' do
before do
stub_feature_flags(show_minute_limit_banner: true)
allow(project.root_ancestor).to receive(:free_plan?).and_return(true)
allow(helper).to receive(:user_dismissed?).with('minute_limit_banner').and_return(false)
end
it 'does not show banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(false)
end
end
end
end
end
......@@ -268,46 +268,4 @@ RSpec.describe NamespacesHelper do
end
end
end
describe '#show_minute_limit_banner?' do
let(:project) { create(:project) }
context 'on dot com' do
using RSpec::Parameterized::TableSyntax
where(:feature_flag_enabled, :free_project, :user_dismissed_banner, :should_show_banner) do
true | true | false | true
true | true | true | false
true | false | false | false
false | true | false | false
end
with_them do
before do
allow(Gitlab).to receive(:com?).and_return(true)
stub_feature_flags(show_minute_limit_banner: feature_flag_enabled)
allow(project.root_ancestor).to receive(:free_plan?).and_return(free_project)
allow(helper).to receive(:user_dismissed?).with(Users::CalloutsHelper::MINUTE_LIMIT_BANNER).and_return(user_dismissed_banner)
end
it 'shows the banner if required' do
expect(helper.show_minute_limit_banner?(project)).to eq(should_show_banner)
end
end
end
context 'not dot com' do
context 'when feature flag is enabled for a free project and user has not dismissed callout' do
before do
stub_feature_flags(show_minute_limit_banner: true)
allow(project.root_ancestor).to receive(:free_plan?).and_return(true)
allow(helper).to receive(:user_dismissed?).with(Users::CalloutsHelper::MINUTE_LIMIT_BANNER).and_return(false)
end
it 'does not show banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(false)
end
end
end
end
end
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