Commit 4a1dff32 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch...

Merge branch '342323-nomethoderror-undefined-method-error-for-import-validateremotegitendpointservice' into 'master'

Resolve "NoMethodError: undefined method `error' for #<Import::ValidateRemoteGitEndpointService:0x00007fe2e6106320>

See merge request gitlab-org/gitlab!71670
parents b108f35c a93a088f
......@@ -21,7 +21,7 @@ module Import
def execute
uri = Gitlab::Utils.parse_url(@params[:url])
return error("Invalid URL") unless uri
return ServiceResponse.error(message: "#{@params[:url]} is not a valid URL") unless uri
uri.fragment = nil
url = Gitlab::Utils.append_path(uri.to_s, "/info/refs?service=#{GIT_SERVICE_NAME}")
......
......@@ -46,6 +46,14 @@ RSpec.describe Import::ValidateRemoteGitEndpointService do
expect(result.message).to eq(error_message)
end
it 'reports error when invalid URL is provided' do
result = described_class.new(url: 1).execute
expect(result).to be_a(ServiceResponse)
expect(result.error?).to be(true)
expect(result.message).to eq('1 is not a valid URL')
end
it 'reports error when required header is missing' do
stub_full_request(endpoint_url, method: :get).to_return(valid_response.merge({ headers: nil }))
......
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