Commit be326b7f authored by Krasimir Angelov's avatar Krasimir Angelov

Remove not existing feature flag from tests

Tests for `EE::SubscribableBannerHelper` were testing against feature
flag that do not exists (`subscribable_banner`). Remove this flag from
tests, and add some tests for when `subscribable_subscription_banner` is
enabled/disabled.

See https://gitlab.com/gitlab-org/gitlab/-/issues/295308.
parent e9245077
...@@ -16,60 +16,42 @@ RSpec.describe EE::SubscribableBannerHelper do ...@@ -16,60 +16,42 @@ RSpec.describe EE::SubscribableBannerHelper do
end end
end end
context 'when feature flag is enabled' do let(:license) { double(:license) }
let(:license) { double(:license) }
context 'when instance variable true' do
before do before do
stub_feature_flags(subscribable_banner: true) assign(:display_subscription_banner, true)
end end
context 'when instance variable true' do context 'when should_check_namespace_plan is true' do
before do before do
assign(:display_subscription_banner, true) allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end end
context 'when should_check_namespace_plan is true' do context 'when a project exists' do
before do let(:entity) { create(:project) }
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end
context 'when a project exists' do
let(:entity) { create(:project) }
before do
assign(:project, entity)
end
it_behaves_like 'when a subscription exists' before do
assign(:project, entity)
end end
context 'when a group exists' do it_behaves_like 'when a subscription exists'
let(:entity) { create(:group) }
before do
assign(:group, entity)
end
it_behaves_like 'when a subscription exists'
end
end end
context 'when should_check_namespace_plan is false' do context 'when a group exists' do
let(:entity) { create(:group) }
before do before do
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(false) assign(:group, entity)
end end
it 'returns the current license' do it_behaves_like 'when a subscription exists'
expect(License).to receive(:current).and_return(license)
expect(subject).to eq(license)
end
end end
end end
context 'when instance variable false' do context 'when should_check_namespace_plan is false' do
before do before do
assign(:display_subscription_banner, false) allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(false)
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end end
it 'returns the current license' do it 'returns the current license' do
...@@ -77,18 +59,30 @@ RSpec.describe EE::SubscribableBannerHelper do ...@@ -77,18 +59,30 @@ RSpec.describe EE::SubscribableBannerHelper do
expect(subject).to eq(license) expect(subject).to eq(license)
end end
end end
end
context 'with a future dated license' do context 'when instance variable false' do
let(:gl_license) { build(:gitlab_license, starts_at: Date.current + 1.month) } before do
assign(:display_subscription_banner, false)
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end
before do it 'returns the current license' do
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true) expect(License).to receive(:current).and_return(license)
end expect(subject).to eq(license)
end
end
it 'returns the current license' do context 'with a future dated license' do
allow(License).to receive(:current).and_return(license) let(:gl_license) { build(:gitlab_license, starts_at: Date.current + 1.month) }
expect(subject).to eq(license)
end before do
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end
it 'returns the current license' do
allow(License).to receive(:current).and_return(license)
expect(subject).to eq(license)
end end
end end
end end
...@@ -98,9 +92,9 @@ RSpec.describe EE::SubscribableBannerHelper do ...@@ -98,9 +92,9 @@ RSpec.describe EE::SubscribableBannerHelper do
let(:message) { double(:message) } let(:message) { double(:message) }
context 'when feature flag is enabled' do context 'when subscribable_subscription_banner feature flag is enabled' do
before do before do
stub_feature_flags(subscribable_banner: true) stub_feature_flags(subscribable_subscription_banner: true)
end end
context 'when instance variable true' do context 'when instance variable true' do
...@@ -201,6 +195,19 @@ RSpec.describe EE::SubscribableBannerHelper do ...@@ -201,6 +195,19 @@ RSpec.describe EE::SubscribableBannerHelper do
end end
end end
end end
context 'when subscribable_subscription_banner feature flag is disabled' do
before do
stub_feature_flags(subscribable_subscription_banner: false)
assign(:display_subscription_banner, true)
allow(::Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true)
end
it 'returns the license message' do
expect(helper).to receive(:license_message).and_return(message)
expect(subject).to eq(message)
end
end
end end
describe '#display_subscription_banner!' do describe '#display_subscription_banner!' do
......
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