Commit 5627974d authored by Vijay Hawoldar's avatar Vijay Hawoldar

Fix expiring subscription message on subgroups

When a sub-group belongs to a namespace that has a future dated
subscription/renewal, users viewing those sub-groups will no longer
see the expiring subscription message

Changelog: fixed
EE: true
parent bf7b31d8
......@@ -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