From 71270f80dd42e524a904a3c19f23217e8766e282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Nov=C3=BD?= Date: Thu, 25 Aug 2016 21:56:32 +0000 Subject: UI: Allow a project variable to be set to an empty value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- app/views/projects/variables/_form.html.haml | 2 +- .../unreleased/lnovy-gitlab-ce-empty-variables.yml | 4 ++ spec/features/variables_spec.rb | 44 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/lnovy-gitlab-ce-empty-variables.yml diff --git a/app/views/projects/variables/_form.html.haml b/app/views/projects/variables/_form.html.haml index a5bae83e0ce..1ae86d258af 100644 --- a/app/views/projects/variables/_form.html.haml +++ b/app/views/projects/variables/_form.html.haml @@ -6,5 +6,5 @@ = f.text_field :key, class: "form-control", placeholder: "PROJECT_VARIABLE", required: true .form-group = f.label :value, "Value", class: "label-light" - = f.text_area :value, class: "form-control", placeholder: "PROJECT_VARIABLE", required: true + = f.text_area :value, class: "form-control", placeholder: "PROJECT_VARIABLE" = f.submit btn_text, class: "btn btn-save" diff --git a/changelogs/unreleased/lnovy-gitlab-ce-empty-variables.yml b/changelogs/unreleased/lnovy-gitlab-ce-empty-variables.yml new file mode 100644 index 00000000000..bd5db5ac7af --- /dev/null +++ b/changelogs/unreleased/lnovy-gitlab-ce-empty-variables.yml @@ -0,0 +1,4 @@ +--- +title: 'UI: Allow a project variable to be set to an empty value' +merge_request: 6044 +author: Lukáš Nový diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index 9a4bc027004..a07eba2f01e 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'Project variables', js: true do let(:user) { create(:user) } let(:project) { create(:project) } - let(:variable) { create(:ci_variable, key: 'test') } + let(:variable) { create(:ci_variable, key: 'test_key', value: 'test value') } before do login_as(user) @@ -16,16 +16,28 @@ describe 'Project variables', js: true do it 'shows list of variables' do page.within('.variables-table') do expect(page).to have_content(variable.key) + expect(page).to have_content(variable.value) end end it 'adds new variable' do - fill_in('variable_key', with: 'key') - fill_in('variable_value', with: 'key value') + fill_in('variable_key', with: 'new_key') + fill_in('variable_value', with: 'new value') click_button('Add new variable') page.within('.variables-table') do - expect(page).to have_content('key') + expect(page).to have_content('new_key') + expect(page).to have_content('new value') + end + end + + it 'adds empty variable' do + fill_in('variable_key', with: 'new_key') + fill_in('variable_value', with: '') + click_button('Add new variable') + + page.within('.variables-table') do + expect(page).to have_content('new_key') end end @@ -68,12 +80,30 @@ describe 'Project variables', js: true do end expect(page).to have_content('Update variable') - fill_in('variable_key', with: 'key') - fill_in('variable_value', with: 'key value') + fill_in('variable_key', with: 'new_key') + fill_in('variable_value', with: 'new value') click_button('Save variable') page.within('.variables-table') do - expect(page).to have_content('key') + expect(page).not_to have_content(variable.key) + expect(page).not_to have_content(variable.value) + expect(page).to have_content('new_key') + expect(page).to have_content('new value') + end + end + + it 'edits variable with empty value' do + page.within('.variables-table') do + find('.btn-variable-edit').click + end + + expect(page).to have_content('Update variable') + fill_in('variable_value', with: '') + click_button('Save variable') + + page.within('.variables-table') do + expect(page).to have_content(variable.key) + expect(page).not_to have_content(variable.value) end end end -- cgit v1.2.3 From 4f115a090a931c3999f6b51d9fa027165b96b618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 21 Feb 2017 18:48:22 +0100 Subject: Fix specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/features/variables_spec.rb | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index a07eba2f01e..a362d6fd3b6 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -16,18 +16,17 @@ describe 'Project variables', js: true do it 'shows list of variables' do page.within('.variables-table') do expect(page).to have_content(variable.key) - expect(page).to have_content(variable.value) end end it 'adds new variable' do - fill_in('variable_key', with: 'new_key') - fill_in('variable_value', with: 'new value') + fill_in('variable_key', with: 'key') + fill_in('variable_value', with: 'key value') click_button('Add new variable') + expect(page).to have_content('Variables were successfully updated.') page.within('.variables-table') do - expect(page).to have_content('new_key') - expect(page).to have_content('new value') + expect(page).to have_content('key') end end @@ -36,6 +35,7 @@ describe 'Project variables', js: true do fill_in('variable_value', with: '') click_button('Add new variable') + expect(page).to have_content('Variables were successfully updated.') page.within('.variables-table') do expect(page).to have_content('new_key') end @@ -80,16 +80,12 @@ describe 'Project variables', js: true do end expect(page).to have_content('Update variable') - fill_in('variable_key', with: 'new_key') - fill_in('variable_value', with: 'new value') + fill_in('variable_key', with: 'key') + fill_in('variable_value', with: 'key value') click_button('Save variable') - page.within('.variables-table') do - expect(page).not_to have_content(variable.key) - expect(page).not_to have_content(variable.value) - expect(page).to have_content('new_key') - expect(page).to have_content('new value') - end + expect(page).to have_content('Variable was successfully updated.') + expect(project.variables.first.value).to eq('key value') end it 'edits variable with empty value' do @@ -101,9 +97,7 @@ describe 'Project variables', js: true do fill_in('variable_value', with: '') click_button('Save variable') - page.within('.variables-table') do - expect(page).to have_content(variable.key) - expect(page).not_to have_content(variable.value) - end + expect(page).to have_content('Variable was successfully updated.') + expect(project.variables.first.value).to eq('') end end -- cgit v1.2.3