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
377b3d92
Commit
377b3d92
authored
Jan 21, 2021
by
Jason Goodman
Committed by
Robert Speicher
Jan 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide card in billing page for deprecated plans with override set
Allows to hide cards for certain deprecated plans
parent
8f35d011
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
ee/app/helpers/billing_plans_helper.rb
ee/app/helpers/billing_plans_helper.rb
+7
-1
ee/spec/helpers/billing_plans_helper_spec.rb
ee/spec/helpers/billing_plans_helper_spec.rb
+28
-2
No files found.
ee/app/helpers/billing_plans_helper.rb
View file @
377b3d92
...
@@ -97,7 +97,13 @@ module BillingPlansHelper
...
@@ -97,7 +97,13 @@ module BillingPlansHelper
def
billing_available_plans
(
plans_data
,
current_plan
)
def
billing_available_plans
(
plans_data
,
current_plan
)
return
plans_data
unless
::
Feature
.
enabled?
(
:hide_deprecated_billing_plans
)
return
plans_data
unless
::
Feature
.
enabled?
(
:hide_deprecated_billing_plans
)
plans_data
.
filter
{
|
plan_data
|
!
plan_data
.
deprecated?
||
plan_data
.
code
==
current_plan
&
.
code
}
plans_data
.
reject
do
|
plan_data
|
if
plan_data
.
code
==
current_plan
&
.
code
plan_data
.
deprecated?
&&
plan_data
.
hide_deprecated_card?
else
plan_data
.
deprecated?
end
end
end
end
private
private
...
...
ee/spec/helpers/billing_plans_helper_spec.rb
View file @
377b3d92
...
@@ -271,11 +271,19 @@ RSpec.describe BillingPlansHelper do
...
@@ -271,11 +271,19 @@ RSpec.describe BillingPlansHelper do
end
end
describe
'#billing_available_plans'
do
describe
'#billing_available_plans'
do
let
(
:plan
)
{
double
(
'Plan'
,
deprecated?:
false
,
code:
'silver'
)
}
let
(
:plan
)
{
double
(
'Plan'
,
deprecated?:
false
,
code:
'silver'
,
hide_deprecated_card?:
false
)
}
let
(
:deprecated_plan
)
{
double
(
'Plan'
,
deprecated?:
true
,
code:
'bronze'
)
}
let
(
:deprecated_plan
)
{
double
(
'Plan'
,
deprecated?:
true
,
code:
'bronze'
,
hide_deprecated_card?:
false
)
}
let
(
:plans_data
)
{
[
plan
,
deprecated_plan
]
}
let
(
:plans_data
)
{
[
plan
,
deprecated_plan
]
}
context
'when namespace is not on a plan'
do
it
'returns plans without deprecated'
do
expect
(
helper
.
billing_available_plans
(
plans_data
,
nil
)).
to
eq
([
plan
])
end
end
context
'when namespace is on an active plan'
do
context
'when namespace is on an active plan'
do
let
(
:current_plan
)
{
Hashie
::
Mash
.
new
(
code:
'silver'
)
}
it
'returns plans without deprecated'
do
it
'returns plans without deprecated'
do
expect
(
helper
.
billing_available_plans
(
plans_data
,
nil
)).
to
eq
([
plan
])
expect
(
helper
.
billing_available_plans
(
plans_data
,
nil
)).
to
eq
([
plan
])
end
end
...
@@ -288,5 +296,23 @@ RSpec.describe BillingPlansHelper do
...
@@ -288,5 +296,23 @@ RSpec.describe BillingPlansHelper do
expect
(
helper
.
billing_available_plans
(
plans_data
,
current_plan
)).
to
eq
(
plans_data
)
expect
(
helper
.
billing_available_plans
(
plans_data
,
current_plan
)).
to
eq
(
plans_data
)
end
end
end
end
context
'when namespace is on a deprecated plan that has hide_deprecated_card set to true'
do
let
(
:current_plan
)
{
Hashie
::
Mash
.
new
(
code:
'bronze'
)
}
let
(
:deprecated_plan
)
{
double
(
'Plan'
,
deprecated?:
true
,
code:
'bronze'
,
hide_deprecated_card?:
true
)
}
it
'returns plans without the deprecated plan'
do
expect
(
helper
.
billing_available_plans
(
plans_data
,
current_plan
)).
to
eq
([
plan
])
end
end
context
'when namespace is on a plan that has hide_deprecated_card set to true, but deprecated? is false'
do
let
(
:current_plan
)
{
Hashie
::
Mash
.
new
(
code:
'silver'
)
}
let
(
:plan
)
{
double
(
'Plan'
,
deprecated?:
false
,
code:
'silver'
,
hide_deprecated_card?:
true
)
}
it
'returns plans with the deprecated plan'
do
expect
(
helper
.
billing_available_plans
(
plans_data
,
current_plan
)).
to
eq
([
plan
])
end
end
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