Commit df904001 authored by Corinna Wiesner's avatar Corinna Wiesner

Allow licenses with a 10% overage of users for renewals

There already was a 10% overage allowance when applying a new license
(no renewals). Now, the same overage will be applied to all license
uploads for the users count.

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67507
EE: true
parent f23f3109
......@@ -656,9 +656,6 @@ class License < ApplicationRecord
end
def restricted_user_count_with_threshold
# overage should only be applied for new subscriptions not for renewals.
return restricted_user_count if previous_user_count
(restricted_user_count * (1 + ALLOWED_PERCENTAGE_OF_USERS_OVERAGE)).to_i
end
......@@ -667,7 +664,7 @@ class License < ApplicationRecord
return unless restricted_user_count
if previous_user_count && (prior_historical_max <= previous_user_count)
return if restricted_user_count >= daily_billable_users_count
return if restricted_user_count_with_threshold >= daily_billable_users_count
else
return if restricted_user_count_with_threshold >= prior_historical_max
end
......
......@@ -218,16 +218,28 @@ RSpec.describe License do
HistoricalData.track!
end
context 'when license is from a fresh subscription' do
let(:previous_user_count) { nil }
shared_examples 'current active user count within threshold' do
context 'when current active users count is under the threshold' do
let(:current_active_users_count) { 10 }
it 'accepts the license' do
expect(new_license).to be_valid
end
end
context 'when current active users count is equal to the threshold' do
let(:current_active_users_count) { 11 }
it 'accepts the license' do
expect(new_license).to be_valid
end
end
end
context 'when license is from a fresh subscription' do
let(:previous_user_count) { nil }
include_examples 'current active user count within threshold'
context 'when current active users count is above the threshold' do
let(:current_active_users_count) { 12 }
......@@ -256,8 +268,10 @@ RSpec.describe License do
context 'when license is from a renewal' do
let(:previous_user_count) { 1 }
context 'when current active users count is under the threshold' do
let(:current_active_users_count) { 11 }
include_examples 'current active user count within threshold'
context 'when current active users count is over the threshold' do
let(:current_active_users_count) { 12 }
it 'does not accept the license' do
expect(new_license).not_to be_valid
......
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