Commit cd2d435d authored by Eric Eastwood's avatar Eric Eastwood Committed by Shinya Maeda

Schedule pipelines with variables

Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32568
parent 5711562e
......@@ -27,6 +27,7 @@
%label.label-light
#{ _('Variables') }
%ul.js-pipeline-variable-list.pipeline-variable-list
- if @schedule.variables.present?
- @schedule.variables.each_with_index do |variable, i|
= render 'variable_row', id: variable.id, key: variable.key, value: variable.value
= render 'variable_row'
......
......@@ -93,6 +93,15 @@ feature 'Pipeline Schedules', :feature, js: true do
expect(page).to have_content('This field is required')
end
it 'sets a variable' do
fill_in_schedule_form
fill_in_variable
save_pipeline_schedule
expect(Ci::PipelineSchedule.last.job_variables).to eq([{ key: 'foo', value: 'bar', public: false }])
end
end
describe 'PATCH /projects/pipelines_schedules/:id/edit' do
......@@ -115,6 +124,14 @@ feature 'Pipeline Schedules', :feature, js: true do
expect(page).to have_content('my brand new description')
end
it 'adds a new variable' do
fill_in_variable
save_pipeline_schedule
expect(Ci::PipelineSchedule.last.job_variables).to eq([{ key: 'foo', value: 'bar', public: false }])
end
context 'when ref is nil' do
before do
pipeline_schedule.update_attribute(:ref, nil)
......@@ -127,6 +144,40 @@ feature 'Pipeline Schedules', :feature, js: true do
end
end
end
context 'when variables already exist' do
before do
create(:ci_pipeline_schedule_variable, key: 'some_key', value: 'some_value', pipeline_schedule: pipeline_schedule)
edit_pipeline_schedule
end
it 'edits existing variable' do
expect(first('[name="schedule[variables_attributes][][key]"]').value).to eq('some_key')
expect(first('[name="schedule[variables_attributes][][value]"]').value).to eq('some_value')
fill_in_variable
save_pipeline_schedule
expect(Ci::PipelineSchedule.last.job_variables).to eq([{ key: 'foo', value: 'bar', public: false }])
end
it 'removes an existing variable' do
remove_variable
save_pipeline_schedule
expect(Ci::PipelineSchedule.last.job_variables).to eq([])
end
it 'adds another variable' do
fill_in_variable(1)
save_pipeline_schedule
expect(Ci::PipelineSchedule.last.job_variables).to eq([
{ key: 'some_key', value: 'some_value', public: false },
{ key: 'foo', value: 'bar', public: false }
])
end
end
end
context 'when user creates a new pipeline schedule with variables' do
......@@ -219,6 +270,15 @@ feature 'Pipeline Schedules', :feature, js: true do
click_button 'Save pipeline schedule'
end
def fill_in_variable(index = 0)
all('[name="schedule[variables_attributes][][key]"]')[index].set('foo')
all('[name="schedule[variables_attributes][][value]"]')[index].set('bar')
end
def remove_variable
first('.js-pipeline-variable-list .js-row-remove-button').click
end
def fill_in_schedule_form
fill_in 'schedule_description', with: 'my fancy description'
fill_in 'schedule_cron', with: '* 1 2 3 4'
......
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