Commit adad4d20 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'vshumilo-keep-namespace-name-in-sync-fix' into 'master'

Subscription portal update_namespace_name update

See merge request gitlab-org/gitlab!71340
parents e4afa34c aca11d6c
......@@ -183,13 +183,10 @@ module Gitlab
return error(CONNECTIVITY_ERROR) unless response[:success]
response = response.dig(:data, 'data', 'orderNamespaceNameUpdate')
errors = response.dig(:data, 'errors') ||
response.dig(:data, 'data', 'orderNamespaceNameUpdate', 'errors')
if response['errors'].blank?
{ success: true }
else
error(response['errors'])
end
errors.blank? ? { success: true } : error(errors)
rescue Gitlab::HTTP::BlockedUrlError, HTTParty::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, SocketError, Timeout::Error => e
Gitlab::ErrorTracking.log_exception(e)
error(CONNECTIVITY_ERROR)
......
......@@ -400,45 +400,54 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Graphql do
}
)
result = update_request
expect(update_request).to eq({ success: true })
end
it 'returns top level errors' do
top_level_errors = ['Validation error', 'Errors in query execution']
expect(result).to eq({ success: true })
expect(client).to receive(:execute_graphql_query).and_return(
{
success: true,
data: {
'errors' => top_level_errors
}
}
)
expect(update_request).to eq({ errors: top_level_errors, success: false })
end
it 'returns failure' do
it 'returns errors as data' do
errors_as_data = ['error updating the name']
expect(client).to receive(:execute_graphql_query).and_return(
{
success: true,
data: {
'data' => {
'orderNamespaceNameUpdate' => {
'errors' => ['error updating the name']
'errors' => errors_as_data
}
}
}
}
)
result = update_request
expect(result).to eq({ errors: ['error updating the name'], success: false })
expect(update_request).to eq({ errors: errors_as_data, success: false })
end
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 = update_request
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(update_request).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 = update_request
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(update_request).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(Gitlab::ErrorTracking).to have_received(:log_exception).with(kind_of(Timeout::Error))
end
end
......
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