2015-08-26 01:42:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'Project variables', :js do
|
2016-04-27 11:17:17 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-08-25 21:56:32 +00:00
|
|
|
let(:variable) { create(:ci_variable, key: 'test_key', value: 'test value') }
|
2016-04-27 11:17:17 +00:00
|
|
|
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2016-04-27 11:17:17 +00:00
|
|
|
project.team << [user, :master]
|
|
|
|
project.variables << variable
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_settings_ci_cd_path(project)
|
2016-04-27 11:17:17 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
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
|
|
|
|
|
2017-05-25 11:31:21 +00:00
|
|
|
it 'adds new secret variable' do
|
2017-02-21 17:48:22 +00:00
|
|
|
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')
|
|
|
|
|
2017-07-06 12:40:27 +00:00
|
|
|
expect(page).to have_content('Variable was successfully created.')
|
2016-04-27 11:17:17 +00:00
|
|
|
page.within('.variables-table') do
|
2017-02-21 17:48:22 +00:00
|
|
|
expect(page).to have_content('key')
|
2017-05-25 11:31:21 +00:00
|
|
|
expect(page).to have_content('No')
|
2016-08-25 21:56:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds empty variable' do
|
|
|
|
fill_in('variable_key', with: 'new_key')
|
|
|
|
fill_in('variable_value', with: '')
|
|
|
|
click_button('Add new variable')
|
|
|
|
|
2017-07-06 12:40:27 +00:00
|
|
|
expect(page).to have_content('Variable was successfully created.')
|
2016-08-25 21:56:32 +00:00
|
|
|
page.within('.variables-table') do
|
|
|
|
expect(page).to have_content('new_key')
|
2016-04-27 11:17:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-25 11:31:21 +00:00
|
|
|
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')
|
|
|
|
|
2017-07-06 12:40:27 +00:00
|
|
|
expect(page).to have_content('Variable was successfully created.')
|
2017-05-25 11:31:21 +00:00
|
|
|
page.within('.variables-table') do
|
|
|
|
expect(page).to have_content('key')
|
|
|
|
expect(page).to have_content('Yes')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-24 10:24:52 +00:00
|
|
|
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-07-25 18:16:19 +00:00
|
|
|
it 'deletes variable' do
|
2016-04-27 11:17:17 +00:00
|
|
|
page.within('.variables-table') do
|
2017-11-01 02:22:42 +00:00
|
|
|
accept_confirm { click_on 'Remove' }
|
2016-04-27 11:17:17 +00:00
|
|
|
end
|
|
|
|
|
2016-05-23 23:37:59 +00:00
|
|
|
expect(page).not_to have_selector('variables-table')
|
2016-04-27 11:17:17 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'edits variable' do
|
2016-04-27 11:17:17 +00:00
|
|
|
page.within('.variables-table') do
|
2017-05-03 18:51:55 +00:00
|
|
|
click_on 'Update'
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2016-08-11 16:48:32 +00:00
|
|
|
expect(page).to have_content('Update variable')
|
2017-02-21 17:48:22 +00:00
|
|
|
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')
|
2015-09-28 15:19:20 +00:00
|
|
|
|
2017-02-21 17:48:22 +00:00
|
|
|
expect(page).to have_content('Variable was successfully updated.')
|
2017-05-31 16:37:44 +00:00
|
|
|
expect(project.variables(true).first.value).to eq('key value')
|
2016-08-25 21:56:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'edits variable with empty value' do
|
|
|
|
page.within('.variables-table') do
|
2017-05-03 18:51:55 +00:00
|
|
|
click_on 'Update'
|
2016-08-25 21:56:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Update variable')
|
|
|
|
fill_in('variable_value', with: '')
|
|
|
|
click_button('Save variable')
|
|
|
|
|
2017-02-21 17:48:22 +00:00
|
|
|
expect(page).to have_content('Variable was successfully updated.')
|
2017-05-31 16:37:44 +00:00
|
|
|
expect(project.variables(true).first.value).to eq('')
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
2017-05-25 11:31:21 +00:00
|
|
|
|
|
|
|
it 'edits variable to be protected' do
|
|
|
|
page.within('.variables-table') do
|
2017-05-03 18:51:55 +00:00
|
|
|
click_on 'Update'
|
2017-05-25 11:31:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Update variable')
|
|
|
|
check('Protected')
|
|
|
|
click_button('Save variable')
|
|
|
|
|
|
|
|
expect(page).to have_content('Variable was successfully updated.')
|
2017-05-31 16:37:44 +00:00
|
|
|
expect(project.variables(true).first).to be_protected
|
2017-05-25 11:31:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'edits variable to be unprotected' do
|
|
|
|
project.variables.first.update(protected: true)
|
|
|
|
|
|
|
|
page.within('.variables-table') do
|
2017-05-03 18:51:55 +00:00
|
|
|
click_on 'Update'
|
2017-05-25 11:31:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Update variable')
|
2017-05-25 12:53:03 +00:00
|
|
|
uncheck('Protected')
|
2017-05-25 11:31:21 +00:00
|
|
|
click_button('Save variable')
|
|
|
|
|
|
|
|
expect(page).to have_content('Variable was successfully updated.')
|
2017-05-31 16:37:44 +00:00
|
|
|
expect(project.variables(true).first).not_to be_protected
|
2017-05-25 11:31:21 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|