Commit 71f486c2 authored by Vladlena Shumilo's avatar Vladlena Shumilo

Pass down de license as an argument for optimization

Removes some keyword arguments within LicenseHelper
Passes some licenses to the helper from the view for
optimization
parent 67719d5d
......@@ -18,19 +18,20 @@ module LicenseHelper
License.current&.maximum_user_count || 0
end
def license_message(signed_in: signed_in?, is_admin: current_user&.admin?)
def license_message(signed_in: signed_in?, is_admin: current_user&.admin?, license: License.current)
Gitlab::ExpiringSubscriptionMessage.new(
subscribable: current_license,
subscribable: license,
signed_in: signed_in,
is_admin: is_admin
).message
end
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
def seats_calculation_message(license)
return unless license.present?
return unless 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
......
......@@ -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(license: @license)
= seats_calculation_message(@license)
.col-sm-6.d-flex.pr-0
.info-well.dark-well
.well-segment.well-centered
......
......@@ -2,8 +2,8 @@
- subscribable = decorated_subscription
- message = subscription_message
- else
- subscribable = current_license
- message = license_message
- subscribable = License.current
- message = license_message(license: subscribable)
- if message.present?
.container-fluid.container-limited.pt-3
......
......@@ -208,7 +208,7 @@ describe DashboardHelper, type: :helper do
before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:current_license).and_return(license)
allow(License).to receive(:current).and_return(license)
end
it { is_expected.to eq(output) }
......
......@@ -123,7 +123,7 @@ describe LicenseHelper do
end
describe '#seats_calculation_message' do
subject { seats_calculation_message(license: license) }
subject { seats_calculation_message(license) }
context 'with a license' do
let(:license) { double("License", 'exclude_guests_from_active_count?' => exclude_guests) }
......
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