Commit fb2e2d29 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '327255-connection-error' into 'master'

Return connection error for activation

See merge request gitlab-org/gitlab!59840
parents ced9a272 1dcb1197
...@@ -6,6 +6,8 @@ module Gitlab ...@@ -6,6 +6,8 @@ module Gitlab
module Graphql module Graphql
extend ActiveSupport::Concern extend ActiveSupport::Concern
CONNECTIVITY_ERROR = 'CONNECTIVITY_ERROR'
class_methods do class_methods do
def activate(activation_code) def activate(activation_code)
uuid = Gitlab::CurrentSettings.uuid uuid = Gitlab::CurrentSettings.uuid
...@@ -33,9 +35,7 @@ module Gitlab ...@@ -33,9 +35,7 @@ module Gitlab
{ query: query, variables: variables } { query: query, variables: variables }
) )
if !response[:success] || response.dig(:data, 'errors').present? return error(CONNECTIVITY_ERROR) unless response[:success]
return error(response.dig(:data, 'errors'))
end
response = response.dig(:data, 'data', 'cloudActivationActivate') response = response.dig(:data, 'data', 'cloudActivationActivate')
......
...@@ -49,6 +49,14 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Graphql do ...@@ -49,6 +49,14 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Graphql do
expect(result).to eq({ errors: ["invalid activation code"], success: false }) expect(result).to eq({ errors: ["invalid activation code"], success: false })
end end
it 'returns connectivity error' do
stub_request(:any, EE::SUBSCRIPTIONS_GRAPHQL_URL).to_return(status: [500, "Internal Server Error"])
result = client.activate('activation_code_abc')
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
end
end end
describe '#plan_upgrade_offer' do describe '#plan_upgrade_offer' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment