diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-06-19 18:59:10 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-07-05 12:38:30 +0300 |
commit | cd2d435d59e87123f5722898cdf13c152ff3c92f (patch) | |
tree | a1e4706f0c0b43318f1d549853729226f6eea733 /spec/features/projects/pipeline_schedules_spec.rb | |
parent | 5711562e2528ed371b69ca68467a9821100f5808 (diff) |
Schedule pipelines with variables
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32568
Diffstat (limited to 'spec/features/projects/pipeline_schedules_spec.rb')
-rw-r--r-- | spec/features/projects/pipeline_schedules_spec.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/features/projects/pipeline_schedules_spec.rb b/spec/features/projects/pipeline_schedules_spec.rb index fa7f8561f46..9c544ad3d38 100644 --- a/spec/features/projects/pipeline_schedules_spec.rb +++ b/spec/features/projects/pipeline_schedules_spec.rb @@ -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' |