diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-03-10 18:56:24 +0300 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2017-03-21 22:16:55 +0300 |
commit | 68873d7457dda6657dc29aba468337f8da2445b3 (patch) | |
tree | cd0d8f2631f416cc70ea5ad1e2a807b67d1c3dd3 /spec | |
parent | 0f711b0818888523b400e898b19c5a2954a2613d (diff) |
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
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/url_sanitizer_spec.rb | 8 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb index fc144a2556a..5f7abdd04fb 100644 --- a/spec/lib/gitlab/url_sanitizer_spec.rb +++ b/spec/lib/gitlab/url_sanitizer_spec.rb @@ -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") } 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 diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 77f79cd5bc7..b4b23617498 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -424,6 +424,14 @@ describe API::Projects, api: true do expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy 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 let(:project_param) { attributes_for(:project, visibility: 'public') } |