Commit 67719d5d authored by Vladlena Shumilo's avatar Vladlena Shumilo

Removes current_license helper method from LicenseHelper

After the removal of memoization, the current_license method
on the LicenseHelper is deprecated
Also some places are optimized to pass the license as a param
parent 3026f3d5
......@@ -28,7 +28,7 @@ module EE
end
def has_start_trial?
!current_license && current_user.admin?
!current_user.has_current_license? && current_user.admin?
end
def analytics_nav_url
......
......@@ -44,6 +44,7 @@ module EE
def upgrade_plan_path(group)
return profile_billings_path if group.blank?
group_billings_path(group)
end
......
......@@ -26,18 +26,14 @@ module LicenseHelper
).message
end
def seats_calculation_message
if current_license&.exclude_guests_from_active_count?
def seats_calculation_message(license:)
if license&.exclude_guests_from_active_count?
content_tag :p do
"Users with a Guest role or those who don't belong to a Project or Group will not use a seat from your license."
end
end
end
def current_license
License.current
end
def current_license_title
License.current&.plan&.titleize || 'Core'
end
......
......@@ -32,7 +32,7 @@
= _(' %{start} to %{end}') % { start: @license.starts_at, end: @license.expires_at }
\.
= _('The %{link_start}true-up model%{link_end} allows having more users, and additional users will incur a retroactive charge on renewal.').html_safe % { link_start: true_up_link_start, link_end: link_end }
= seats_calculation_message
= seats_calculation_message(license: @license)
.col-sm-6.d-flex.pr-0
.info-well.dark-well
.well-segment.well-centered
......
......@@ -5,7 +5,7 @@
- else
%h3.page-title
Your License
- if current_license.trial?
- if @license.trial?
= render "upload_buy_license"
- else
= link_to 'Upload New License', new_admin_license_path, class: "btn btn-success float-right"
......
......@@ -91,15 +91,6 @@ describe LicenseHelper do
end
end
describe '#current_license' do
it 'returns the current license' do
license = double
allow(License).to receive(:current).and_return(license)
expect(current_license).to eq(license)
end
end
describe '#current_license_title' do
context 'when there is a current license' do
context 'and it has a plan associated to it' do
......@@ -130,4 +121,36 @@ describe LicenseHelper do
end
end
end
describe '#seats_calculation_message' do
subject { seats_calculation_message(license: license) }
context 'with a license' do
let(:license) { double("License", 'exclude_guests_from_active_count?' => exclude_guests) }
context 'and guest are excluded from the active count' do
let(:exclude_guests) { true }
it 'returns a tag with the message' do
expect(subject).to eq("<p>Users with a Guest role or those who don&#39;t belong to a Project or Group will not use a seat from your license.</p>")
end
end
context 'and guest are NOT excluded from the active count' do
let(:exclude_guests) { false }
it 'returns nil' do
expect(subject).to be_blank
end
end
end
context 'when the license is blank' do
let(:license) { nil }
it 'returns nil' do
expect(subject).to be_blank
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