Skip to content
Snippets Groups Projects
Commit c06f91f8 authored by Douwe Maan's avatar Douwe Maan Committed by Job van der Voort
Browse files

Rename issued_at to starts_at.

parent 7c983052
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -219,7 +219,7 @@ GEM
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3)
gitlab-license (0.0.2)
gitlab-license (0.0.3)
gitlab-linguist (3.0.1)
charlock_holmes (~> 0.6.6)
escape_utils (~> 0.2.4)
Loading
Loading
Loading
Loading
@@ -99,20 +99,18 @@ def active_user_count
active_user_count = User.active.count
historical_active_user_count = HistoricalData.maximum(:active_user_count) || 0
 
max_active_user_count = [active_user_count, historical_active_user_count].max
date_range = (self.starts_at - 1.year)..self.starts_at
active_user_count = HistoricalData.during(date_range).maximum(:active_user_count) || 0
return unless active_user_count
 
return if max_active_user_count < restricted_user_count
 
overage = max_active_user_count - restricted_user_count
 
message = ""
message <<
if historical_active_user_count > active_user_count
"At one point, this GitLab installation had "
else
"This GitLab installation has "
end
message << "#{number_with_delimiter max_active_user_count} active #{"user".pluralize(max_active_user_count)}, "
message << "During the year before this license started, this GitLab installation had "
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)}. "
message << "Please upload a license for at least "
Loading
Loading
Loading
Loading
@@ -20,12 +20,12 @@
.panel-heading
Details
%ul.well-list
%li
%span.light Issued:
%strong= time_ago_with_tooltip @license.issued_at
%li
%span.light Uploaded:
%strong= time_ago_with_tooltip @license.created_at
%li
%span.light Started:
%strong= time_ago_with_tooltip @license.starts_at
%li
%span.light
- if @license.expired?
Loading
Loading
@@ -106,8 +106,8 @@
%tr
- @license.licensee.keys.each do |label|
%th= label
%th Issued at
%th Uploaded at
%th Started at
%th Expired at
%th Active users
%tbody
Loading
Loading
@@ -117,10 +117,10 @@
%td= license.licensee[label]
%td
%span
= license.issued_at
= license.created_at
%td
%span
= license.created_at
= license.starts_at
%td
%span
= license.expires_at || "Never"
Loading
Loading
Loading
Loading
@@ -211,7 +211,7 @@
end
 
factory :gitlab_license, class: "Gitlab::License" do
issued_at { Date.today - 1.month }
starts_at { Date.today - 1.month }
licensee do
{ "Name" => Faker::Name.name }
end
Loading
Loading
Loading
Loading
@@ -23,8 +23,10 @@
end
end
 
describe "Active user count" do
let(:active_user_count) { User.active.count }
describe "Historical 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) }
 
context "when there is no active user count restriction" do
it "is valid" do
Loading
Loading
@@ -37,15 +39,15 @@
gl_license.restrictions = { active_user_count: active_user_count - 1 }
end
 
it "is invalid" do
expect(license).to_not be_valid
context "when the license started" do
it "is invalid" do
expect(license).to_not be_valid
end
end
end
 
context "when the active user count restriction is not exceeded" do
before do
gl_license.restrictions = { active_user_count: active_user_count + 1 }
end
context "after the license started" do
let(:date) { Date.today }
 
it "is valid" do
expect(license).to be_valid
Loading
Loading
@@ -53,9 +55,8 @@
end
end
 
describe "Historical active user count" do
let(:active_user_count) { User.active.count + 10 }
let!(:historical_data) { HistoricalData.create!(date: License.current.issued_at, active_user_count: active_user_count) }
context "in the year before the license started" do
let(:date) { License.current.starts_at - 6.months }
 
context "when there is no active user count restriction" do
it "is valid" do
Loading
Loading
@@ -63,10 +64,8 @@
end
end
 
context "when the active user count restriction is exceeded" do
before do
gl_license.restrictions = { active_user_count: active_user_count - 1 }
end
context "earlier than a year before the license started" do
let(:date) { License.current.starts_at - 2.years }
 
it "is invalid" do
expect(license).to_not be_valid
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