Commit 6ad6dbd8 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '271523-mlunoe-display-eoa-banner-on-billing-pages' into 'master'

Feat(EoA Bronze Plan Banner): add banner

See merge request gitlab-org/gitlab!52607
parents 8cba9f18 ea10b173
......@@ -127,8 +127,20 @@ module BillingPlansHelper
end
end
def show_eoa_banner?(namespace)
return false unless ::Feature.enabled?(:show_billing_eoa_banner)
return false unless Date.current < eoa_bronze_plan_end_date
return false unless namespace.bronze_plan?
(namespace.group? && namespace.has_owner?(current_user.id)) || !namespace.group?
end
private
def eoa_bronze_plan_end_date
Date.parse('2022-01-26')
end
def add_seats_url(group)
return unless group
......
- support_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: EE::CUSTOMER_SUPPORT_URL }
- support_link_end = '</a>'.html_safe
= content_for :flash_message do
= render_if_exists 'shared/billings/eoa_bronze_plan_banner', namespace: namespace, eoa_bronze_plan_end_date: eoa_bronze_plan_end_date
- if current_plan
= render 'shared/billings/billing_plan_header', namespace: namespace, plan: current_plan
......
- if show_eoa_banner?(namespace)
.container-fluid.container-limited.pt-3
.gl-alert.gl-alert-info.mt-3{ role: 'alert' }
= sprite_icon('information-o', css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
%button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') }
= sprite_icon('close', css_class: 'gl-icon')
.gl-alert-body
%h4.gl-alert-title= s_("BillingPlans|End of availability for the Bronze Plan")
- announcement_link = external_link("announcement blog", "https://about.gitlab.com/blog/2021/01/26/new-gitlab-product-subscription-model")
= s_("BillingPlans|While GitLab is ending availability of the Bronze plan, you can still renew your Bronze subscription one additional time before %{eoa_bronze_plan_end_date}. We are also offering a limited time free upgrade to our Premium Plan (up to 25 users)! Learn more about the changes and offers in our %{announcement_link}.").html_safe % { announcement_link: announcement_link, eoa_bronze_plan_end_date: eoa_bronze_plan_end_date.in_time_zone.to_date.to_s(:medium) }
---
title: Add End of Availability banner for Bronze Plans for relevant users
merge_request: 52607
author:
type: added
---
name: show_billing_eoa_banner
introduced_by_url:
rollout_issue_url:
milestone: '13.9'
type: development
group: group::purchase
default_enabled: false
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe BillingPlansHelper do
include Devise::Test::ControllerHelpers
describe '#subscription_plan_data_attributes' do
let(:customer_portal_url) { "#{EE::SUBSCRIPTIONS_URL}/subscriptions" }
......@@ -419,6 +421,118 @@ RSpec.describe BillingPlansHelper do
end
end
describe '#show_eoa_banner?' do
let_it_be(:user) { create(:user) }
stub_feature_flags(show_billing_eoa_banner: true)
shared_examples 'current time' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'displays the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
expect(helper.show_eoa_banner?(namespace)).to eq(true)
end
end
end
shared_examples 'past eoa date' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date + 1.day) do
expect(helper.show_eoa_banner?(namespace)).to eq(false)
end
end
end
shared_examples 'with show_billing_eoa_banner turned off' do
before do
stub_feature_flags(show_billing_eoa_banner: false)
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
expect(helper.show_eoa_banner?(namespace)).to eq(false)
end
end
end
shared_examples 'with a different plan than Bronze' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::SILVER)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
expect(helper.show_eoa_banner?(namespace)).to eq(false)
end
end
end
context 'with group namespace' do
let(:group) { create(:group) }
let(:current_user) { user }
before do
group.add_owner(current_user.id)
allow(group).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
allow(helper).to receive(:current_user).and_return(current_user)
end
it_behaves_like 'current time' do
let(:namespace) { group }
end
it_behaves_like 'past eoa date' do
let(:namespace) { group }
end
it_behaves_like 'with show_billing_eoa_banner turned off' do
let(:namespace) { group }
end
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { group }
end
end
context 'with personal namespace' do
let(:current_user) { user }
before do
allow(current_user.namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it_behaves_like 'current time' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'past eoa date' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'with show_billing_eoa_banner turned off' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { current_user.namespace }
end
end
end
describe '#eoa_bronze_plan_end_date' do
it 'returns a date type value' do
expect(helper.send(:eoa_bronze_plan_end_date).is_a?(Date)).to eq(true)
end
end
describe '#subscription_plan_info' do
it 'returns the current plan' do
other_plan = Hashie::Mash.new(code: 'bronze')
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'shared/billings/_eoa_bronze_plan_banner.html.haml' do
let_it_be(:user) { create(:user) }
let(:eoa_bronze_plan_end_date) { Date.current + 5.days}
stub_feature_flags(show_billing_eoa_banner: true)
shared_examples 'current time' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'displays the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
render
expect(rendered).to have_content("End of availability for the Bronze Plan")
end
end
end
shared_examples 'past eoa date' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date + 1.day) do
render
expect(rendered).not_to have_content("End of availability for the Bronze Plan")
end
end
end
shared_examples 'with show_billing_eoa_banner turned off' do
before do
stub_feature_flags(show_billing_eoa_banner: false)
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
render
expect(rendered).not_to have_content("End of availability for the Bronze Plan")
end
end
end
shared_examples 'with a different plan than Bronze' do
before do
allow(namespace).to receive(:actual_plan_name).and_return(::Plan::SILVER)
end
it 'does not display the banner' do
travel_to(eoa_bronze_plan_end_date - 1.day) do
render
expect(rendered).not_to have_content("End of availability for the Bronze Plan")
end
end
end
before do
allow(view).to receive(:eoa_bronze_plan_end_date).and_return(eoa_bronze_plan_end_date)
end
context 'with group namespace' do
let(:group) { create(:group) }
let(:current_user) { user }
before do
group.add_owner(current_user.id)
allow(group).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
allow(view).to receive(:namespace).and_return(group)
allow(view).to receive(:current_user).and_return(current_user)
end
it_behaves_like 'current time' do
let(:namespace) { group }
end
it_behaves_like 'past eoa date' do
let(:namespace) { group }
end
it_behaves_like 'with show_billing_eoa_banner turned off' do
let(:namespace) { group }
end
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { group }
end
end
context 'with personal namespace' do
let(:current_user) { user }
before do
allow(current_user.namespace).to receive(:actual_plan_name).and_return(::Plan::BRONZE)
allow(view).to receive(:namespace).and_return(current_user.namespace)
end
it_behaves_like 'current time' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'past eoa date' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'with show_billing_eoa_banner turned off' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { current_user.namespace }
end
end
end
......@@ -4466,6 +4466,9 @@ msgstr ""
msgid "BillingPlans|Congratulations, your free trial is activated."
msgstr ""
msgid "BillingPlans|End of availability for the Bronze Plan"
msgstr ""
msgid "BillingPlans|Free upgrade!"
msgstr ""
......@@ -4493,6 +4496,9 @@ msgstr ""
msgid "BillingPlans|To manage the plan for this group, visit the billing section of %{parent_billing_page_link}."
msgstr ""
msgid "BillingPlans|While GitLab is ending availability of the Bronze plan, you can still renew your Bronze subscription one additional time before %{eoa_bronze_plan_end_date}. We are also offering a limited time free upgrade to our Premium Plan (up to 25 users)! Learn more about the changes and offers in our %{announcement_link}."
msgstr ""
msgid "BillingPlans|Your GitLab.com %{plan} trial will %{strong_open}expire after %{expiration_date}%{strong_close}. You can retain access to the %{plan} features by upgrading below."
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