summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-06-03 15:04:59 -0700
committerStan Hu <stanhu@gmail.com>2019-06-03 15:27:24 -0700
commitcfaf012c532a269a230f67b31e623b18e3f8f8b1 (patch)
treedeba08e3288c5b5cb33a457607923989fe8137f2
parent98e1f7d5da8c429e3b8747825e2507bfe464e92c (diff)
downloadgitlab-ce-cfaf012c532a269a230f67b31e623b18e3f8f8b1.tar.gz
Fix project settings not being able to update
Previously import_url would always be present in the update parameters, which would cause the validation to fail. We now only include this parameter only if there is URL given. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/62708
-rw-r--r--app/controllers/concerns/import_url_params.rb2
-rw-r--r--changelogs/unreleased/sh-fix-import-url-update.yml5
-rw-r--r--spec/controllers/concerns/import_url_params_spec.rb12
3 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/concerns/import_url_params.rb b/app/controllers/concerns/import_url_params.rb
index 765654ca2cb..e51e4157f50 100644
--- a/app/controllers/concerns/import_url_params.rb
+++ b/app/controllers/concerns/import_url_params.rb
@@ -2,6 +2,8 @@
module ImportUrlParams
def import_url_params
+ return {} unless params.dig(:project, :import_url).present?
+
{ import_url: import_params_to_full_url(params[:project]) }
end
diff --git a/changelogs/unreleased/sh-fix-import-url-update.yml b/changelogs/unreleased/sh-fix-import-url-update.yml
new file mode 100644
index 00000000000..d143bd3473a
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-import-url-update.yml
@@ -0,0 +1,5 @@
+---
+title: Fix project settings not being able to update
+merge_request: 29097
+author:
+type: fixed
diff --git a/spec/controllers/concerns/import_url_params_spec.rb b/spec/controllers/concerns/import_url_params_spec.rb
index fc5dfb5263f..adbe6e5d3bf 100644
--- a/spec/controllers/concerns/import_url_params_spec.rb
+++ b/spec/controllers/concerns/import_url_params_spec.rb
@@ -8,6 +8,18 @@ describe ImportUrlParams do
controller.import_url_params
end
+ context 'empty URL' do
+ let(:params) do
+ ActionController::Parameters.new(project: {
+ title: 'Test'
+ })
+ end
+
+ it 'returns empty hash' do
+ expect(import_url_params).to eq({})
+ end
+ end
+
context 'url and password separately provided' do
let(:params) do
ActionController::Parameters.new(project: {