Commit cfaf012c authored by Stan Hu's avatar Stan Hu

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
parent 98e1f7d5
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module ImportUrlParams module ImportUrlParams
def import_url_params def import_url_params
return {} unless params.dig(:project, :import_url).present?
{ import_url: import_params_to_full_url(params[:project]) } { import_url: import_params_to_full_url(params[:project]) }
end end
......
---
title: Fix project settings not being able to update
merge_request: 29097
author:
type: fixed
...@@ -8,6 +8,18 @@ describe ImportUrlParams do ...@@ -8,6 +8,18 @@ describe ImportUrlParams do
controller.import_url_params controller.import_url_params
end 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 context 'url and password separately provided' do
let(:params) do let(:params) do
ActionController::Parameters.new(project: { ActionController::Parameters.new(project: {
......
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