Commit 03e379f2 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Prevent future renewal checks if no gitlab subscription

parent 112b08b6
...@@ -120,7 +120,7 @@ module Gitlab ...@@ -120,7 +120,7 @@ module Gitlab
end end
def subscription_future_renewal? def subscription_future_renewal?
return if self_managed? || namespace.nil? return if self_managed? || namespace.nil? || !namespace.gitlab_subscription.present?
::GitlabSubscriptions::CheckFutureRenewalService.new(namespace: namespace).execute ::GitlabSubscriptions::CheckFutureRenewalService.new(namespace: namespace).execute
end end
......
...@@ -112,7 +112,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -112,7 +112,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
context 'with namespace' do context 'with namespace' do
let(:has_future_renewal) { false } let(:has_future_renewal) { false }
let_it_be(:namespace) { create(:group, name: 'No Limit Records') } let_it_be(:namespace) { create(:group_with_plan, name: 'No Limit Records') }
before do before do
allow_next_instance_of(GitlabSubscriptions::CheckFutureRenewalService, namespace: namespace) do |service| allow_next_instance_of(GitlabSubscriptions::CheckFutureRenewalService, namespace: namespace) do |service|
...@@ -141,6 +141,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -141,6 +141,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
context 'without gitlab_subscription' do
let(:namespace) { build(:group, name: 'No Subscription Records') }
it 'does not check for a future renewal' do
expect(GitlabSubscriptions::CheckFutureRenewalService).not_to receive(:new)
subject
end
end
end end
end end
...@@ -200,12 +210,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -200,12 +210,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let(:has_future_renewal) { false } let(:has_future_renewal) { false }
let_it_be(:namespace) { create(:group, name: 'No Limit Records') } let_it_be(:namespace) { create(:group_with_plan, name: 'No Limit Records') }
before do before do
allow_next_instance_of(GitlabSubscriptions::CheckFutureRenewalService, namespace: namespace) do |service| allow_next_instance_of(GitlabSubscriptions::CheckFutureRenewalService, namespace: namespace) do |service|
allow(service).to receive(:execute).and_return(has_future_renewal) allow(service).to receive(:execute).and_return(has_future_renewal)
end end
allow_next_instance_of(Group) do |group|
allow(group).to receive(:gitlab_subscription).and_return(gitlab_subscription)
end
end end
where plan: %w(gold ultimate) where plan: %w(gold ultimate)
...@@ -255,6 +269,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -255,6 +269,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
context 'without gitlab_subscription' do
let(:namespace) { build(:group, name: 'No Subscription Records') }
it 'does not check for a future renewal' do
expect(GitlabSubscriptions::CheckFutureRenewalService).not_to receive(:new)
subject
end
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