Commit 4d29bbac authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '301032-license-creation-via-api' into 'master'

Update expiry setting when license is created

See merge request gitlab-org/gitlab!54550
parents f63f8884 4e306ccf
---
title: Hide repeated trial offers on self-hosted instances
merge_request: 54550
author:
type: fixed
......@@ -39,8 +39,6 @@ class Admin::LicensesController < Admin::ApplicationController
respond_with(@license, location: admin_license_path) do
if @license.save
@license.update_trial_setting
notice = if @license.started?
_('The license was successfully uploaded and is now active. You can see the details below.')
else
......
......@@ -241,6 +241,7 @@ class License < ApplicationRecord
before_validation :reset_license, if: :data_changed?
after_create :reset_current
after_create :update_trial_setting
after_destroy :reset_current
after_commit :reset_future_dated, on: [:create, :destroy]
after_commit :reset_previous, on: [:create, :destroy]
......
......@@ -1229,9 +1229,9 @@ RSpec.describe License do
gl_license.expires_at = Date.tomorrow
end
it 'returns nil' do
updated = license.update_trial_setting
expect(updated).to be_nil
it 'does nothing' do
license.save
expect(ApplicationSetting.current.license_trial_ends_on).to be_nil
end
end
......@@ -1248,10 +1248,9 @@ RSpec.describe License do
expect(described_class.eligible_for_trial?).to be_truthy
end
it 'updates the trial setting' do
updated = license.update_trial_setting
it 'updates the trial setting during create' do
license.save
expect(updated).to be_truthy
expect(described_class.eligible_for_trial?).to be_falsey
expect(ApplicationSetting.current.license_trial_ends_on).to eq(tomorrow)
end
......@@ -1267,8 +1266,8 @@ RSpec.describe License do
end
it 'does not update existing trial setting' do
updated = license.update_trial_setting
expect(updated).to be_falsey
license.save
expect(ApplicationSetting.current.license_trial_ends_on).to eq(yesterday)
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