Skip to content
Snippets Groups Projects
Commit 99720002 authored by Stan Hu's avatar Stan Hu
Browse files

Use current active user count to determine whether license is valid.

Previously, the EE license check used the historical maximum to determine
whether an admin has enough seats for the license. Let's say a customer has a
5-seat license, and sometime during the year he had 20 users. If he/she trims back
to 4 users, the 5-seat license won't work anymore. Right now the workaround is
to issue a license for 20 users.

Closes #550
parent 1cdecf9f
Branches andrey-remove-group-caching
No related tags found
1 merge request!387Use current active user count to determine whether license is valid
Pipeline #12834670 failed
Please view this file on the master branch, on stable branches it's out of date.
 
v 8.8.0 (unreleased)
- Use current active user count to determine whether license is valid
- [Elastic] Database indexer prints its status
- [Elastic][Fix] Database indexer skips projects with invalid HEAD reference
- [Elastic] More efficient snippets search
Loading
Loading
Loading
Loading
@@ -108,7 +108,7 @@ def active_user_count
restricted_user_count = self.restrictions[:active_user_count]
 
date_range = (self.starts_at - 1.year)..self.starts_at
active_user_count = HistoricalData.during(date_range).maximum(:active_user_count) || 0
active_user_count = User.active.count
 
return unless active_user_count
 
Loading
Loading
@@ -117,7 +117,7 @@ def active_user_count
overage = active_user_count - restricted_user_count
 
message = ""
message << "During the year before this license started, this GitLab installation had "
message << "This GitLab installation currently has "
message << "#{number_with_delimiter active_user_count} active #{"user".pluralize(active_user_count)}, "
message << "exceeding this license's limit of #{number_with_delimiter restricted_user_count} by "
message << "#{number_with_delimiter overage} #{"user".pluralize(overage)}. "
Loading
Loading
Loading
Loading
@@ -23,10 +23,13 @@
end
end
 
describe "Historical active user count" do
describe "Active user count" do
let(:active_user_count) { User.active.count + 10 }
let(:date) { License.current.starts_at }
let!(:historical_data) { HistoricalData.create!(date: date, active_user_count: active_user_count) }
before do
allow(User).to receive(:active).and_return(Array.new(active_user_count))
end
 
context "when there is no active user count restriction" do
it "is valid" do
Loading
Loading
@@ -39,34 +42,8 @@
gl_license.restrictions = { active_user_count: active_user_count - 1 }
end
 
context "when the license started" do
it "is invalid" do
expect(license).not_to be_valid
end
end
context "after the license started" do
let(:date) { Date.today }
it "is valid" do
expect(license).to be_valid
end
end
context "in the year before the license started" do
let(:date) { License.current.starts_at - 6.months }
it "is invalid" do
expect(license).not_to be_valid
end
end
context "earlier than a year before the license started" do
let(:date) { License.current.starts_at - 2.years }
it "is valid" do
expect(license).to be_valid
end
it "is invalid" do
expect(license).not_to be_valid
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment