BigW Consortium Gitlab

Commit 68873d74 by Douwe Maan Committed by DJ Mountney

Merge branch 'tc-fix-project-create-500' into 'master'

Fix for creating a project through API when import_url is nil Closes #29121 See merge request !9841
parent 0f711b08
---
title: Fix for creating a project through API when import_url is nil
merge_request: 9841
author:
...@@ -9,6 +9,8 @@ module Gitlab ...@@ -9,6 +9,8 @@ module Gitlab
end end
def self.valid?(url) def self.valid?(url)
return false unless url
Addressable::URI.parse(url.strip) Addressable::URI.parse(url.strip)
true true
......
...@@ -100,4 +100,12 @@ describe Gitlab::UrlSanitizer, lib: true do ...@@ -100,4 +100,12 @@ describe Gitlab::UrlSanitizer, lib: true do
it { expect(url_sanitizer.full_url).to eq("https://john.doe@github.com/me/project.git") } it { expect(url_sanitizer.full_url).to eq("https://john.doe@github.com/me/project.git") }
end end
end end
describe '.valid?' do
it 'validates url strings' do
expect(described_class.valid?(nil)).to be(false)
expect(described_class.valid?('valid@project:url.git')).to be(true)
expect(described_class.valid?('123://invalid:url')).to be(false)
end
end
end end
...@@ -424,6 +424,14 @@ describe API::Projects, api: true do ...@@ -424,6 +424,14 @@ describe API::Projects, api: true do
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy
end end
it 'ignores import_url when it is nil' do
project = attributes_for(:project, { import_url: nil })
post api('/projects', user), project
expect(response).to have_http_status(201)
end
context 'when a visibility level is restricted' do context 'when a visibility level is restricted' do
let(:project_param) { attributes_for(:project, visibility: 'public') } let(:project_param) { attributes_for(:project, visibility: 'public') }
......
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