Commit 375589ea authored by Alper Akgun's avatar Alper Akgun Committed by Mayra Cabrera

Fix billing page regression when trial ends

Fixes a regression which appeared since august 16, 2019.
Users on trial can't access their personal or group billing pages
after their trials expire. Adds tests for the trial views.
Added view tests as trial flow is business critical
parent 42a4a6f8
---
title: Fix error when viewing group billing page
merge_request: 18740
author:
type: fixed
- faq_link = link_to s_("BillingPlans|frequently asked questions"), "https://about.gitlab.com/gitlab-com/#faq"
- pricing_page_link = link_to s_("BillingPlans|Pricing page"), "https://about.gitlab.com/pricing"
- features_link = link_to s_("BillingPlans|features"), "https://about.gitlab.com/features"
- learn_more_text = s_("BillingPlans|Learn more about each plan by reading our %{faq_link}.").html_safe % { faq_link: faq_link }
- if namespace.eligible_for_trial?
= s_("BillingPlans|Learn more about each plan by reading our %{faq_link}, or start a free 30-day trial of GitLab.com Gold.").html_safe % { faq_link: faq_link }
......
# frozen_string_literal: true
require 'spec_helper'
describe 'shared/billings/_trial_status.html.haml' do
include ApplicationHelper
let(:group) { create(:group) }
let(:gitlab_subscription) { create(:gitlab_subscription, namespace: group) }
let(:plan) { nil }
let(:trial_ends_on) { nil }
let(:trial) { false }
before do
gitlab_subscription.update(
hosted_plan: plan,
trial_ends_on: trial_ends_on,
trial: trial
)
end
context 'when not eligible for trial' do
it 'offers to learn more about plans' do
render 'shared/billings/trial_status', namespace: group
expect(rendered).to have_content("Learn more about each plan by visiting our")
end
end
context 'when trial active' do
let(:plan) { create(:bronze_plan) }
let(:trial_ends_on) { Date.tomorrow }
let(:trial) { true }
it 'displays expiry date' do
render 'shared/billings/trial_status', namespace: group
expect(rendered).to have_content("Your GitLab.com trial will expire after #{trial_ends_on}")
end
end
context 'when trial expired' do
let(:plan) { create(:free_plan) }
let(:trial_ends_on) { Date.yesterday }
it 'displays the date is expired' do
render 'shared/billings/trial_status', namespace: group
expect(rendered).to have_content("Your GitLab.com trial expired on #{trial_ends_on}")
end
end
context 'when eligible for trial' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
it 'offers a trial' do
render 'shared/billings/trial_status', namespace: group
expect(rendered).to have_content("start a free 30-day trial of GitLab.com Gold")
end
end
end
......@@ -2415,6 +2415,9 @@ msgstr ""
msgid "BillingPlans|Learn more about each plan by reading our %{faq_link}, or start a free 30-day trial of GitLab.com Gold."
msgstr ""
msgid "BillingPlans|Learn more about each plan by reading our %{faq_link}."
msgstr ""
msgid "BillingPlans|Learn more about each plan by visiting our %{pricing_page_link}."
msgstr ""
......
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