Commit 764bead2 authored by Stan Hu's avatar Stan Hu

Merge branch '325541_use_licensee_methods' into 'master'

Use licensee methods

See merge request gitlab-org/gitlab!59364
parents c2f72d60 74e6b606
...@@ -361,7 +361,7 @@ class License < ApplicationRecord ...@@ -361,7 +361,7 @@ class License < ApplicationRecord
end end
def data_filename def data_filename
company_name = self.licensee["Company"] || self.licensee.each_value.first company_name = self.licensee_company || self.licensee.each_value.first
clean_company_name = company_name.gsub(/[^A-Za-z0-9]/, "") clean_company_name = company_name.gsub(/[^A-Za-z0-9]/, "")
"#{clean_company_name}.gitlab-license" "#{clean_company_name}.gitlab-license"
end end
......
...@@ -34,10 +34,10 @@ module HistoricalUserData ...@@ -34,10 +34,10 @@ module HistoricalUserData
def header_csv def header_csv
CSV.generate do |csv| CSV.generate do |csv|
csv << ['License Key', license.data] csv << ['License Key', license.data]
csv << ['Email', license.licensee['Email']] csv << ['Email', license.licensee_email]
csv << ['License Start Date', license.starts_at&.to_s(:csv)] csv << ['License Start Date', license.starts_at&.to_s(:csv)]
csv << ['License End Date', license.expires_at&.to_s(:csv)] csv << ['License End Date', license.expires_at&.to_s(:csv)]
csv << ['Company', license.licensee['Company']] csv << ['Company', license.licensee_company]
csv << ['Generated At', Time.current.to_s(:csv)] csv << ['Generated At', Time.current.to_s(:csv)]
csv << [''] csv << ['']
end end
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
= render 'admin/licenses/license_status' = render 'admin/licenses/license_status'
%span.gl-ml-5 %span.gl-ml-5
= _('Licensed to:') = _('Licensed to:')
%strong= @license.licensee['Name'] %strong= @license.licensee_name
= "(#{@license.licensee['Email']})" = "(#{@license.licensee_email})"
%div %div
= link_to 'View details', admin_license_path, class: "gl-button btn btn-default" = link_to 'View details', admin_license_path, class: "gl-button btn btn-default"
...@@ -21,7 +21,7 @@ class ActiveUserCountThresholdWorker # rubocop:disable Scalability/IdempotentWor ...@@ -21,7 +21,7 @@ class ActiveUserCountThresholdWorker # rubocop:disable Scalability/IdempotentWor
.to_set .to_set
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
recipients << license.licensee["Email"] if license.licensee["Email"] recipients << license.licensee_email if license.licensee_email
LicenseMailer.approaching_active_user_count_limit(recipients.to_a) LicenseMailer.approaching_active_user_count_limit(recipients.to_a)
end end
......
...@@ -755,6 +755,24 @@ RSpec.describe License do ...@@ -755,6 +755,24 @@ RSpec.describe License do
end end
end end
describe "#data_filename" do
subject { license.data_filename }
context 'when licensee includes company information' do
let(:gl_license) do
build(:gitlab_license, licensee: { 'Company' => ' Example & Partner Inc. 2 ', 'Name' => 'User Example' })
end
it { is_expected.to eq('ExamplePartnerInc2.gitlab-license') }
end
context 'when licensee does not include company information' do
let(:gl_license) { build(:gitlab_license, licensee: { 'Name' => 'User Example' }) }
it { is_expected.to eq('UserExample.gitlab-license') }
end
end
describe "#md5" do describe "#md5" do
it "returns the same MD5 for licenses with carriage returns and those without" do it "returns the same MD5 for licenses with carriage returns and those without" do
other_license = build(:license, data: license.data.gsub("\n", "\r\n")) other_license = build(:license, data: license.data.gsub("\n", "\r\n"))
......
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