Commit 31abe9c5 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '341211-hide-banner-before-elegible-saas' into 'master'

Hide subs expiration banner before eligible

See merge request gitlab-org/gitlab!77625
parents 38cca778 c50aac98
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
class SubscriptionPresenter < Gitlab::View::Presenter::Delegated class SubscriptionPresenter < Gitlab::View::Presenter::Delegated
GRACE_PERIOD_EXTENSION_DAYS = 14.days GRACE_PERIOD_EXTENSION_DAYS = 14.days
RENEWAL_ALLOWED_PERIOD_DAYS = 15
presents ::Subscription, as: :subscription presents ::Subscription, as: :subscription
...@@ -14,7 +15,7 @@ class SubscriptionPresenter < Gitlab::View::Presenter::Delegated ...@@ -14,7 +15,7 @@ class SubscriptionPresenter < Gitlab::View::Presenter::Delegated
end end
def notify_admins? def notify_admins?
remaining_days && remaining_days < 30 remaining_days.present? && remaining_days <= RENEWAL_ALLOWED_PERIOD_DAYS
end end
def notify_users? def notify_users?
......
...@@ -115,11 +115,11 @@ RSpec.describe 'Expiring Subscription Message', :js, :freeze_time do ...@@ -115,11 +115,11 @@ RSpec.describe 'Expiring Subscription Message', :js, :freeze_time do
end end
end end
context 'with a license expiring in less than 30 days' do context 'with a license expiring in less than 15 days' do
let(:end_date) { Date.current + 29.days } let(:end_date) { Date.current + 14.days }
it 'notifies the group owner of a soon expiring subscription' do it 'notifies the group owner of a soon expiring subscription' do
expect(page).to have_content('Your subscription will expire in 29 days') expect(page).to have_content('Your subscription will expire in 14 days')
end end
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe SubscriptionPresenter, :saas do RSpec.describe SubscriptionPresenter, :saas do
using RSpec::Parameterized::TableSyntax
let(:subscription) { create(:gitlab_subscription) } let(:subscription) { create(:gitlab_subscription) }
let(:presenter) { described_class.new(subscription) } let(:presenter) { described_class.new(subscription) }
...@@ -15,26 +17,20 @@ RSpec.describe SubscriptionPresenter, :saas do ...@@ -15,26 +17,20 @@ RSpec.describe SubscriptionPresenter, :saas do
describe '#notify_admins?' do describe '#notify_admins?' do
subject { presenter.notify_admins? } subject { presenter.notify_admins? }
let(:today) { Time.utc(2020, 3, 7, 10) } where(:remaining_days_count, :expected_result) do
nil | false
it 'is false when remaining days is nil' do 0 | true
expect(subject).to be false described_class::RENEWAL_ALLOWED_PERIOD_DAYS - 1.day | true
described_class::RENEWAL_ALLOWED_PERIOD_DAYS | true
described_class::RENEWAL_ALLOWED_PERIOD_DAYS + 1.day | false
end end
it 'remaining days more than 30 is false' do with_them do
allow(subscription).to receive(:end_date).and_return(Time.utc(2020, 4, 9, 10).to_date) before do
allow(presenter).to receive(:remaining_days).and_return(remaining_days_count)
travel_to(today) do
expect(subject).to be false
end end
end
it 'remaining days less than 30 is true' do
allow(subscription).to receive(:end_date).and_return(Time.utc(2020, 3, 9, 10).to_date)
travel_to(today) do it { expect(subject).to be(expected_result) }
expect(subject).to be true
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