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
e4e577a4
Commit
e4e577a4
authored
Oct 04, 2021
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create hand raise lead service
parent
fa4d55f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
0 deletions
+74
-0
ee/app/services/gitlab_subscriptions/create_hand_raise_lead_service.rb
...es/gitlab_subscriptions/create_hand_raise_lead_service.rb
+21
-0
ee/lib/gitlab/subscription_portal/clients/rest.rb
ee/lib/gitlab/subscription_portal/clients/rest.rb
+4
-0
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
+11
-0
ee/spec/services/gitlab_subscriptions/create_hand_raise_lead_service_spec.rb
...tlab_subscriptions/create_hand_raise_lead_service_spec.rb
+38
-0
No files found.
ee/app/services/gitlab_subscriptions/create_hand_raise_lead_service.rb
0 → 100644
View file @
e4e577a4
# frozen_string_literal: true
module
GitlabSubscriptions
class
CreateHandRaiseLeadService
def
execute
(
params
)
response
=
client
.
generate_hand_raise_lead
(
params
)
if
response
[
:success
]
ServiceResponse
.
success
else
ServiceResponse
.
error
(
message:
response
.
dig
(
:data
,
:errors
))
end
end
private
def
client
Gitlab
::
SubscriptionPortal
::
Client
end
end
end
ee/lib/gitlab/subscription_portal/clients/rest.rb
View file @
e4e577a4
...
@@ -13,6 +13,10 @@ module Gitlab
...
@@ -13,6 +13,10 @@ module Gitlab
http_post
(
"trials"
,
admin_headers
,
params
)
http_post
(
"trials"
,
admin_headers
,
params
)
end
end
def
generate_hand_raise_lead
(
params
)
http_post
(
"trials/create_hand_raise_lead"
,
admin_headers
,
params
)
end
def
extend_reactivate_trial
(
params
)
def
extend_reactivate_trial
(
params
)
http_put
(
"trials/extend_reactivate_trial"
,
admin_headers
,
params
)
http_put
(
"trials/extend_reactivate_trial"
,
admin_headers
,
params
)
end
end
...
...
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
View file @
e4e577a4
...
@@ -64,6 +64,17 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Rest do
...
@@ -64,6 +64,17 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Rest do
it_behaves_like
'when http call raises an exception'
it_behaves_like
'when http call raises an exception'
end
end
describe
'#generate_hand_raise_lead'
do
subject
do
client
.
generate_hand_raise_lead
({})
end
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
describe
'#extend_reactivate_trial'
do
describe
'#extend_reactivate_trial'
do
let
(
:http_method
)
{
:put
}
let
(
:http_method
)
{
:put
}
...
...
ee/spec/services/gitlab_subscriptions/create_hand_raise_lead_service_spec.rb
0 → 100644
View file @
e4e577a4
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
GitlabSubscriptions
::
CreateHandRaiseLeadService
do
subject
(
:execute
)
{
described_class
.
new
.
execute
(
params
)
}
let
(
:params
)
{
{}
}
describe
'#execute'
do
before
do
allow
(
Gitlab
::
SubscriptionPortal
::
Client
).
to
receive
(
:generate_hand_raise_lead
).
with
(
params
).
and_return
(
response
)
end
context
'hand raise lead call is made successfully'
do
let
(
:response
)
{
{
success:
true
}
}
it
'returns success: true'
do
result
=
execute
expect
(
result
.
is_a?
(
ServiceResponse
)).
to
be
true
expect
(
result
.
success?
).
to
be
true
end
end
context
'error while creating hand raise lead call is made successful'
do
let
(
:response
)
{
{
success:
false
,
data:
{
errors:
[
'some error'
]
}
}
}
it
'returns success: false with errors'
do
result
=
execute
expect
(
result
.
is_a?
(
ServiceResponse
)).
to
be
true
expect
(
result
.
success?
).
to
be
false
expect
(
result
.
message
).
to
match_array
([
'some error'
])
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