Commit 90b901fb authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'jswain_subscription_banner_goes_away' into 'master'

Add spec to ensure banner will disappear

See merge request gitlab-org/gitlab!42534
parents 989d53d3 7fd25956
...@@ -28,6 +28,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -28,6 +28,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(grace_period_effective_from) allow_any_instance_of(Gitlab::ExpiringSubscriptionMessage).to receive(:grace_period_effective_from).and_return(grace_period_effective_from)
end end
around do |example|
Timecop.freeze(today) do
example.run
end
end
context 'subscribable installed' do context 'subscribable installed' do
let(:auto_renew) { false } let(:auto_renew) { false }
...@@ -80,23 +86,17 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -80,23 +86,17 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let(:plan_name) { ::Plan::SILVER } let(:plan_name) { ::Plan::SILVER }
it "shows the expiring message" do it "shows the expiring message" do
Timecop.freeze(today) do expect(subject).to include('Your subscription expired! No worries, you can still use all the Silver features for now. You have 0 days to renew your subscription.')
expect(subject).to include('Your subscription expired! No worries, you can still use all the Silver features for now. You have 0 days to renew your subscription.')
end
end end
end end
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do expect(subject).to include('Your subscription has been downgraded.')
expect(subject).to include('Your subscription has been downgraded.')
end
end end
context 'no namespace' do context 'no namespace' do
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
Timecop.freeze(today) do expect(subject).to include("You didn't renew your subscription so it was downgraded to the GitLab Core Plan")
expect(subject).to include("You didn't renew your subscription so it was downgraded to the GitLab Core Plan")
end
end end
end end
...@@ -104,24 +104,18 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -104,24 +104,18 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let(:namespace) { double(:namespace, name: 'No Limit Records') } let(:namespace) { double(:namespace, name: 'No Limit Records') }
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
Timecop.freeze(today) do expect(subject).to include("You didn't renew your subscription for No Limit Records so it was downgraded to the free plan")
expect(subject).to include("You didn't renew your subscription for No Limit Records so it was downgraded to the free plan")
end
end end
context 'is auto_renew' do context 'is auto_renew' do
let(:auto_renew) { true } let(:auto_renew) { true }
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do expect(subject).to include('Something went wrong with your automatic subscription renewal')
expect(subject).to include('Something went wrong with your automatic subscription renewal')
end
end end
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
Timecop.freeze(today) do expect(subject).to include("We tried to automatically renew your subscription for No Limit Records on 2020-03-01 but something went wrong so your subscription was downgraded to the free plan. Don't worry, your data is safe. We suggest you check your payment method and get in touch with our support team (support@gitlab.com). They'll gladly help with your subscription renewal.")
expect(subject).to include("We tried to automatically renew your subscription for No Limit Records on 2020-03-01 but something went wrong so your subscription was downgraded to the free plan. Don't worry, your data is safe. We suggest you check your payment method and get in touch with our support team (support@gitlab.com). They'll gladly help with your subscription renewal.")
end
end end
end end
end end
...@@ -138,18 +132,14 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -138,18 +132,14 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
it 'has a nice subject' do it 'has a nice subject' do
allow(subscribable).to receive(:will_block_changes?).and_return(false) allow(subscribable).to receive(:will_block_changes?).and_return(false)
Timecop.freeze(today) do expect(subject).to include('Your subscription expired!')
expect(subject).to include('Your subscription expired!')
end
end end
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
allow(subscribable).to receive(:block_changes_at).and_return(Time.utc(2020, 3, 9, 10).to_date) allow(subscribable).to receive(:block_changes_at).and_return(Time.utc(2020, 3, 9, 10).to_date)
allow(subscribable).to receive(:is_a?).with(::License).and_return(true) allow(subscribable).to receive(:is_a?).with(::License).and_return(true)
Timecop.freeze(today) do expect(subject).to include('No worries, you can still use all the Gold features for now. You have 2 days to renew your subscription.')
expect(subject).to include('No worries, you can still use all the Gold features for now. You have 2 days to renew your subscription.')
end
end end
end end
end end
...@@ -163,16 +153,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -163,16 +153,12 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end end
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do expect(subject).to include('Your subscription will expire in 2 days')
expect(subject).to include('Your subscription will expire in 2 days')
end
end end
context 'without namespace' do context 'without namespace' do
it 'has an expiration blocking message' do it 'has an expiration blocking message' do
Timecop.freeze(today) do expect(subject).to include('Your Gold subscription will expire on 2020-03-09. After that, you will not to be able to create issues or merge requests as well as many other features.')
expect(subject).to include('Your Gold subscription will expire on 2020-03-09. After that, you will not to be able to create issues or merge requests as well as many other features.')
end
end end
end end
...@@ -182,25 +168,19 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -182,25 +168,19 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
it 'has gold plan specific messaging' do it 'has gold plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('gold') allow(subscribable).to receive(:plan).and_return('gold')
Timecop.freeze(today) do expect(subject).to include('Your Gold subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or epics as well as many security features.')
expect(subject).to include('Your Gold subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or epics as well as many security features.')
end
end end
it 'has silver plan specific messaging' do it 'has silver plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('silver') allow(subscribable).to receive(:plan).and_return('silver')
Timecop.freeze(today) do expect(subject).to include('Your Silver subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or epics as well as many other features.')
expect(subject).to include('Your Silver subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or epics as well as many other features.')
end
end end
it 'has bronze plan specific messaging' do it 'has bronze plan specific messaging' do
allow(subscribable).to receive(:plan).and_return('bronze') allow(subscribable).to receive(:plan).and_return('bronze')
Timecop.freeze(today) do expect(subject).to include('Your Bronze subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or code quality as well as many other features.')
expect(subject).to include('Your Bronze subscription for No Limit Records will expire on 2020-03-09. After that, you will not to be able to use merge approvals or code quality as well as many other features.')
end
end end
context 'is auto_renew nil' do context 'is auto_renew nil' do
...@@ -238,17 +218,21 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do ...@@ -238,17 +218,21 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let(:grace_period_effective_from) { today.to_date - 40.days } let(:grace_period_effective_from) { today.to_date - 40.days }
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do expect(subject).to include('Your subscription has been downgraded')
expect(subject).to include('Your subscription has been downgraded') end
end end
context 'and is 30 days past the cutoff date' do
let(:grace_period_effective_from) { today.to_date - 60.days }
it 'stops displaying' do
expect(subject).to be nil
end end
end end
context 'and not past the cutoff date' do context 'and not past the cutoff date' do
it 'has a nice subject' do it 'has a nice subject' do
Timecop.freeze(today) do expect(subject).to include('Your subscription will expire in 5 days')
expect(subject).to include('Your subscription will expire in 5 days')
end
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