Commit 2405d955 authored by Illya Klymov's avatar Illya Klymov

Merge branch...

Merge branch '238191-hide-the-upgrade-link-on-the-admin-license-page-if-the-current-plan-is-ultimate' into 'master'

Hide the upgrade link on the admin license page if plan Ultimate

Closes #238191

See merge request gitlab-org/gitlab!40977
parents 45b8fcdc 7434421c
......@@ -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