Commit 86e7816e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch 'jswain_dont_display_banner_for_auto_renew_nil' into 'master'

Dont display banner for auto renew nil

See merge request gitlab-org/gitlab!33422
parents 3b1b65e3 e4483e80
...@@ -490,6 +490,10 @@ class License < ApplicationRecord ...@@ -490,6 +490,10 @@ class License < ApplicationRecord
starts_at > Date.current starts_at > Date.current
end end
def auto_renew?
false
end
private private
def restricted_attr(name, default = nil) 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 ...@@ -119,10 +119,19 @@ module Gitlab
end end
def notifiable? def notifiable?
subscribable && signed_in && with_enabled_notifications? && require_notification?
signed_in && end
((is_admin && subscribable.notify_admins?) || subscribable.notify_users?) &&
expired_subscribable_within_notification_window? 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 end
def expired_subscribable_within_notification_window? def expired_subscribable_within_notification_window?
...@@ -145,7 +154,7 @@ module Gitlab ...@@ -145,7 +154,7 @@ module Gitlab
end end
def auto_renew? def auto_renew?
subscribable.try(:auto_renew?) subscribable.auto_renew?
end end
end end
end end
...@@ -22,10 +22,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -22,10 +22,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
context 'subscribable installed' do context 'subscribable installed' do
let(:expired_date) { Time.utc(2020, 3, 9, 10) } let(:expired_date) { Time.utc(2020, 3, 9, 10) }
let(:today) { Time.utc(2020, 3, 7, 10) } let(:today) { Time.utc(2020, 3, 7, 10) }
let(:auto_renew) { false }
before do before do
allow(subscribable).to receive(:plan).and_return('ultimate') allow(subscribable).to receive(:plan).and_return('ultimate')
allow(subscribable).to receive(:expires_at).and_return(expired_date) allow(subscribable).to receive(:expires_at).and_return(expired_date)
allow(subscribable).to receive(:auto_renew?).and_return(auto_renew)
end end
context 'subscribable should not notify admins' do context 'subscribable should not notify admins' do
...@@ -89,9 +91,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -89,9 +91,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end end
context 'is auto_renew' do context 'is auto_renew' do
before do let(:auto_renew) { true }
allow(subscribable).to receive(:auto_renew?).and_return(true)
end
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do Timecop.freeze(today) do
...@@ -181,11 +181,17 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -181,11 +181,17 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end end
end end
context 'is auto_renew' do context 'is auto_renew nil' do
before do let(:auto_renew) { nil }
allow(subscribable).to receive(:auto_renew?).and_return(true)
it 'returns nil' do
expect(subject).to be nil
end
end end
context 'is auto_renew' do
let(:auto_renew) { true }
it 'has a nice subject' do it 'has a nice subject' do
expect(subject).to include('Your subscription will automatically renew in 4 days.') expect(subject).to include('Your subscription will automatically renew in 4 days.')
end end
......
...@@ -963,4 +963,10 @@ RSpec.describe License do ...@@ -963,4 +963,10 @@ RSpec.describe License do
end end
end end
end end
describe '#auto_renew?' do
it 'is false' do
expect(license.auto_renew?).to be false
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