Commit b346ae84 authored by Mark Chao's avatar Mark Chao

Allow activate mutation to handle connection error

Rescue and return connection error message
parent 3718f4ec
......@@ -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)
......
......@@ -50,13 +50,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