Commit e4483e80 authored by Jay Swain's avatar Jay Swain

Dont display subscription banner if auto_renew nil

In some instances we were showing the subscription banner when
auto_renew was nil. This was more of a data consistency issue and caused
alarm to a lot of customers and added to the support queue.

We've decided to not show the subscription banner if auto_renew is nil.

part of: https://gitlab.com/gitlab-org/growth/product/-/issues/1567
parent a30e935f
......@@ -489,6 +489,10 @@ class License < ApplicationRecord
starts_at > Date.current
end
def auto_renew?
false
end
private
def restricted_attr(name, default = nil)
......
---
title: Dont display subscription banner if auto_renew nil
merge_request: 33422
author:
type: changed
......@@ -119,10 +119,19 @@ module Gitlab
end
def notifiable?
subscribable &&
signed_in &&
((is_admin && subscribable.notify_admins?) || subscribable.notify_users?) &&
expired_subscribable_within_notification_window?
signed_in && with_enabled_notifications? && require_notification?
end
def with_enabled_notifications?
subscribable && ((is_admin && subscribable.notify_admins?) || subscribable.notify_users?)
end
def require_notification?
auto_renew_choice_exists? && expired_subscribable_within_notification_window?
end
def auto_renew_choice_exists?
auto_renew? != nil
end
def expired_subscribable_within_notification_window?
......@@ -145,7 +154,7 @@ module Gitlab
end
def auto_renew?
subscribable.try(:auto_renew?)
subscribable.auto_renew?
end
end
end
......@@ -22,10 +22,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
context 'subscribable installed' do
let(:expired_date) { Time.utc(2020, 3, 9, 10) }
let(:today) { Time.utc(2020, 3, 7, 10) }
let(:auto_renew) { false }
before do
allow(subscribable).to receive(:plan).and_return('ultimate')
allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:auto_renew?).and_return(auto_renew)
end
context 'subscribable should not notify admins' do
......@@ -89,9 +91,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end
context 'is auto_renew' do
before do
allow(subscribable).to receive(:auto_renew?).and_return(true)
end
let(:auto_renew) { true }
it 'has a nice subject' do
Timecop.freeze(today) do
......@@ -181,10 +181,16 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end
end
context 'is auto_renew' do
before do
allow(subscribable).to receive(:auto_renew?).and_return(true)
context 'is auto_renew nil' do
let(:auto_renew) { nil }
it 'returns nil' do
expect(subject).to be nil
end
end
context 'is auto_renew' do
let(:auto_renew) { true }
it 'has a nice subject' do
expect(subject).to include('Your subscription will automatically renew in 4 days.')
......
......@@ -963,4 +963,10 @@ RSpec.describe License do
end
end
end
describe '#auto_renew?' do
it 'is false' do
expect(license.auto_renew?).to be false
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