Commit c1935190 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'vij-fix-subgroup-expiration-banner' into 'master'

Fix expiring subscription message on subgroups

See merge request gitlab-org/gitlab!64507
parents e857908f 5627974d
......@@ -120,7 +120,7 @@ module Gitlab
end
def subscription_future_renewal?
return if self_managed? || namespace.nil? || !namespace.gitlab_subscription.present?
return if self_managed? || namespace.nil? || !namespace.closest_gitlab_subscription.present?
::GitlabSubscriptions::CheckFutureRenewalService.new(namespace: namespace).execute
end
......
......@@ -208,9 +208,10 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
context 'with namespace' do
using RSpec::Parameterized::TableSyntax
let(:has_future_renewal) { false }
let_it_be(:group_with_plan) { create(:group_with_plan, name: 'No Limit Records') }
let_it_be(:namespace) { create(:group_with_plan, name: 'No Limit Records') }
let(:has_future_renewal) { false }
let(:namespace) { group_with_plan }
before do
allow_next_instance_of(GitlabSubscriptions::CheckFutureRenewalService, namespace: namespace) do |service|
......@@ -279,6 +280,22 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
subject
end
end
context 'with a sub-group' do
let(:namespace) { build(:group, parent: group_with_plan) }
it 'checks for a future renewal' do
expect(GitlabSubscriptions::CheckFutureRenewalService).to receive(:new)
subject
end
context 'when parent namespace has a future renewal' do
let(:has_future_renewal) { true }
it { is_expected.to be_nil }
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