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
5300d93e
Commit
5300d93e
authored
Dec 16, 2021
by
Corinna Wiesner
Committed by
Heinrich Lee Yu
Dec 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render manual quarterly co-term banner
parent
15b3414b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
198 additions
and
0 deletions
+198
-0
app/views/admin/dashboard/index.html.haml
app/views/admin/dashboard/index.html.haml
+1
-0
ee/app/helpers/manual_quarterly_co_term_banner_helper.rb
ee/app/helpers/manual_quarterly_co_term_banner_helper.rb
+11
-0
ee/app/views/admin/subscriptions/show.html.haml
ee/app/views/admin/subscriptions/show.html.haml
+1
-0
ee/app/views/shared/_manual_quarterly_reconciliation_banner.html.haml
.../shared/_manual_quarterly_reconciliation_banner.html.haml
+15
-0
ee/spec/features/admin/admin_dashboard_spec.rb
ee/spec/features/admin/admin_dashboard_spec.rb
+1
-0
ee/spec/features/admin/subscriptions/admin_views_subscription_spec.rb
...ures/admin/subscriptions/admin_views_subscription_spec.rb
+1
-0
ee/spec/helpers/manual_quarterly_co_term_banner_helper_spec.rb
...ec/helpers/manual_quarterly_co_term_banner_helper_spec.rb
+86
-0
ee/spec/support/features/manual_quarterly_co_term_banner_examples.rb
...port/features/manual_quarterly_co_term_banner_examples.rb
+82
-0
No files found.
app/views/admin/dashboard/index.html.haml
View file @
5300d93e
...
...
@@ -4,6 +4,7 @@
-
billable_users_link_start
=
'<a href="%{url}" target="_blank" rel="noopener noreferrer nofollow">'
.
html_safe
%
{
url:
billable_users_url
}
=
render_if_exists
'shared/manual_renewal_banner'
=
render_if_exists
'shared/manual_quarterly_reconciliation_banner'
=
render_if_exists
'shared/qrtly_reconciliation_alert'
=
render
'admin/dashboard/security_newsletter_callout'
...
...
ee/app/helpers/manual_quarterly_co_term_banner_helper.rb
0 → 100644
View file @
5300d93e
# frozen_string_literal: true
module
ManualQuarterlyCoTermBannerHelper
def
manual_quarterly_co_term_banner
return
unless
current_user
&
.
can_admin_all_resources?
upcoming_reconciliation
=
GitlabSubscriptions
::
UpcomingReconciliation
.
next
Gitlab
::
ManualQuarterlyCoTermBanner
.
new
(
actionable:
upcoming_reconciliation
)
end
end
ee/app/views/admin/subscriptions/show.html.haml
View file @
5300d93e
...
...
@@ -2,5 +2,6 @@
-
page_title
_
(
'Subscription'
)
=
render_if_exists
'shared/manual_renewal_banner'
=
render_if_exists
'shared/manual_quarterly_reconciliation_banner'
#js-show-subscription-page
{
data:
cloud_license_view_data
}
ee/app/views/shared/_manual_quarterly_reconciliation_banner.html.haml
0 → 100644
View file @
5300d93e
-
payload
=
manual_quarterly_co_term_banner
-
return
unless
payload
&
.
display?
=
content_for
:page_level_alert
do
=
render
'shared/global_alert'
,
title:
payload
.
subject
,
variant:
payload
.
display_error_version?
?
:danger
:
:warning
,
close_button_class:
'js-close'
,
alert_class:
'gl-my-5'
,
alert_data:
{
testid:
'close-manual-quarterly-co-term-banner'
}
do
.gl-alert-body
=
payload
.
body
.gl-alert-actions
=
link_to
s_
(
'SubscriptionBanner|Export license usage file'
),
admin_license_usage_export_path
(
format: :csv
),
class:
'btn gl-alert-action gl-button btn-confirm'
=
link_to
s_
(
'SubscriptionBanner|Upload new license'
),
new_admin_license_path
,
class:
'btn gl-alert-action gl-button btn-default'
ee/spec/features/admin/admin_dashboard_spec.rb
View file @
5300d93e
...
...
@@ -100,4 +100,5 @@ RSpec.describe 'Admin Dashboard' do
end
include_examples
'manual renewal banner'
,
path_to_visit: :admin_subscription_path
include_examples
'manual quarterly co-term banner'
,
path_to_visit: :admin_subscription_path
end
ee/spec/features/admin/subscriptions/admin_views_subscription_spec.rb
View file @
5300d93e
...
...
@@ -225,6 +225,7 @@ RSpec.describe 'Admin views Subscription', :js do
end
include_examples
'manual renewal banner'
,
path_to_visit: :admin_subscription_path
include_examples
'manual quarterly co-term banner'
,
path_to_visit: :admin_subscription_path
private
...
...
ee/spec/helpers/manual_quarterly_co_term_banner_helper_spec.rb
0 → 100644
View file @
5300d93e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
ManualQuarterlyCoTermBannerHelper
do
describe
'#manual_quarterly_co_term_banner'
do
subject
(
:manual_quarterly_co_term_banner
)
{
helper
.
manual_quarterly_co_term_banner
}
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
current_user
)
end
context
'when current user is empty'
do
let
(
:current_user
)
{
nil
}
it
'does not return a banner payload'
do
expect
(
manual_quarterly_co_term_banner
).
to
eq
(
nil
)
end
end
context
'when current user cannot admin all resources'
do
it
'does not return a banner payload'
do
expect
(
manual_quarterly_co_term_banner
).
to
eq
(
nil
)
end
end
context
'when current user can admin all resources'
do
before
do
allow
(
current_user
).
to
receive
(
:can_admin_all_resources?
).
and_return
(
true
)
allow_next_instance_of
(
Gitlab
::
ManualQuarterlyCoTermBanner
)
do
|
banner
|
allow
(
banner
).
to
receive
(
:display?
).
and_return
(
display_banner
)
end
end
context
'when no banner instance is returned'
do
let
(
:display_banner
)
{
false
}
it
'does not return a banner payload'
do
aggregate_failures
do
expect
(
manual_quarterly_co_term_banner
).
to
be_an_instance_of
(
Gitlab
::
ManualQuarterlyCoTermBanner
)
expect
(
manual_quarterly_co_term_banner
.
subject
).
to
eq
(
nil
)
end
end
end
context
'when a banner instance is returned'
do
let
(
:display_banner
)
{
true
}
let
(
:upcoming_reconciliation
)
do
create
(
:upcoming_reconciliation
,
:self_managed
,
next_reconciliation_date:
next_reconciliation_date
)
end
before
do
allow
(
GitlabSubscriptions
::
UpcomingReconciliation
).
to
receive
(
:next
).
and_return
(
upcoming_reconciliation
)
end
context
'when reconciliation is overdue'
do
let!
(
:next_reconciliation_date
)
{
Date
.
yesterday
}
it
'returns a banner payload'
do
aggregate_failures
do
expect
(
manual_quarterly_co_term_banner
).
to
be_an_instance_of
(
Gitlab
::
ManualQuarterlyCoTermBanner
)
expect
(
manual_quarterly_co_term_banner
.
body
).
to
include
(
'GitLab must now reconcile your subscription'
)
expect
(
manual_quarterly_co_term_banner
.
display_error_version?
).
to
eq
(
true
)
end
end
end
context
'when reconciliation is upcoming'
do
let
(
:next_reconciliation_date
)
{
Date
.
current
+
60
.
days
}
it
'returns a banner payload'
do
aggregate_failures
do
expect
(
manual_quarterly_co_term_banner
).
to
be_an_instance_of
(
Gitlab
::
ManualQuarterlyCoTermBanner
)
expect
(
manual_quarterly_co_term_banner
.
body
).
to
include
(
'GitLab must reconcile your subscription'
)
expect
(
manual_quarterly_co_term_banner
.
display_error_version?
).
to
eq
(
false
)
end
end
end
end
end
end
end
ee/spec/support/features/manual_quarterly_co_term_banner_examples.rb
0 → 100644
View file @
5300d93e
# frozen_string_literal: true
RSpec
.
shared_examples
'manual quarterly co-term banner'
do
|
path_to_visit
:|
shared_examples
'a visible dismissible manual quarterly co-term banner'
do
context
'when dismissed'
do
before
do
page
.
within
(
find
(
'[data-testid="close-manual-quarterly-co-term-banner"]'
,
match: :first
))
do
click_button
'Dismiss'
end
end
it_behaves_like
'a hidden manual quarterly co-term banner'
context
'when visiting again'
do
before
do
visit
current_path
end
it
'displays a banner'
do
expect
(
page
).
to
have_selector
(
'[data-testid="close-manual-quarterly-co-term-banner"]'
)
end
end
end
end
shared_examples
'a hidden manual quarterly co-term banner'
do
it
'does not display a banner'
do
expect
(
page
).
not_to
have_selector
(
'[data-testid="close-manual-quarterly-co-term-banner"]'
)
end
end
describe
'manual quarterly co-term banner'
,
:js
do
let_it_be
(
:reminder_days
)
{
Gitlab
::
ManualQuarterlyCoTermBanner
::
REMINDER_DAYS
}
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
should_check_namespace_plan?
}
create
(
:upcoming_reconciliation
,
type
,
next_reconciliation_date:
reconciliation_date
)
visit
(
send
(
path_to_visit
))
end
context
'when on Gitlab.com'
do
let
(
:reconciliation_date
)
{
Date
.
current
}
let
(
:should_check_namespace_plan?
)
{
true
}
let
(
:type
)
{
:saas
}
it_behaves_like
'a hidden manual quarterly co-term banner'
end
context
'when on self-managed'
do
let
(
:should_check_namespace_plan?
)
{
false
}
let
(
:type
)
{
:self_managed
}
context
'when reconciliation is upcoming'
do
context
'within notification window'
do
let
(
:reconciliation_date
)
{
Date
.
current
+
reminder_days
}
it_behaves_like
'a visible dismissible manual quarterly co-term banner'
end
context
'outside of notification window'
do
let
(
:reconciliation_date
)
{
Date
.
tomorrow
+
reminder_days
}
it_behaves_like
'a hidden manual quarterly co-term banner'
end
end
context
'when reconciliation date was passed'
do
let
(
:reconciliation_date
)
{
Date
.
current
}
it_behaves_like
'a visible dismissible manual quarterly co-term banner'
end
context
'when reconciliation date is outside of the notification window'
do
let
(
:reconciliation_date
)
{
1
.
month
.
from_now
.
to_date
}
it_behaves_like
'a hidden manual quarterly co-term banner'
end
end
end
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