Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fda2b5ad
Commit
fda2b5ad
authored
May 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only look at year before license was issued.
parent
d180f404
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
app/models/license.rb
app/models/license.rb
+5
-2
app/views/admin/licenses/show.html.haml
app/views/admin/licenses/show.html.haml
+2
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+9
-1
No files found.
app/models/license.rb
View file @
fda2b5ad
...
...
@@ -96,15 +96,18 @@ class License < ActiveRecord::Base
return
unless
self
.
license?
&&
self
.
restricted?
(
:active_user_count
)
restricted_user_count
=
self
.
restrictions
[
:active_user_count
]
date_range
=
(
self
.
issued_at
-
1
.
year
)
..
self
.
issued_at
active_user_count
=
HistoricalData
.
during
(
date_range
).
maximum
(
:active_user_count
)
||
0
active_user_count
=
HistoricalData
.
up_until
(
self
.
issued_at
).
maximum
(
:active_user_count
)
||
0
return
unless
active_user_count
return
if
active_user_count
<
restricted_user_count
overage
=
active_user_count
-
restricted_user_count
message
=
""
message
<<
"
At one point
, this GitLab installation had "
message
<<
"
During the year before this license was issued
, 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
)
}
. "
...
...
app/views/admin/licenses/show.html.haml
View file @
fda2b5ad
...
...
@@ -65,7 +65,8 @@
%strong
Exceeds license limit
-
historical
=
HistoricalData
.
up_until
(
@license
.
issued_at
).
maximum
(
:active_user_count
)
-
date_range
=
(
Date
.
today
-
1
.
year
)
..
Date
.
today
-
historical
=
HistoricalData
.
during
(
date_range
).
maximum
(
:active_user_count
)
-
if
historical
%li
%span
.light
Maximum active users:
...
...
spec/models/license_spec.rb
View file @
fda2b5ad
...
...
@@ -53,13 +53,21 @@ describe License do
end
end
context
"before the license was issued"
do
context
"
in the year
before the license was issued"
do
let
(
:date
)
{
License
.
current
.
issued_at
-
6
.
months
}
it
"is invalid"
do
expect
(
license
).
to_not
be_valid
end
end
context
"earlier than a year before the license was issued"
do
let
(
:date
)
{
License
.
current
.
issued_at
-
2
.
years
}
it
"is valid"
do
expect
(
license
).
to
be_valid
end
end
end
context
"when the active user count restriction is not exceeded"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment