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
b9a10eea
Commit
b9a10eea
authored
Oct 11, 2019
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce shared examples for billing plans spec
Closes
https://gitlab.com/gitlab-org/gitlab/issues/31936
parent
a94463a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
47 deletions
+84
-47
ee/spec/features/billings/billing_plans_spec.rb
ee/spec/features/billings/billing_plans_spec.rb
+80
-43
ee/spec/support/shared_examples/gold_trial_callout_shared_examples.rb
...ort/shared_examples/gold_trial_callout_shared_examples.rb
+4
-4
No files found.
ee/spec/features/billings/billing_plans_spec.rb
View file @
b9a10eea
...
...
@@ -9,6 +9,7 @@ describe 'Billing plan pages', :feature do
let
(
:namespace
)
{
user
.
namespace
}
let
(
:free_plan
)
{
create
(
:free_plan
)
}
let
(
:bronze_plan
)
{
create
(
:bronze_plan
)
}
let
(
:silver_plan
)
{
create
(
:silver_plan
)
}
let
(
:gold_plan
)
{
create
(
:gold_plan
)
}
let
(
:plans_data
)
do
JSON
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'ee/spec/fixtures/gitlab_com_plans.json'
))).
map
do
|
data
|
...
...
@@ -17,7 +18,7 @@ describe 'Billing plan pages', :feature do
end
before
do
stub_full_request
(
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/gitlab_plans?plan=
#{
plan
}
"
)
stub_full_request
(
"
#{
EE
::
SUBSCRIPTIONS_URL
}
/gitlab_plans?plan=
#{
plan
.
name
}
"
)
.
to_return
(
status:
200
,
body:
plans_data
.
to_json
)
stub_application_setting
(
check_namespace_plan:
true
)
allow
(
Gitlab
).
to
receive
(
:com?
)
{
true
}
...
...
@@ -30,13 +31,64 @@ describe 'Billing plan pages', :feature do
end
end
shared_examples
'upgradable plan'
do
before
do
visit
page_path
end
it
'displays the upgrade link'
do
page
.
within
(
'.content'
)
do
expect
(
page
).
to
have_link
(
'Upgrade'
,
href:
external_upgrade_url
(
namespace
,
plan
))
end
end
end
shared_examples
'non-upgradable plan'
do
before
do
visit
page_path
end
it
'does not display the upgrade link'
do
page
.
within
(
'.content'
)
do
expect
(
page
).
not_to
have_link
(
'Upgrade'
,
href:
external_upgrade_url
(
namespace
,
plan
))
end
end
end
shared_examples
'downgradable plan'
do
before
do
visit
page_path
end
it
'displays the downgrade link'
do
page
.
within
(
'.content'
)
do
expect
(
page
).
to
have_content
(
'downgrade your plan'
)
expect
(
page
).
to
have_link
(
'Customer Support'
,
href:
EE
::
CUSTOMER_SUPPORT_URL
)
end
end
end
shared_examples
'plan with header'
do
before
do
visit
page_path
end
it
'displays header'
do
page
.
within
(
'.billing-plan-header'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
username
}
you are currently using the
#{
plan
.
name
.
titleize
}
plan."
)
expect
(
page
).
to
have_css
(
'.billing-plan-logo img'
)
end
end
end
context
'users profile billing page'
do
let
(
:page_path
)
{
profile_billings_path
}
it_behaves_like
'billings gold trial callout'
context
'on free'
do
let
(
:plan
)
{
free_plan
.
name
}
let
(
:plan
)
{
free_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
nil
,
seats:
15
)
...
...
@@ -81,55 +133,40 @@ describe 'Billing plan pages', :feature do
end
end
context
'on bronze'
do
let
(
:plan
)
{
bronze_plan
.
name
}
context
'on bronze
plan
'
do
let
(
:plan
)
{
bronze_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
bronze_
plan
,
seats:
15
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
before
do
visit
page_path
end
it
'displays header and actions'
do
page
.
within
(
'.billing-plan-header'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
username
}
you are currently using the Bronze plan."
)
expect
(
page
).
to
have_css
(
'.billing-plan-logo img'
)
end
page
.
within
(
'.content'
)
do
expect
(
page
).
to
have_link
(
'Upgrade'
,
href:
external_upgrade_url
(
namespace
,
bronze_plan
))
expect
(
page
).
to
have_content
(
'downgrade your plan'
)
expect
(
page
).
to
have_link
(
'Customer Support'
,
href:
EE
::
CUSTOMER_SUPPORT_URL
)
end
end
it_behaves_like
'plan with header'
it_behaves_like
'downgradable plan'
it_behaves_like
'upgradable plan'
end
context
'on
gold
'
do
let
(
:plan
)
{
gold_plan
.
name
}
context
'on
silver plan
'
do
let
(
:plan
)
{
silver_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
gold_plan
,
seats:
15
)
end
before
do
visit
page_path
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
it
'displays header and actions'
do
page
.
within
(
'.billing-plan-header'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
username
}
you are currently using the Gold plan."
)
it_behaves_like
'plan with header'
it_behaves_like
'downgradable plan'
it_behaves_like
'upgradable plan'
end
expect
(
page
).
to
have_css
(
'.billing-plan-logo img'
)
end
context
'on gold plan'
do
let
(
:plan
)
{
gold_plan
}
page
.
within
(
'.content'
)
do
expect
(
page
).
to
have_content
(
'downgrade your plan'
)
expect
(
page
).
to
have_link
(
'Customer Support'
,
href:
EE
::
CUSTOMER_SUPPORT_URL
)
end
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
it_behaves_like
'plan with header'
it_behaves_like
'downgradable plan'
it_behaves_like
'non-upgradable plan'
end
end
...
...
@@ -143,10 +180,10 @@ describe 'Billing plan pages', :feature do
it_behaves_like
'billings gold trial callout'
context
'on bronze'
do
let
(
:plan
)
{
bronze_plan
.
name
}
let
(
:plan
)
{
bronze_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
bronze_
plan
,
seats:
15
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
before
do
...
...
@@ -187,10 +224,10 @@ describe 'Billing plan pages', :feature do
it_behaves_like
'billings gold trial callout'
context
'on bronze'
do
let
(
:plan
)
{
bronze_plan
.
name
}
let
(
:plan
)
{
bronze_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
bronze_
plan
,
seats:
15
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
before
do
...
...
@@ -210,7 +247,7 @@ describe 'Billing plan pages', :feature do
end
context
'with unexpected JSON'
do
let
(
:plan
)
{
'free'
}
let
(
:plan
)
{
free_plan
}
let
(
:plans_data
)
do
[
...
...
ee/spec/support/shared_examples/gold_trial_callout_shared_examples.rb
View file @
b9a10eea
...
...
@@ -60,7 +60,7 @@ end
shared_examples
'billings gold trial callout'
do
context
'on a free plan'
do
let
(
:plan
)
{
'free'
}
let
(
:plan
)
{
free_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
nil
,
seats:
15
)
...
...
@@ -82,7 +82,7 @@ shared_examples 'billings gold trial callout' do
where
(
case_names:
->
(
plan_type
)
{
"like
#{
plan_type
}
"
},
plan_type:
[
:bronze
,
:silver
])
with_them
do
let
(
:plan
)
{
plan
_type
}
let
(
:plan
)
{
plan
s
[
plan_type
]
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plans
[
plan_type
],
seats:
15
)
...
...
@@ -103,10 +103,10 @@ shared_examples 'billings gold trial callout' do
end
context
'on a gold plan'
do
let
(
:plan
)
{
gold_plan
.
name
}
let
(
:plan
)
{
gold_plan
}
let!
(
:subscription
)
do
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
gold_
plan
,
seats:
15
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
plan
,
seats:
15
)
end
before
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