Commit 8022fef7 authored by Corinna Wiesner's avatar Corinna Wiesner

Show specific content for future-dated licenses

When a current license already exists and a future-dated license is
uploaded the current license's information and breakdown as well as a
license history is displayed. But when no current license exists and a
future-dated license is uploaded then an information message and the
license history is displayed.
parent dc2fbc70
......@@ -7,10 +7,10 @@ class Admin::LicensesController < Admin::ApplicationController
respond_to :html
def show
if @license.blank?
render :missing
else
if @license.present? || License.future_dated_only?
@licenses = License.history
else
render :missing
end
end
......@@ -65,6 +65,7 @@ class Admin::LicensesController < Admin::ApplicationController
def license
@license ||= begin
License.reset_current
License.reset_future_dated
License.current
end
end
......
......@@ -5,13 +5,21 @@
- else
%h3.page-title
Your License
- if @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"
%hr
- if License.future_dated_only?
.gl-alert.gl-alert-info
= sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
.gl-alert-body
%h4.gl-alert-title= s_('You do not have an active license')
= s_('You have a license(s) that activates at a future date. Please see the License History table below.')
- if @license.present?
.row
.col-md-6
.card
......@@ -78,13 +86,15 @@
= render "breakdown", license: @license
- if @licenses.any?
- licensee_keys = @licenses.first.licensee.keys
%h4 License History
.card#license_history
%table.table
%thead.card-header
%tr
- @license.licensee.keys.each do |label|
- licensee_keys.each do |label|
%th= label
%th Plan
%th Uploaded on
......@@ -94,7 +104,7 @@
%tbody
- @licenses.each do |license|
%tr{ class: ('gl-bg-blue-50 font-weight-bold gl-text-blue-500' if license == @license), data: { testid: ('license-current' if license == @license) } }
- @license.licensee.keys.each do |label|
- licensee_keys.each do |label|
%td= license.licensee[label]
%td
%span
......
---
title: Show specific content for future-dated licenses
merge_request: 31463
author:
type: added
......@@ -36,6 +36,7 @@ describe "Admin uploads license" do
it "installs license" do
expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.")
.and have_content("You have a license(s) that activates at a future date. Please see the License History table below.")
end
end
end
......@@ -77,6 +78,7 @@ describe "Admin uploads license" do
context "when license starts in the future" do
let_it_be(:license) { build(:gitlab_license, starts_at: Date.current + 1.month) }
context "when a current license exists" do
it "uploads license" do
attach_and_upload(path)
......@@ -84,6 +86,21 @@ describe "Admin uploads license" do
.and have_content(license.licensee.each_value.first)
end
end
context "when no current license exists" do
before do
allow(License).to receive(:current).and_return(nil)
end
it "uploads license" do
attach_and_upload(path)
expect(page).to have_content("The license was successfully uploaded and will be active from #{license.starts_at}. You can see the details below.")
.and have_content(license.licensee.each_value.first)
.and have_content("You have a license(s) that activates at a future date. Please see the License History table below.")
end
end
end
end
context "when license is invalid" do
......
......@@ -44,12 +44,10 @@ describe "Admin views license" do
end
context "when viewing license history", :aggregate_failures do
let_it_be(:license) { create(:license) }
it "shows licensee" do
license_history = page.find("#license_history")
License.all.each do |license|
License.history.each do |license|
expect(license_history).to have_content(license.licensee.each_value.first)
end
end
......@@ -83,4 +81,44 @@ describe "Admin views license" do
end
end
end
context "when existing licenses only contain a future-dated license" do
let_it_be(:license) { create(:license, data: create(:gitlab_license, starts_at: Date.current + 1.month).export) }
before do
License.where.not(id: license.id).delete_all
visit(admin_license_path)
end
context "when viewing license history" do
it "shows licensee" do
license_history = page.find("#license_history")
expect(license_history).to have_content(license.licensee.each_value.first)
end
it "has no highlighted license", :aggregate_failures do
license_history = page.find("#license_history")
expect(license_history).not_to have_selector("[data-testid='license-current']")
end
it "shows only the future-dated license", :aggregate_failures do
license_history = page.find("#license_history")
license_history_row = license_history.find('tbody tr', match: :first)
expect(license_history).to have_css('tbody tr', count: 1)
expect(license_history_row).to have_content(license.licensee[:name])
expect(license_history_row).to have_content(license.licensee[:email])
expect(license_history_row).to have_content(license.licensee[:company])
expect(license_history_row).to have_content(license.plan.capitalize)
expect(license_history_row).to have_content(license.created_at)
expect(license_history_row).to have_content(license.starts_at)
expect(license_history_row).to have_content(license.expires_at)
expect(license_history_row).to have_content(license.restrictions[:active_user_count])
end
end
end
end
......@@ -24606,6 +24606,9 @@ msgstr ""
msgid "You didn't renew your %{strong}%{plan_name}%{strong_close} subscription so it was downgraded to the GitLab Core Plan."
msgstr ""
msgid "You do not have an active license"
msgstr ""
msgid "You do not have any subscriptions yet"
msgstr ""
......@@ -24654,6 +24657,9 @@ msgstr ""
msgid "You don’t have access to Value Stream Analytics for this group"
msgstr ""
msgid "You have a license(s) that activates at a future date. Please see the License History table below."
msgstr ""
msgid "You have been granted %{access_level} access to the %{source_link} %{source_type}."
msgstr ""
......
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