Commit 71270f80 authored by Lukáš Nový's avatar Lukáš Nový Committed by Rémy Coutable

UI: Allow a project variable to be set to an empty value

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 459a97d4
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
= f.text_field :key, class: "form-control", placeholder: "PROJECT_VARIABLE", required: true = f.text_field :key, class: "form-control", placeholder: "PROJECT_VARIABLE", required: true
.form-group .form-group
= f.label :value, "Value", class: "label-light" = 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" = f.submit btn_text, class: "btn btn-save"
---
title: 'UI: Allow a project variable to be set to an empty value'
merge_request: 6044
author: Lukáš Nový
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'Project variables', js: true do describe 'Project variables', js: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:variable) { create(:ci_variable, key: 'test') } let(:variable) { create(:ci_variable, key: 'test_key', value: 'test value') }
before do before do
login_as(user) login_as(user)
...@@ -16,16 +16,28 @@ describe 'Project variables', js: true do ...@@ -16,16 +16,28 @@ describe 'Project variables', js: true do
it 'shows list of variables' do it 'shows list of variables' do
page.within('.variables-table') do page.within('.variables-table') do
expect(page).to have_content(variable.key) expect(page).to have_content(variable.key)
expect(page).to have_content(variable.value)
end end
end end
it 'adds new variable' do it 'adds new variable' do
fill_in('variable_key', with: 'key') fill_in('variable_key', with: 'new_key')
fill_in('variable_value', with: 'key value') fill_in('variable_value', with: 'new value')
click_button('Add new variable') click_button('Add new variable')
page.within('.variables-table') do 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
end end
...@@ -68,12 +80,30 @@ describe 'Project variables', js: true do ...@@ -68,12 +80,30 @@ describe 'Project variables', js: true do
end end
expect(page).to have_content('Update variable') expect(page).to have_content('Update variable')
fill_in('variable_key', with: 'key') fill_in('variable_key', with: 'new_key')
fill_in('variable_value', with: 'key value') fill_in('variable_value', with: 'new value')
click_button('Save variable') click_button('Save variable')
page.within('.variables-table') do 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 end
end end
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