Commit faeb6337 authored by Nikola Milojevic's avatar Nikola Milojevic

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

Allow activate mutation to handle timeout

See merge request gitlab-org/gitlab!60102
parents fd7b78e4 b346ae84
......@@ -44,6 +44,9 @@ module Gitlab
else
error(response['errors'])
end
rescue Gitlab::HTTP::BlockedUrlError, HTTParty::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, SocketError, Timeout::Error => e
Gitlab::ErrorTracking.log_exception(e)
error(CONNECTIVITY_ERROR)
end
def plan_upgrade_offer(namespace_id)
......
......@@ -48,13 +48,23 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Graphql do
expect(result).to eq({ errors: ["invalid activation code"], success: false })
end
it 'returns connectivity error' do
it 'returns connectivity error when remote server returns 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
it 'returns connectivity error when the remote server is unreachable' do
stub_request(:any, EE::SUBSCRIPTIONS_GRAPHQL_URL).to_timeout
allow(Gitlab::ErrorTracking).to receive(:log_exception)
result = client.activate('activation_code_abc')
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(Gitlab::ErrorTracking).to have_received(:log_exception).with(kind_of(Timeout::Error))
end
end
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