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
fc940cc1
Commit
fc940cc1
authored
Jun 18, 2021
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strong memoize and add spec
parent
837bbb40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
ee/app/services/subscriptions/create_service.rb
ee/app/services/subscriptions/create_service.rb
+5
-3
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
+13
-0
No files found.
ee/app/services/subscriptions/create_service.rb
View file @
fc940cc1
...
...
@@ -2,6 +2,8 @@
module
Subscriptions
class
CreateService
include
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:current_user
,
:customer_params
,
:subscription_params
CUSTOMERS_OAUTH_APP_ID_CACHE_KEY
=
'customers_oauth_app_id'
...
...
@@ -103,13 +105,13 @@ module Subscriptions
end
def
oauth_token
@oauth_token
||=
begin
return
unless
customers_oauth_app_id
strong_memoize
(
:oauth_token
)
do
next
unless
customers_oauth_app_id
application
=
Doorkeeper
::
Application
.
find_by_uid
(
customers_oauth_app_id
)
existing_token
=
Doorkeeper
::
AccessToken
.
matching_token_for
(
application
,
current_user
.
id
,
application
.
scopes
)
return
existing_token
if
existing_token
next
existing_token
if
existing_token
Doorkeeper
::
AccessToken
.
new
(
application_id:
customers_oauth_app_id
,
...
...
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
View file @
fc940cc1
...
...
@@ -124,4 +124,17 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Rest do
it_behaves_like
'when response code is 500'
it_behaves_like
'when http call raises an exception'
end
describe
'#customers_oauth_app_id'
do
subject
do
client
.
customers_oauth_app_id
end
let
(
:http_method
)
{
:get
}
it_behaves_like
'when response is successful'
it_behaves_like
'when response code is 422'
it_behaves_like
'when response code is 500'
it_behaves_like
'when http call raises an exception'
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