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
5203239d
Commit
5203239d
authored
Nov 16, 2021
by
Diana Zubova
Committed by
Mark Chao
Nov 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add full params on first addons purchase
parent
0e31f5f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
14 deletions
+70
-14
ee/app/services/subscriptions/create_service.rb
ee/app/services/subscriptions/create_service.rb
+9
-4
ee/spec/fixtures/create_service_params.json
ee/spec/fixtures/create_service_params.json
+40
-4
ee/spec/services/subscriptions/create_service_spec.rb
ee/spec/services/subscriptions/create_service_spec.rb
+21
-6
No files found.
ee/app/services/subscriptions/create_service.rb
View file @
5203239d
...
...
@@ -71,10 +71,7 @@ module Subscriptions
end
def
create_subscription
(
customer_data
)
# When purchasing an add on, we don't want to send create_subscription_params
# in order to avoid amending the main product. Note that this will go away
# when fully transitioning the flow to GraphQL
create_params
=
add_on?
?
create_addon_params
:
create_subscription_params
create_params
=
send_create_addon_params?
?
create_addon_params
:
create_subscription_params
billing_email
,
token
=
customer_data
.
values_at
(
:email
,
:authentication_token
)
client
.
create_subscription
(
create_params
,
billing_email
,
token
)
...
...
@@ -112,6 +109,14 @@ module Subscriptions
Gitlab
::
Utils
.
to_boolean
(
subscription_params
[
:is_addon
],
default:
false
)
end
def
send_create_addon_params?
# We don't want to send create_subscription_params when purchasing addon
# in order to avoid amending the main product. The only exception to it
# is when we don't have an active subscription for a group purchasing addon.
# Note that this will go away when fully transitioning the flow to GraphQL
add_on?
&&
subscription_params
[
:active_subscription
].
present?
end
def
country_code
(
country
)
World
.
alpha3_from_alpha2
(
country
)
end
...
...
ee/spec/fixtures/create_service_params.json
View file @
5203239d
[
{
{
"subscription_params"
:
{
"customer"
:
{
"provider"
:
"gitlab"
,
"uid"
:
111
,
...
...
@@ -35,7 +35,7 @@
"source"
:
"some_source"
}
},
{
"addon_with_active_sub"
:
{
"customer"
:
{
"provider"
:
"gitlab"
,
"uid"
:
111
,
...
...
@@ -67,5 +67,41 @@
"preview"
:
"false"
,
"source"
:
"some_source"
}
},
"addon_without_active_sub"
:
{
"customer"
:
{
"provider"
:
"gitlab"
,
"uid"
:
111
,
"credentials"
:
{
"token"
:
"foo_token"
},
"customer"
:
{
"country"
:
"NLD"
,
"address_1"
:
"Address line 1"
,
"address_2"
:
"Address line 2"
,
"city"
:
"City"
,
"state"
:
"State"
,
"zip_code"
:
"Zip code"
,
"company"
:
"My organization"
},
"info"
:
{
"first_name"
:
"First name"
,
"last_name"
:
"Last name"
,
"email"
:
"first.last@gitlab.com"
}
},
"subscription"
:
{
"plan_id"
:
"Add-on Plan ID"
,
"payment_method_id"
:
"Payment method ID"
,
"products"
:
{
"main"
:
{
"quantity"
:
111
}
},
"gl_namespace_id"
:
222
,
"gl_namespace_name"
:
"Group name"
,
"preview"
:
"false"
,
"source"
:
"some_source"
}
}
]
}
\ No newline at end of file
ee/spec/services/subscriptions/create_service_spec.rb
View file @
5203239d
...
...
@@ -32,7 +32,7 @@ RSpec.describe Subscriptions::CreateService do
let_it_be
(
:customer_email
)
{
'first.last@gitlab.com'
}
let_it_be
(
:client
)
{
Gitlab
::
SubscriptionPortal
::
Client
}
let_it_be
(
:create_service_params
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'create_service_params.json'
,
dir:
'ee'
))[
0
].
deep_symbolize_keys
}
let_it_be
(
:create_service_params
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'create_service_params.json'
,
dir:
'ee'
))[
"subscription_params"
].
deep_symbolize_keys
}
describe
'#execute'
do
before
do
...
...
@@ -127,7 +127,6 @@ RSpec.describe Subscriptions::CreateService do
let_it_be
(
:subscription_params
)
do
{
is_addon:
true
,
active_subscription:
'A-000000'
,
plan_id:
'Add-on Plan ID'
,
payment_method_id:
'Payment method ID'
,
quantity:
111
,
...
...
@@ -135,12 +134,28 @@ RSpec.describe Subscriptions::CreateService do
}
end
it
'passes the correct parameters for creating a subscription'
do
create_service_addon_params
=
Gitlab
::
Json
.
parse
(
fixture_file
(
'create_service_params.json'
,
dir:
'ee'
))[
1
].
deep_symbolize_keys
context
'without active subscription'
do
it
'passes the correct parameters for creating a subscription'
do
create_service_addon_params
=
Gitlab
::
Json
.
parse
(
fixture_file
(
'create_service_params.json'
,
dir:
'ee'
))[
"addon_without_active_sub"
].
deep_symbolize_keys
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_addon_params
[
:subscription
],
customer_email
,
'token'
)
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_addon_params
[
:subscription
],
customer_email
,
'token'
)
execute
execute
end
end
context
'with active subscription'
do
before
do
subscription_params
[
:active_subscription
]
=
'A-000000'
end
it
'passes the correct parameters for creating a subscription'
do
create_service_addon_params
=
Gitlab
::
Json
.
parse
(
fixture_file
(
'create_service_params.json'
,
dir:
'ee'
))[
"addon_with_active_sub"
].
deep_symbolize_keys
expect
(
client
).
to
receive
(
:create_subscription
).
with
(
create_service_addon_params
[
:subscription
],
customer_email
,
'token'
)
execute
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