2015-09-25 12:07:36 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
describe 'Project variables', js: true do
|
|
|
|
let(:user) { create(:user) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:empty_project) }
|
|
|
|
let(:variable) { create(:ci_variable, key: 'test_key', value: 'test value') }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
login_as(user)
|
|
|
|
project.team << [user, :master]
|
|
|
|
project.variables << variable
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
visit namespace_project_settings_ci_cd_path(project.namespace, project)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'shows list of variables' do
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.variables-table') do
|
|
|
|
expect(page).to have_content(variable.key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'adds new variable' do
|
2016-06-02 11:05:42 +05:30
|
|
|
fill_in('variable_key', with: 'key')
|
|
|
|
fill_in('variable_value', with: 'key value')
|
|
|
|
click_button('Add new variable')
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Variables were successfully updated.')
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.variables-table') do
|
|
|
|
expect(page).to have_content('key')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
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')
|
|
|
|
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
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'deletes variable' do
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.variables-table') do
|
|
|
|
find('.btn-variable-delete').click
|
|
|
|
end
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).not_to have_selector('variables-table')
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'edits variable' do
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.variables-table') do
|
|
|
|
find('.btn-variable-edit').click
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
expect(page).to have_content('Update variable')
|
2016-06-02 11:05:42 +05:30
|
|
|
fill_in('variable_key', with: 'key')
|
|
|
|
fill_in('variable_value', with: 'key value')
|
|
|
|
click_button('Save variable')
|
2015-10-24 18:46:33 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.variables-table') do
|
2017-08-17 22:00:37 +05:30
|
|
|
find('.btn-variable-edit').click
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|