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 ...@@ -183,13 +183,10 @@ module Gitlab
return error(CONNECTIVITY_ERROR) unless response[:success] 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? errors.blank? ? { success: true } : error(errors)
{ success: true }
else
error(response['errors'])
end
rescue Gitlab::HTTP::BlockedUrlError, HTTParty::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, SocketError, Timeout::Error => e rescue Gitlab::HTTP::BlockedUrlError, HTTParty::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, SocketError, Timeout::Error => e
Gitlab::ErrorTracking.log_exception(e) Gitlab::ErrorTracking.log_exception(e)
error(CONNECTIVITY_ERROR) error(CONNECTIVITY_ERROR)
......
...@@ -400,45 +400,54 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::Graphql do ...@@ -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 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( expect(client).to receive(:execute_graphql_query).and_return(
{ {
success: true, success: true,
data: { data: {
'data' => { 'data' => {
'orderNamespaceNameUpdate' => { 'orderNamespaceNameUpdate' => {
'errors' => ['error updating the name'] 'errors' => errors_as_data
} }
} }
} }
} }
) )
result = update_request expect(update_request).to eq({ errors: errors_as_data, success: false })
expect(result).to eq({ errors: ['error updating the name'], success: false })
end end
it 'returns connectivity error when remote server returns 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"]) stub_request(:any, EE::SUBSCRIPTIONS_GRAPHQL_URL).to_return(status: [500, "Internal Server Error"])
result = update_request expect(update_request).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
end end
it 'returns connectivity error when the remote server is unreachable' do it 'returns connectivity error when the remote server is unreachable' do
stub_request(:any, EE::SUBSCRIPTIONS_GRAPHQL_URL).to_timeout stub_request(:any, EE::SUBSCRIPTIONS_GRAPHQL_URL).to_timeout
allow(Gitlab::ErrorTracking).to receive(:log_exception) allow(Gitlab::ErrorTracking).to receive(:log_exception)
result = update_request expect(update_request).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(result).to eq({ errors: described_class::CONNECTIVITY_ERROR, success: false })
expect(Gitlab::ErrorTracking).to have_received(:log_exception).with(kind_of(Timeout::Error)) expect(Gitlab::ErrorTracking).to have_received(:log_exception).with(kind_of(Timeout::Error))
end end
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