Commit 7434421c authored by Doug Stull's avatar Doug Stull

Hide how-to-upgrade link if ultimate plan

- no need to show how-to-upgrade link if
  we are already on the highest possible.
parent ff28d00a
......@@ -439,10 +439,12 @@ class License < ApplicationRecord
restricted_attr(:trial)
end
def exclude_guests_from_active_count?
def ultimate?
plan == License::ULTIMATE_PLAN
end
alias_method :exclude_guests_from_active_count?, :ultimate?
def remaining_days
return 0 if expired?
......
......@@ -16,12 +16,13 @@
%li
%span.light= _('Plan:')
%strong= @license.plan.capitalize
= ' - '
= link_to _('How to upgrade'),
help_page_path('subscriptions/index.md', anchor: 'upgrade-your-self-managed-subscription-tier'),
class: 'inline-link',
target: :_blank,
rel: :noreferrer
- unless @license.ultimate?
= ' - '
= link_to _('How to upgrade'),
help_page_path('subscriptions/index.md', anchor: 'upgrade-your-self-managed-subscription-tier'),
class: 'inline-link',
target: :_blank,
rel: :noreferrer
%li
%span.light= _('Uploaded:')
%strong= time_ago_with_tooltip @license.created_at
......
---
title: Hide the upgrade link on the admin license page if plan Ultimate
merge_request: 40977
author:
type: changed
......@@ -767,6 +767,26 @@ RSpec.describe License do
end
end
describe '#ultimate?' do
using RSpec::Parameterized::TableSyntax
let(:license) { build(:license, plan: plan) }
subject { license.ultimate? }
where(:plan, :expected) do
nil | false
described_class::STARTER_PLAN | false
described_class::PREMIUM_PLAN | false
described_class::EARLY_ADOPTER_PLAN | false
described_class::ULTIMATE_PLAN | true
end
with_them do
it { is_expected.to eq(expected) }
end
end
describe 'Trial Licenses' do
before do
ApplicationSetting.create_from_defaults
......
......@@ -3,18 +3,31 @@
require 'spec_helper'
RSpec.describe 'admin/licenses/_info' do
let_it_be(:license) { create(:license) }
context 'when observing the license' do
before do
assign(:license, license)
end
before do
assign(:license, license)
end
context 'when plan can be upgraded' do
let(:license) { create(:license, plan: License::STARTER_PLAN) }
it 'shows "How to upgrade" link' do
render
expect(rendered).to have_content('Plan: Starter - How to upgrade')
expect(rendered).to have_link('How to upgrade')
end
end
context 'when plan can not be upgraded' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) }
context 'when observing licensees' do
it 'shows "How to upgrade" link' do
render
it 'does not show "How to upgrade" link' do
render
expect(rendered).to have_content('Plan: Starter - How to upgrade')
expect(rendered).to have_link('How to upgrade')
expect(rendered).to have_content('Plan: Ultimate')
expect(rendered).not_to have_link('How to upgrade')
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