Commit a93a088f authored by Illya Klymov's avatar Illya Klymov

Fix undefined method error in validate_remote_git_endpoint service

* update tests

Changelog: fixed
parent 8f1f5ab8
......@@ -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