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
4ddcecab
Commit
4ddcecab
authored
Jun 02, 2020
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do now show user limit banner for overage licenses
parent
d59c77bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
26 deletions
+44
-26
ee/app/helpers/license_monitoring_helper.rb
ee/app/helpers/license_monitoring_helper.rb
+4
-6
ee/spec/features/admin/licenses/show_user_count_threshold_spec.rb
...features/admin/licenses/show_user_count_threshold_spec.rb
+29
-5
ee/spec/helpers/license_monitoring_helper_spec.rb
ee/spec/helpers/license_monitoring_helper_spec.rb
+11
-15
No files found.
ee/app/helpers/license_monitoring_helper.rb
View file @
4ddcecab
...
...
@@ -17,6 +17,9 @@ module LicenseMonitoringHelper
def
show_active_user_count_threshold_banner?
return
if
::
Gitlab
.
com?
return
if
current_license
.
nil?
||
current_license
.
trial?
return
if
user_dismissed?
(
UserCalloutsHelper
::
ACTIVE_USER_COUNT_THRESHOLD
)
return
if
license_is_over_capacity?
current_user
&
.
admin?
&&
active_user_count_threshold_reached?
end
...
...
@@ -30,7 +33,6 @@ module LicenseMonitoringHelper
end
def
active_user_count_threshold_reached?
return
if
current_license
.
nil?
||
current_license
.
trial?
return
if
total_user_count
.
nil?
||
total_user_count
==
1
active_user_count_threshold
[
:value
]
>=
if
active_user_count_threshold
[
:percentage
]
...
...
@@ -48,16 +50,12 @@ module LicenseMonitoringHelper
strong_memoize
(
:current_license_overage
)
{
current_license
.
overage_with_historical_max
}
end
def
current_active_users_count
strong_memoize
(
:current_active_users_count
)
{
current_license
.
current_active_users_count
}
end
def
total_user_count
strong_memoize
(
:total_user_count
)
{
current_license
.
restricted_user_count
}
end
def
remaining_user_count
strong_memoize
(
:remaining_user_count
)
{
total_user_count
-
current_
active_users
_count
}
strong_memoize
(
:remaining_user_count
)
{
total_user_count
-
current_
license
.
maximum_user
_count
}
end
def
active_user_count_threshold
...
...
ee/spec/features/admin/licenses/show_user_count_threshold_spec.rb
View file @
4ddcecab
...
...
@@ -31,12 +31,12 @@ RSpec.describe 'Display approaching user count limit banner', :js do
end
end
before
do
create
(
:historical_data
,
date:
license
.
created_at
+
1
.
month
,
active_user_count:
active_user_count
)
end
context
'with reached user count threshold'
do
before
do
# +1 created admin on line 8
# +1 created user on line 9
create_list
(
:user
,
7
)
end
let
(
:active_user_count
)
{
license_seats_limit
-
1
}
context
'when admin is logged in'
do
before
do
...
...
@@ -44,6 +44,16 @@ RSpec.describe 'Display approaching user count limit banner', :js do
end
it_behaves_like
'a visible banner'
context
'when banner was dismissed'
do
before
do
visit
root_dashboard_path
find
(
'.gl-alert-dismiss'
).
click
end
it_behaves_like
'a hidden banner'
end
end
context
'when regular user is logged in'
do
...
...
@@ -75,7 +85,19 @@ RSpec.describe 'Display approaching user count limit banner', :js do
end
end
context
'when active user count is above license user count'
do
let
(
:active_user_count
)
{
license_seats_limit
+
2
}
before
do
gitlab_sign_in
(
admin
)
end
it_behaves_like
'a hidden banner'
end
context
'without license'
do
let
(
:active_user_count
)
{
license_seats_limit
}
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
...
...
@@ -84,6 +106,8 @@ RSpec.describe 'Display approaching user count limit banner', :js do
end
context
'with trial license'
do
let
(
:active_user_count
)
{
license_seats_limit
}
before
do
allow
(
License
).
to
receive
(
:trial?
).
and_return
(
true
)
end
...
...
ee/spec/helpers/license_monitoring_helper_spec.rb
View file @
4ddcecab
...
...
@@ -11,13 +11,13 @@ RSpec.describe LicenseMonitoringHelper do
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
license_seats_limit
}).
export
)
end
before
do
create
(
:historical_data
,
date:
license
.
created_at
+
1
.
month
,
active_user_count:
active_user_count
)
end
describe
'#show_users_over_license_banner?'
do
subject
{
helper
.
show_users_over_license_banner?
}
before
do
create
(
:historical_data
,
date:
license
.
created_at
+
1
.
month
,
active_user_count:
active_user_count
)
end
context
'when admin is logged in'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
...
...
@@ -74,27 +74,23 @@ RSpec.describe LicenseMonitoringHelper do
end
describe
'#show_active_user_count_threshold_banner?'
do
let_it_be
(
:
current_active_users
_count
)
{
1
}
let_it_be
(
:
active_user
_count
)
{
1
}
subject
{
helper
.
show_active_user_count_threshold_banner?
}
before
do
allow
(
helper
).
to
receive
(
:current_active_users_count
).
and_return
(
current_active_users_count
)
end
context
'when admin user is logged in'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
end
context
'when active users count is above the threshold'
do
let
(
:
current_active_users
_count
)
{
license_seats_limit
-
1
}
let
(
:
active_user
_count
)
{
license_seats_limit
-
1
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when active users count is below the threshold'
do
let
(
:
current_active_users
_count
)
{
1
}
let
(
:
active_user
_count
)
{
1
}
it
{
is_expected
.
to
be_falsey
}
end
...
...
@@ -106,13 +102,13 @@ RSpec.describe LicenseMonitoringHelper do
end
context
'when active users count is above the threshold'
do
let
(
:
current_active_users
_count
)
{
license_seats_limit
-
1
}
let
(
:
active_user
_count
)
{
license_seats_limit
-
1
}
it
{
is_expected
.
to
be_falsey
}
end
context
'when active users count is below the threshold'
do
let
(
:
current_active_users
_count
)
{
1
}
let
(
:
active_user
_count
)
{
1
}
it
{
is_expected
.
to
be_falsey
}
end
...
...
@@ -124,13 +120,13 @@ RSpec.describe LicenseMonitoringHelper do
end
context
'when active users count is above the threshold'
do
let
(
:
current_active_users
_count
)
{
license_seats_limit
-
1
}
let
(
:
active_user
_count
)
{
license_seats_limit
-
1
}
it
{
is_expected
.
to
be_falsey
}
end
context
'when active users count is below the threshold'
do
let
(
:
current_active_users
_count
)
{
1
}
let
(
:
active_user
_count
)
{
1
}
it
{
is_expected
.
to
be_falsey
}
end
...
...
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