Commit 02a6b3d6 authored by Max Woolf's avatar Max Woolf

Merge branch '348418_add_offline_display_condition_to_banners' into 'master'

Add offline display condition to manual banners

See merge request gitlab-org/gitlab!80658
parents 0290cabf b134f4db
......@@ -11,6 +11,7 @@ module Gitlab
def display?
return false if Gitlab::CurrentSettings.should_check_namespace_plan?
return false unless Feature.enabled?(:automated_email_provision)
return false unless ::License.current&.offline_cloud_license?
require_notification?
end
......
......@@ -4,6 +4,11 @@ require 'spec_helper'
RSpec.describe Gitlab::ManualBanner do
let(:manual_banner) { described_class.new(actionable: nil) }
let(:offline_license?) { true }
before do
create_current_license({ cloud_licensing_enabled: true, offline_cloud_licensing_enabled: offline_license? })
end
describe '#display?' do
subject(:display?) { manual_banner.display? }
......@@ -29,6 +34,12 @@ RSpec.describe Gitlab::ManualBanner do
it { is_expected.to eq(false) }
end
context 'when current license is not an offline cloud license' do
let(:offline_license?) { false }
it { is_expected.to eq(false) }
end
it { expect { display? }.to raise_error(NotImplementedError) }
end
......
......@@ -12,6 +12,11 @@ RSpec.describe Gitlab::ManualQuarterlyCoTermBanner do
end
let(:next_reconciliation_date) { Date.current + 60.days }
let(:offline_license?) { true }
before do
create_current_license({ cloud_licensing_enabled: true, offline_cloud_licensing_enabled: offline_license? })
end
describe '#display?' do
subject(:display?) { manual_quarterly_co_term_banner.display? }
......@@ -37,6 +42,12 @@ RSpec.describe Gitlab::ManualQuarterlyCoTermBanner do
it { is_expected.to eq(false) }
end
context 'when current license is not an offline cloud license' do
let(:offline_license?) { false }
it { is_expected.to eq(false) }
end
context 'when upcoming reconciliation is nil' do
let(:upcoming_reconciliation) { nil }
......
......@@ -9,6 +9,11 @@ RSpec.describe Gitlab::ManualRenewalBanner do
let(:license) { build(:license, expires_at: expires_at, plan: plan) }
let(:expires_at) { Date.current + 1.year }
let(:plan) { License::ULTIMATE_PLAN }
let(:offline_license?) { true }
before do
create_current_license({ cloud_licensing_enabled: true, offline_cloud_licensing_enabled: offline_license? })
end
describe '#display?' do
subject(:display?) { manual_renewal_banner.display? }
......@@ -34,6 +39,12 @@ RSpec.describe Gitlab::ManualRenewalBanner do
it { is_expected.to eq(false) }
end
context 'when current license is not an offline cloud license' do
let(:offline_license?) { false }
it { is_expected.to eq(false) }
end
context 'when license does not expire' do
let(:expires_at) { nil }
......
......@@ -19,6 +19,8 @@ RSpec.shared_examples 'manual quarterly co-term banner' do |path_to_visit:|
before do
allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?) { should_check_namespace_plan? }
create_current_license(cloud_licensing_enabled: true, offline_cloud_licensing_enabled: true)
create(:upcoming_reconciliation, type, next_reconciliation_date: reconciliation_date)
visit(send(path_to_visit))
......
......@@ -17,7 +17,11 @@ RSpec.shared_examples 'manual renewal banner' do |path_to_visit:|
let_it_be(:reminder_days) { Gitlab::ManualRenewalBanner::REMINDER_DAYS }
before do
create_current_license(expires_at: expires_at)
create_current_license(
cloud_licensing_enabled: true,
offline_cloud_licensing_enabled: true,
expires_at: expires_at
)
allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?) { should_check_namespace_plan? }
......
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