Commit c50aac98 authored by Vladlena Shumilo's avatar Vladlena Shumilo

Hide subs expiration banner before eligible

Update the expiration banner to be visible
15 days before expiration

Changelog: changed
EE: true
parent a39524e7
......@@ -2,6 +2,7 @@
class SubscriptionPresenter < Gitlab::View::Presenter::Delegated
GRACE_PERIOD_EXTENSION_DAYS = 14.days
RENEWAL_ALLOWED_PERIOD_DAYS = 15
presents ::Subscription, as: :subscription
......@@ -14,7 +15,7 @@ class SubscriptionPresenter < Gitlab::View::Presenter::Delegated
end
def notify_admins?
remaining_days && remaining_days < 30
remaining_days.present? && remaining_days <= RENEWAL_ALLOWED_PERIOD_DAYS
end
def notify_users?
......
......@@ -115,11 +115,11 @@ RSpec.describe 'Expiring Subscription Message', :js, :freeze_time do
end
end
context 'with a license expiring in less than 30 days' do
let(:end_date) { Date.current + 29.days }
context 'with a license expiring in less than 15 days' do
let(:end_date) { Date.current + 14.days }
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
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe SubscriptionPresenter, :saas do
using RSpec::Parameterized::TableSyntax
let(:subscription) { create(:gitlab_subscription) }
let(:presenter) { described_class.new(subscription) }
......@@ -15,26 +17,20 @@ RSpec.describe SubscriptionPresenter, :saas do
describe '#notify_admins?' do
subject { presenter.notify_admins? }
let(:today) { Time.utc(2020, 3, 7, 10) }
it 'is false when remaining days is nil' do
expect(subject).to be false
where(:remaining_days_count, :expected_result) do
nil | false
0 | true
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
it 'remaining days more than 30 is false' do
allow(subscription).to receive(:end_date).and_return(Time.utc(2020, 4, 9, 10).to_date)
travel_to(today) do
expect(subject).to be false
with_them do
before do
allow(presenter).to receive(:remaining_days).and_return(remaining_days_count)
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
expect(subject).to be true
end
it { expect(subject).to be(expected_result) }
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