gitlab-org--gitlab-foss/spec/features/variables_spec.rb

146 lines
4.0 KiB
Ruby
Raw Normal View History

2015-08-26 01:42:46 +00:00
require 'spec_helper'
2016-04-27 11:17:17 +00:00
describe 'Project variables', js: true do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:variable) { create(:ci_variable, key: 'test_key', value: 'test value') }
2016-04-27 11:17:17 +00:00
before do
login_as(user)
project.team << [user, :master]
project.variables << variable
2017-01-24 00:51:16 +00:00
visit namespace_project_settings_ci_cd_path(project.namespace, project)
2016-04-27 11:17:17 +00:00
end
it 'shows list of variables' do
2016-04-27 11:17:17 +00:00
page.within('.variables-table') do
expect(page).to have_content(variable.key)
end
end
it 'adds new secret variable' do
fill_in('variable_key', with: 'key')
fill_in('variable_value', with: 'key value')
2016-04-27 11:17:17 +00:00
click_button('Add new variable')
expect(page).to have_content('Variables were successfully updated.')
2016-04-27 11:17:17 +00:00
page.within('.variables-table') do
expect(page).to have_content('key')
expect(page).to have_content('No')
end
end
it 'adds empty variable' do
fill_in('variable_key', with: 'new_key')
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')
2016-04-27 11:17:17 +00:00
end
end
it 'adds new protected variable' do
fill_in('variable_key', with: 'key')
fill_in('variable_value', with: 'value')
check('Protected')
click_button('Add new variable')
expect(page).to have_content('Variables were successfully updated.')
page.within('.variables-table') do
expect(page).to have_content('key')
expect(page).to have_content('Yes')
end
end
it 'reveals and hides new variable' do
fill_in('variable_key', with: 'key')
fill_in('variable_value', with: 'key value')
click_button('Add new variable')
page.within('.variables-table') do
expect(page).to have_content('key')
expect(page).to have_content('******')
end
click_button('Reveal Values')
page.within('.variables-table') do
expect(page).to have_content('key')
expect(page).to have_content('key value')
end
click_button('Hide Values')
page.within('.variables-table') do
expect(page).to have_content('key')
expect(page).to have_content('******')
end
end
it 'deletes variable' do
2016-04-27 11:17:17 +00:00
page.within('.variables-table') do
find('.btn-variable-delete').click
end
expect(page).not_to have_selector('variables-table')
2016-04-27 11:17:17 +00:00
end
it 'edits variable' do
2016-04-27 11:17:17 +00:00
page.within('.variables-table') do
find('.btn-variable-edit').click
2015-08-26 01:42:46 +00:00
end
2016-08-11 16:48:32 +00:00
expect(page).to have_content('Update variable')
fill_in('variable_key', with: 'key')
fill_in('variable_value', with: 'key value')
2016-04-27 11:17:17 +00:00
click_button('Save variable')
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
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')
expect(page).to have_content('Variable was successfully updated.')
expect(project.variables.first.value).to eq('')
2015-08-26 01:42:46 +00:00
end
it 'edits variable to be protected' do
page.within('.variables-table') do
find('.btn-variable-edit').click
end
expect(page).to have_content('Update variable')
check('Protected')
click_button('Save variable')
expect(page).to have_content('Variable was successfully updated.')
expect(project.variables.first).to be_protected
end
it 'edits variable to be unprotected' do
project.variables.first.update(protected: true)
page.within('.variables-table') do
find('.btn-variable-edit').click
end
expect(page).to have_content('Update variable')
check('Protected')
click_button('Save variable')
expect(page).to have_content('Variable was successfully updated.')
expect(project.variables.first).not_to be_protected
end
2015-08-26 01:42:46 +00:00
end