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 ...@@ -439,10 +439,12 @@ class License < ApplicationRecord
restricted_attr(:trial) restricted_attr(:trial)
end end
def exclude_guests_from_active_count? def ultimate?
plan == License::ULTIMATE_PLAN plan == License::ULTIMATE_PLAN
end end
alias_method :exclude_guests_from_active_count?, :ultimate?
def remaining_days def remaining_days
return 0 if expired? return 0 if expired?
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
%li %li
%span.light= _('Plan:') %span.light= _('Plan:')
%strong= @license.plan.capitalize %strong= @license.plan.capitalize
= ' - ' - unless @license.ultimate?
= link_to _('How to upgrade'), = ' - '
help_page_path('subscriptions/index.md', anchor: 'upgrade-your-self-managed-subscription-tier'), = link_to _('How to upgrade'),
class: 'inline-link', help_page_path('subscriptions/index.md', anchor: 'upgrade-your-self-managed-subscription-tier'),
target: :_blank, class: 'inline-link',
rel: :noreferrer target: :_blank,
rel: :noreferrer
%li %li
%span.light= _('Uploaded:') %span.light= _('Uploaded:')
%strong= time_ago_with_tooltip @license.created_at %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 ...@@ -767,6 +767,26 @@ RSpec.describe License do
end end
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 describe 'Trial Licenses' do
before do before do
ApplicationSetting.create_from_defaults ApplicationSetting.create_from_defaults
......
...@@ -3,18 +3,31 @@ ...@@ -3,18 +3,31 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'admin/licenses/_info' do 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 context 'when plan can be upgraded' do
assign(:license, license) let(:license) { create(:license, plan: License::STARTER_PLAN) }
end
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 'does not show "How to upgrade" link' do
it 'shows "How to upgrade" link' do render
render
expect(rendered).to have_content('Plan: Starter - How to upgrade') expect(rendered).to have_content('Plan: Ultimate')
expect(rendered).to have_link('How to upgrade') expect(rendered).not_to have_link('How to upgrade')
end
end end
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