Commit 29a657fd authored by Michael Lunøe's avatar Michael Lunøe Committed by James Lopez

Fix(subscirbable banner): handle self managed

Ensure that the expirence remains for
self managed licenses
parent 24590717
......@@ -21,8 +21,22 @@ module EE
@display_subscription_banner = true
end
def renew_subscription_path
return plan_renew_url(current_namespace) if decorated_subscription
"#{EE::SUBSCRIPTIONS_URL}/subscriptions"
end
def upgrade_subscription_path
"#{EE::SUBSCRIPTIONS_URL}/subscriptions"
end
private
def current_namespace
@project&.namespace || @group
end
def license_message(signed_in: signed_in?, is_admin: current_user&.admin?, license: License.current)
::Gitlab::ExpiringSubscriptionMessage.new(
subscribable: license,
......@@ -33,13 +47,12 @@ module EE
def subscription_message
entity = @project || @group
namespace = @project&.namespace || @group
::Gitlab::ExpiringSubscriptionMessage.new(
subscribable: decorated_subscription,
signed_in: signed_in?,
is_admin: can?(current_user, :owner_access, entity),
namespace: namespace
namespace: current_namespace
).message
end
......
......@@ -19,7 +19,7 @@
= message
- if subscribable.block_changes?
= link_to _('Upgrade your plan'), 'https://customers.gitlab.com/subscriptions/my_renewal', class: 'btn gl-button btn-primary', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'upgrade' }
= link_to _('Upgrade your plan'), upgrade_subscription_path, class: 'btn gl-button btn-primary', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'upgrade' }
- else
= link_to _('Renew subscription'), 'https://customers.gitlab.com/subscriptions/my_renewal', class: 'btn gl-button btn-primary gl-mr-3 gl-mb-2', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'renew' }
= link_to _('Renew subscription'), renew_subscription_path, class: 'btn gl-button btn-primary gl-mr-3 gl-mb-2', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'renew' }
= link_to _('That is ok, I do not want to renew'), '#', data: { track_event: 'click_text', track_label: 'subscribable_action', track_property: 'thats_ok' }, 'aria-label' => 'Dismiss', class: 'btn gl-button btn-info btn-info-secondary js-close gl-mb-2'
---
title: Update renew/upgrade banner with actionable links
merge_request: 51705
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'layouts/header/_ee_subscribable_banner' do
let(:group) { build(:group) }
let(:project_namespace) { build(:group) }
let(:project) { build(:project, namespace: project_namespace) }
let(:message) { double(:message) }
before do
allow(view).to receive(:gitlab_subscription_or_license).and_return(license)
allow(view).to receive(:gitlab_subscription_message_or_license_message).and_return(message)
end
shared_examples 'displays the correct link' do
context "when license will soon expire" do
let(:license) { build(:gitlab_license, expires_at: Date.current + 5.days) }
it 'shows the renew plan link' do
expect(rendered).to have_link 'Renew subscription', href: view.renew_subscription_path
end
context "when license blocks changes" do
let(:license) { build(:gitlab_license, expires_at: Date.current + 5.days, block_changes_at: Date.today) }
it 'shows the upgrade plan link' do
expect(rendered).to have_link 'Upgrade your plan', href: view.upgrade_subscription_path
end
end
end
context "when license expired" do
let(:license) { build(:gitlab_license, expires_at: Date.yesterday) }
it 'shows the renew plan link' do
expect(rendered).to have_link 'Renew subscription', href: view.renew_subscription_path
end
context "when license blocks changes" do
let(:license) { build(:gitlab_license, expires_at: Date.yesterday, block_changes_at: Date.today) }
it 'shows the upgrade plan link' do
expect(rendered).to have_link 'Upgrade your plan', href: view.upgrade_subscription_path
end
end
end
end
context 'with a group' do
before do
assign(:group, group)
render
end
it_behaves_like 'displays the correct link' do
let(:namespace) { group }
end
end
context 'with a project' do
before do
assign(:project, project)
render
end
it_behaves_like 'displays the correct link' do
let(:namespace) { project.namespace }
end
end
context 'with both a group and a project' do
before do
assign(:group, group)
assign(:project, project)
render
end
it_behaves_like 'displays the correct link' do
let(:namespace) { project.namespace }
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