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
328e928e
Commit
328e928e
authored
Feb 01, 2021
by
Michael Lunøe
Committed by
Stan Hu
Feb 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor(EoA Banner): Migrate to user callout
This also helps persist when the banner has been dismissed
parent
3a77b9d2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
138 deletions
+111
-138
app/models/user_callout.rb
app/models/user_callout.rb
+11
-10
ee/app/helpers/billing_plans_helper.rb
ee/app/helpers/billing_plans_helper.rb
+0
-12
ee/app/helpers/ee/user_callouts_helper.rb
ee/app/helpers/ee/user_callouts_helper.rb
+14
-0
ee/app/views/shared/billings/_eoa_bronze_plan_banner.html.haml
...p/views/shared/billings/_eoa_bronze_plan_banner.html.haml
+2
-2
ee/spec/helpers/billing_plans_helper_spec.rb
ee/spec/helpers/billing_plans_helper_spec.rb
+0
-114
ee/spec/helpers/ee/user_callouts_helper_spec.rb
ee/spec/helpers/ee/user_callouts_helper_spec.rb
+68
-0
ee/spec/views/shared/billings/_eoa_bronze_plan_banner.html.haml_spec.rb
...shared/billings/_eoa_bronze_plan_banner.html.haml_spec.rb
+16
-0
No files found.
app/models/user_callout.rb
View file @
328e928e
...
...
@@ -7,19 +7,19 @@ class UserCallout < ApplicationRecord
gke_cluster_integration:
1
,
gcp_signup_offer:
2
,
cluster_security_warning:
3
,
gold_trial:
4
,
# EE-only
geo_enable_hashed_storage:
5
,
# EE-only
geo_migrate_hashed_storage:
6
,
# EE-only
canary_deployment:
7
,
# EE-only
gold_trial_billings:
8
,
# EE-only
gold_trial:
4
,
# EE-only
geo_enable_hashed_storage:
5
,
# EE-only
geo_migrate_hashed_storage:
6
,
# EE-only
canary_deployment:
7
,
# EE-only
gold_trial_billings:
8
,
# EE-only
suggest_popover_dismissed:
9
,
tabs_position_highlight:
10
,
threat_monitoring_info:
11
,
# EE-only
account_recovery_regular_check:
12
,
# EE-only
threat_monitoring_info:
11
,
# EE-only
account_recovery_regular_check:
12
,
# EE-only
webhooks_moved:
13
,
service_templates_deprecated:
14
,
admin_integrations_moved:
15
,
web_ide_alert_dismissed:
16
,
# no longer in use
web_ide_alert_dismissed:
16
,
# no longer in use
active_user_count_threshold:
18
,
# EE-only
buy_pipeline_minutes_notification_dot:
19
,
# EE-only
personal_access_token_expiry:
21
,
# EE-only
...
...
@@ -27,8 +27,9 @@ class UserCallout < ApplicationRecord
customize_homepage:
23
,
feature_flags_new_version:
24
,
registration_enabled_callout:
25
,
new_user_signups_cap_reached:
26
,
# EE-only
unfinished_tag_cleanup_callout:
27
new_user_signups_cap_reached:
26
,
# EE-only
unfinished_tag_cleanup_callout:
27
,
eoa_bronze_plan_banner:
28
# EE-only
}
validates
:user
,
presence:
true
...
...
ee/app/helpers/billing_plans_helper.rb
View file @
328e928e
...
...
@@ -127,20 +127,8 @@ module BillingPlansHelper
end
end
def
show_eoa_banner?
(
namespace
)
return
false
unless
::
Feature
.
enabled?
(
:show_billing_eoa_banner
)
return
false
unless
Date
.
current
<
eoa_bronze_plan_end_date
return
false
unless
namespace
.
bronze_plan?
(
namespace
.
group?
&&
namespace
.
has_owner?
(
current_user
.
id
))
||
!
namespace
.
group?
end
private
def
eoa_bronze_plan_end_date
Date
.
parse
(
'2022-01-26'
)
end
def
add_seats_url
(
group
)
return
unless
group
...
...
ee/app/helpers/ee/user_callouts_helper.rb
View file @
328e928e
...
...
@@ -13,6 +13,7 @@ module EE
NEW_USER_SIGNUPS_CAP_REACHED
=
'new_user_signups_cap_reached'
PERSONAL_ACCESS_TOKEN_EXPIRY
=
'personal_access_token_expiry'
THREAT_MONITORING_INFO
=
'threat_monitoring_info'
EOA_BRONZE_PLAN_BANNER
=
'eoa_bronze_plan_banner'
def
render_enable_hashed_storage_warning
return
unless
show_enable_hashed_storage_warning?
...
...
@@ -93,8 +94,21 @@ module EE
new_user_signups_cap
.
to_i
<=
::
User
.
billable
.
count
end
def
show_eoa_bronze_plan_banner?
(
namespace
)
return
false
unless
::
Feature
.
enabled?
(
:show_billing_eoa_banner
)
return
false
unless
Date
.
current
<
eoa_bronze_plan_end_date
return
false
unless
namespace
.
bronze_plan?
return
false
if
user_dismissed?
(
EOA_BRONZE_PLAN_BANNER
)
(
namespace
.
group?
&&
namespace
.
has_owner?
(
current_user
.
id
))
||
!
namespace
.
group?
end
private
def
eoa_bronze_plan_end_date
Date
.
parse
(
'2022-01-26'
)
end
def
hashed_storage_enabled?
::
Gitlab
::
CurrentSettings
.
current_application_settings
.
hashed_storage_enabled
end
...
...
ee/app/views/shared/billings/_eoa_bronze_plan_banner.html.haml
View file @
328e928e
-
if
show_eoa_banner?
(
namespace
)
-
if
show_eoa_b
ronze_plan_b
anner?
(
namespace
)
.container-fluid.container-limited.pt-3
.gl-alert.gl-alert-info.
mt-3
{
role:
'alert'
}
.gl-alert.gl-alert-info.
gl-mt-5
{
role:
'alert'
,
data:
{
feature_id:
::
EE
::
UserCalloutsHelper
::
EOA_BRONZE_PLAN_BANNER
,
dismiss_endpoint:
user_callouts_path
}
}
=
sprite_icon
(
'information-o'
,
css_class:
'gl-icon gl-alert-icon gl-alert-icon-no-title'
)
%button
.js-close.gl-alert-dismiss
{
type:
'button'
,
'aria-label'
=>
_
(
'Dismiss'
)
}
=
sprite_icon
(
'close'
,
css_class:
'gl-icon'
)
...
...
ee/spec/helpers/billing_plans_helper_spec.rb
View file @
328e928e
...
...
@@ -3,8 +3,6 @@
require
'spec_helper'
RSpec
.
describe
BillingPlansHelper
do
include
Devise
::
Test
::
ControllerHelpers
describe
'#subscription_plan_data_attributes'
do
let
(
:customer_portal_url
)
{
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/subscriptions"
}
...
...
@@ -421,118 +419,6 @@ RSpec.describe BillingPlansHelper do
end
end
describe
'#show_eoa_banner?'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
stub_feature_flags
(
show_billing_eoa_banner:
true
)
shared_examples
'current time'
do
before
do
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
end
it
'displays the banner'
do
travel_to
(
eoa_bronze_plan_end_date
-
1
.
day
)
do
expect
(
helper
.
show_eoa_banner?
(
namespace
)).
to
eq
(
true
)
end
end
end
shared_examples
'past eoa date'
do
before
do
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
end
it
'does not display the banner'
do
travel_to
(
eoa_bronze_plan_end_date
+
1
.
day
)
do
expect
(
helper
.
show_eoa_banner?
(
namespace
)).
to
eq
(
false
)
end
end
end
shared_examples
'with show_billing_eoa_banner turned off'
do
before
do
stub_feature_flags
(
show_billing_eoa_banner:
false
)
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
end
it
'does not display the banner'
do
travel_to
(
eoa_bronze_plan_end_date
-
1
.
day
)
do
expect
(
helper
.
show_eoa_banner?
(
namespace
)).
to
eq
(
false
)
end
end
end
shared_examples
'with a different plan than Bronze'
do
before
do
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
SILVER
)
end
it
'does not display the banner'
do
travel_to
(
eoa_bronze_plan_end_date
-
1
.
day
)
do
expect
(
helper
.
show_eoa_banner?
(
namespace
)).
to
eq
(
false
)
end
end
end
context
'with group namespace'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:current_user
)
{
user
}
before
do
group
.
add_owner
(
current_user
.
id
)
allow
(
group
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
current_user
)
end
it_behaves_like
'current time'
do
let
(
:namespace
)
{
group
}
end
it_behaves_like
'past eoa date'
do
let
(
:namespace
)
{
group
}
end
it_behaves_like
'with show_billing_eoa_banner turned off'
do
let
(
:namespace
)
{
group
}
end
it_behaves_like
'with a different plan than Bronze'
do
let
(
:namespace
)
{
group
}
end
end
context
'with personal namespace'
do
let
(
:current_user
)
{
user
}
before
do
allow
(
current_user
.
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
end
it_behaves_like
'current time'
do
let
(
:namespace
)
{
current_user
.
namespace
}
end
it_behaves_like
'past eoa date'
do
let
(
:namespace
)
{
current_user
.
namespace
}
end
it_behaves_like
'with show_billing_eoa_banner turned off'
do
let
(
:namespace
)
{
current_user
.
namespace
}
end
it_behaves_like
'with a different plan than Bronze'
do
let
(
:namespace
)
{
current_user
.
namespace
}
end
end
end
describe
'#eoa_bronze_plan_end_date'
do
it
'returns a date type value'
do
expect
(
helper
.
send
(
:eoa_bronze_plan_end_date
).
is_a?
(
Date
)).
to
eq
(
true
)
end
end
describe
'#subscription_plan_info'
do
it
'returns the current plan'
do
other_plan
=
Hashie
::
Mash
.
new
(
code:
'bronze'
)
...
...
ee/spec/helpers/ee/user_callouts_helper_spec.rb
View file @
328e928e
...
...
@@ -3,6 +3,7 @@
require
"spec_helper"
RSpec
.
describe
EE
::
UserCalloutsHelper
do
include
Devise
::
Test
::
ControllerHelpers
using
RSpec
::
Parameterized
::
TableSyntax
describe
'.render_enable_hashed_storage_warning'
do
...
...
@@ -379,4 +380,71 @@ RSpec.describe EE::UserCalloutsHelper do
end
end
end
describe
'#show_eoa_bronze_plan_banner?'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
shared_examples
'shows and hides the banner depending on circumstances'
do
where
(
:show_billing_eoa_banner
,
:actual_plan_name
,
:dismissed_callout
,
:travel_to_date
,
:result
)
do
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
true
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
|
false
true
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
+
1
.
day
|
false
true
|
::
Plan
::
BRONZE
|
true
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
SILVER
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
true
|
::
Plan
::
GOLD
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
false
|
::
Plan
::
BRONZE
|
false
|
eoa_bronze_plan_end_date
-
1
.
day
|
false
end
with_them
do
before
do
stub_feature_flags
(
show_billing_eoa_banner:
show_billing_eoa_banner
)
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
actual_plan_name
)
allow
(
user
).
to
receive
(
:dismissed_callout?
).
and_return
(
dismissed_callout
)
end
it
do
travel_to
(
travel_to_date
)
do
expect
(
helper
.
show_eoa_bronze_plan_banner?
(
namespace
)).
to
eq
(
result
)
end
end
end
end
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
context
'with group namespace'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:current_user
)
{
user
}
before
do
group
.
add_owner
(
current_user
.
id
)
allow
(
group
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
current_user
)
end
it_behaves_like
'shows and hides the banner depending on circumstances'
do
let
(
:namespace
)
{
group
}
end
end
context
'with personal namespace'
do
let
(
:current_user
)
{
user
}
before
do
allow
(
current_user
.
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
end
it_behaves_like
'shows and hides the banner depending on circumstances'
do
let
(
:namespace
)
{
current_user
.
namespace
}
end
end
end
describe
'#eoa_bronze_plan_end_date'
do
it
'returns a date type value'
do
expect
(
helper
.
send
(
:eoa_bronze_plan_end_date
).
is_a?
(
Date
)).
to
eq
(
true
)
end
end
end
ee/spec/views/shared/billings/_eoa_bronze_plan_banner.html.haml_spec.rb
View file @
328e928e
...
...
@@ -65,8 +65,24 @@ RSpec.describe 'shared/billings/_eoa_bronze_plan_banner.html.haml' do
end
end
shared_examples
'when user dismissed the banner'
do
before
do
allow
(
namespace
).
to
receive
(
:actual_plan_name
).
and_return
(
::
Plan
::
BRONZE
)
allow
(
view
).
to
receive
(
:user_dismissed?
).
with
(
::
EE
::
UserCalloutsHelper
::
EOA_BRONZE_PLAN_BANNER
).
and_return
(
true
)
end
it
'does not display the banner'
do
travel_to
(
eoa_bronze_plan_end_date
-
1
.
day
)
do
render
expect
(
rendered
).
not_to
have_content
(
"End of availability for the Bronze Plan"
)
end
end
end
before
do
allow
(
view
).
to
receive
(
:eoa_bronze_plan_end_date
).
and_return
(
eoa_bronze_plan_end_date
)
allow
(
view
).
to
receive
(
:user_dismissed?
).
with
(
::
EE
::
UserCalloutsHelper
::
EOA_BRONZE_PLAN_BANNER
).
and_return
(
false
)
end
context
'with group namespace'
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