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
8281e91e
Commit
8281e91e
authored
Dec 12, 2019
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API endpoints for payment method component
This is part of the paid signup flow
parent
56a1cb09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
3 deletions
+70
-3
ee/app/controllers/subscriptions_controller.rb
ee/app/controllers/subscriptions_controller.rb
+16
-0
ee/config/routes/subscription.rb
ee/config/routes/subscription.rb
+4
-1
ee/spec/controllers/subscriptions_controller_spec.rb
ee/spec/controllers/subscriptions_controller_spec.rb
+50
-2
No files found.
ee/app/controllers/subscriptions_controller.rb
View file @
8281e91e
...
@@ -6,4 +6,20 @@ class SubscriptionsController < ApplicationController
...
@@ -6,4 +6,20 @@ class SubscriptionsController < ApplicationController
def
new
def
new
return
redirect_to
dashboard_projects_path
unless
Feature
.
enabled?
(
:paid_signup_flow
)
return
redirect_to
dashboard_projects_path
unless
Feature
.
enabled?
(
:paid_signup_flow
)
end
end
def
payment_form
response
=
client
.
payment_form_params
(
params
[
:id
])
render
json:
response
[
:data
]
end
def
payment_method
response
=
client
.
payment_method
(
params
[
:id
])
render
json:
response
[
:data
]
end
private
def
client
Gitlab
::
SubscriptionPortal
::
Client
end
end
end
ee/config/routes/subscription.rb
View file @
8281e91e
# frozen_string_literal: true
# frozen_string_literal: true
resource
:subscriptions
,
only:
[
:new
]
resource
:subscriptions
,
only:
[
:new
]
do
get
:payment_form
get
:payment_method
end
ee/spec/controllers/subscriptions_controller_spec.rb
View file @
8281e91e
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
require
'spec_helper'
require
'spec_helper'
describe
SubscriptionsController
do
describe
SubscriptionsController
do
describe
'GET #new'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
describe
'GET #new'
do
subject
{
get
:new
,
params:
{
plan_id:
'bronze_id'
}
}
subject
{
get
:new
,
params:
{
plan_id:
'bronze_id'
}
}
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
@@ -37,4 +37,52 @@ describe SubscriptionsController do
...
@@ -37,4 +37,52 @@ describe SubscriptionsController do
end
end
end
end
end
end
describe
'GET #payment_form'
do
subject
{
get
:payment_form
,
params:
{
id:
'cc'
}
}
context
'with unauthorized user'
do
it
{
is_expected
.
to
have_gitlab_http_status
302
}
it
{
is_expected
.
to
redirect_to
new_user_session_path
}
end
context
'with authorized user'
do
before
do
sign_in
(
user
)
client_response
=
{
success:
true
,
data:
{
signature:
'x'
,
token:
'y'
}
}
allow
(
Gitlab
::
SubscriptionPortal
::
Client
).
to
receive
(
:payment_form_params
).
with
(
'cc'
).
and_return
(
client_response
)
end
it
{
is_expected
.
to
have_gitlab_http_status
200
}
it
'returns the data attribute of the client response in JSON format'
do
subject
expect
(
response
.
body
).
to
eq
(
'{"signature":"x","token":"y"}'
)
end
end
end
describe
'GET #payment_method'
do
subject
{
get
:payment_method
,
params:
{
id:
'xx'
}
}
context
'with unauthorized user'
do
it
{
is_expected
.
to
have_gitlab_http_status
302
}
it
{
is_expected
.
to
redirect_to
new_user_session_path
}
end
context
'with authorized user'
do
before
do
sign_in
(
user
)
client_response
=
{
success:
true
,
data:
{
credit_card_type:
'Visa'
}
}
allow
(
Gitlab
::
SubscriptionPortal
::
Client
).
to
receive
(
:payment_method
).
with
(
'xx'
).
and_return
(
client_response
)
end
it
{
is_expected
.
to
have_gitlab_http_status
200
}
it
'returns the data attribute of the client response in JSON format'
do
subject
expect
(
response
.
body
).
to
eq
(
'{"credit_card_type":"Visa"}'
)
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