summaryrefslogtreecommitdiff
path: root/spec/features
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-06-19 10:59:10 -0500
committerShinya Maeda <shinya@gitlab.com>2017-07-05 18:36:19 +0900
commit5576214d0fbbc8b7f208367e3eedd6347b21151b (patch)
tree3526e353bfa743033c343faacdbdfebc511d3772 /spec/features
parentd7cd3c3635bc6200cd9c8668a025826818f19a80 (diff)
downloadgitlab-ce-5576214d0fbbc8b7f208367e3eedd6347b21151b.tar.gz
Schedule pipelines with variables
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32568
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/projects/pipeline_schedules_spec.rb60
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 dfb973c37e5..0adc192b804 100644
--- a/spec/features/projects/pipeline_schedules_spec.rb
+++ b/spec/features/projects/pipeline_schedules_spec.rb
@@ -98,6 +98,15 @@ feature 'Pipeline Schedules', :feature 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', js: true do
@@ -120,6 +129,14 @@ feature 'Pipeline Schedules', :feature 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)
@@ -132,6 +149,40 @@ feature 'Pipeline Schedules', :feature 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
def visit_new_pipeline_schedule
@@ -160,6 +211,15 @@ feature 'Pipeline Schedules', :feature 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'