summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2017-09-18 11:54:48 +0200
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2017-09-18 12:02:47 +0200
commitcf851ce559b1af2b0fecd13a06c362b15b5d5df8 (patch)
treebb494bf09e6293fc5bf83e21219ba66f71368434
parent65e5888f1d42fed563f2c369e6c05cd64fde0341 (diff)
downloadgitlab-ce-cf851ce559b1af2b0fecd13a06c362b15b5d5df8.tar.gz
Fix instance default option being true as value
When a user selected 'Instance default' as value for the auto devops settings, this was interpreted as a true value. Now we post an empty string in this case, meaning we want to set `NULL` in the database. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37893#note_40541294
-rw-r--r--app/views/projects/pipelines_settings/_show.html.haml4
-rw-r--r--spec/controllers/projects/pipelines_settings_controller_spec.rb (renamed from spec/controllers/projects/pipelines_setttings_controller_spec.rb)14
2 files changed, 15 insertions, 3 deletions
diff --git a/app/views/projects/pipelines_settings/_show.html.haml b/app/views/projects/pipelines_settings/_show.html.haml
index 324cd423ede..2aceb4b529c 100644
--- a/app/views/projects/pipelines_settings/_show.html.haml
+++ b/app/views/projects/pipelines_settings/_show.html.haml
@@ -25,8 +25,8 @@
%span.descr
A specific .gitlab-ci.yml file needs to be specified before you can begin using Continious Integration and Delivery.
.radio
- = form.label :enabled do
- = form.radio_button :enabled, nil
+ = form.label :enabled_nil do
+ = form.radio_button :enabled, ''
%strong
Instance default (status: #{current_application_settings.auto_devops_enabled?})
%br
diff --git a/spec/controllers/projects/pipelines_setttings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb
index 9eb6d7ce8b5..ee46ad00947 100644
--- a/spec/controllers/projects/pipelines_setttings_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb
@@ -17,15 +17,27 @@ describe Projects::PipelinesSettingsController do
namespace_id: project.namespace.to_param,
project_id: project,
project: {
- auto_devops_attributes: { enabled: false, domain: 'mempmep.md' }
+ auto_devops_attributes: params
}
end
context 'when updating the auto_devops settings' do
+ let(:params) { { enabled: '', domain: 'mepmep.md' } }
+
it 'redirects to the settings page' do
expect(response).to have_http_status(302)
expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.")
end
+
+ context 'following the instance default' do
+ let(:params) { { enabled: '' } }
+
+ it 'allows enabled to be set to nil' do
+ project_auto_devops.reload
+
+ expect(project_auto_devops.enabled).to be_nil
+ end
+ end
end
end
end