2017-05-07 22:35:56 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
feature 'Pipeline Schedules', :js do
|
2017-05-07 22:35:56 +00:00
|
|
|
include PipelineSchedulesHelper
|
|
|
|
|
2017-07-24 22:51:14 +00:00
|
|
|
let!(:project) { create(:project, :repository) }
|
2017-05-23 18:32:21 +00:00
|
|
|
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) }
|
2017-05-10 18:47:43 +00:00
|
|
|
let!(:pipeline) { create(:ci_pipeline, pipeline_schedule: pipeline_schedule) }
|
2017-05-07 22:35:56 +00:00
|
|
|
let(:scope) { nil }
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'logged in as master' do
|
2017-06-29 09:33:24 +00:00
|
|
|
before do
|
2017-07-10 16:09:16 +00:00
|
|
|
project.add_master(user)
|
|
|
|
gitlab_sign_in(user)
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'GET /projects/pipeline_schedules' do
|
|
|
|
before do
|
|
|
|
visit_pipelines_schedules
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'The view' do
|
|
|
|
it 'displays the required information description' do
|
|
|
|
page.within('.pipeline-schedule-table-row') do
|
|
|
|
expect(page).to have_content('pipeline schedule')
|
|
|
|
expect(find(".next-run-cell time")['data-original-title'])
|
|
|
|
.to include(pipeline_schedule.real_next_run.strftime('%b %-d, %Y'))
|
|
|
|
expect(page).to have_link('master')
|
|
|
|
expect(page).to have_link("##{pipeline.id}")
|
|
|
|
end
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'creates a new scheduled pipeline' do
|
|
|
|
click_link 'New schedule'
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
expect(page).to have_content('Schedule a new pipeline')
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'changes ownership of the pipeline' do
|
|
|
|
click_link 'Take ownership'
|
|
|
|
page.within('.pipeline-schedule-table-row') do
|
|
|
|
expect(page).not_to have_content('No owner')
|
|
|
|
expect(page).to have_link('John Doe')
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'edits the pipeline' do
|
|
|
|
page.within('.pipeline-schedule-table-row') do
|
|
|
|
click_link 'Edit'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Edit Pipeline Schedule')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes the pipeline' do
|
2017-10-10 04:13:57 +00:00
|
|
|
accept_confirm { click_link 'Delete' }
|
2017-07-10 16:09:16 +00:00
|
|
|
|
|
|
|
expect(page).not_to have_css(".pipeline-schedule-table-row")
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'when ref is nil' do
|
|
|
|
before do
|
|
|
|
pipeline_schedule.update_attribute(:ref, nil)
|
|
|
|
visit_pipelines_schedules
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'shows a list of the pipeline schedules with empty ref column' do
|
|
|
|
expect(first('.branch-name-cell').text).to eq('')
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
2017-07-20 07:23:40 +00:00
|
|
|
|
|
|
|
context 'when ref is empty' do
|
|
|
|
before do
|
|
|
|
pipeline_schedule.update_attribute(:ref, '')
|
|
|
|
visit_pipelines_schedules
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a list of the pipeline schedules with empty ref column' do
|
|
|
|
expect(first('.branch-name-cell').text).to eq('')
|
|
|
|
end
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
2017-05-25 10:20:24 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'POST /projects/pipeline_schedules/new' do
|
2017-05-25 10:20:24 +00:00
|
|
|
before do
|
2017-07-10 16:09:16 +00:00
|
|
|
visit_new_pipeline_schedule
|
2017-05-25 10:20:24 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'sets defaults for timezone and target branch' do
|
|
|
|
expect(page).to have_button('master')
|
|
|
|
expect(page).to have_button('UTC')
|
2017-05-25 10:20:24 +00:00
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'it creates a new scheduled pipeline' do
|
|
|
|
fill_in_schedule_form
|
|
|
|
save_pipeline_schedule
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
expect(page).to have_content('my fancy description')
|
|
|
|
end
|
2017-05-13 01:15:27 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'it prevents an invalid form from being submitted' do
|
|
|
|
save_pipeline_schedule
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
expect(page).to have_content('This field is required')
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'PATCH /projects/pipelines_schedules/:id/edit' do
|
|
|
|
before do
|
|
|
|
edit_pipeline_schedule
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'it displays existing properties' do
|
|
|
|
description = find_field('schedule_description').value
|
|
|
|
expect(description).to eq('pipeline schedule')
|
|
|
|
expect(page).to have_button('master')
|
|
|
|
expect(page).to have_button('UTC')
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'edits the scheduled pipeline' do
|
|
|
|
fill_in 'schedule_description', with: 'my brand new description'
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
save_pipeline_schedule
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
expect(page).to have_content('my brand new description')
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'when ref is nil' do
|
|
|
|
before do
|
|
|
|
pipeline_schedule.update_attribute(:ref, nil)
|
|
|
|
edit_pipeline_schedule
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
it 'shows the pipeline schedule with default ref' do
|
|
|
|
page.within('.js-target-branch-dropdown') do
|
2017-07-20 07:23:40 +00:00
|
|
|
expect(first('.dropdown-toggle-text').text).to eq('master')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when ref is empty' do
|
|
|
|
before do
|
|
|
|
pipeline_schedule.update_attribute(:ref, '')
|
|
|
|
edit_pipeline_schedule
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline schedule with default ref' do
|
|
|
|
page.within('.js-target-branch-dropdown') do
|
2017-07-10 16:09:16 +00:00
|
|
|
expect(first('.dropdown-toggle-text').text).to eq('master')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
2017-05-25 10:20:24 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'when user creates a new pipeline schedule with variables' do
|
|
|
|
background do
|
|
|
|
visit_pipelines_schedules
|
|
|
|
click_link 'New schedule'
|
|
|
|
fill_in_schedule_form
|
2018-03-22 11:08:16 +00:00
|
|
|
all('[name="schedule[variables_attributes][][key]"]')[0].set('AAA')
|
2018-03-17 15:18:36 +00:00
|
|
|
all('[name="schedule[variables_attributes][][secret_value]"]')[0].set('AAA123')
|
2018-03-22 11:08:16 +00:00
|
|
|
all('[name="schedule[variables_attributes][][key]"]')[1].set('BBB')
|
2018-03-17 15:18:36 +00:00
|
|
|
all('[name="schedule[variables_attributes][][secret_value]"]')[1].set('BBB123')
|
2017-07-10 16:09:16 +00:00
|
|
|
save_pipeline_schedule
|
2017-05-25 10:20:24 +00:00
|
|
|
end
|
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
scenario 'user sees the new variable in edit window' do
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2018-01-26 06:25:26 +00:00
|
|
|
page.within('.ci-variable-list') do
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('AAA')
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('AAA123')
|
|
|
|
expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-key").value).to eq('BBB')
|
|
|
|
expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-value", visible: false).value).to eq('BBB123')
|
2017-05-25 10:20:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'when user edits a variable of a pipeline schedule' do
|
|
|
|
background do
|
|
|
|
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
|
|
|
|
create(:ci_pipeline_schedule_variable, key: 'AAA', value: 'AAA123', pipeline_schedule: pipeline_schedule)
|
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
visit_pipelines_schedules
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2018-01-26 06:25:26 +00:00
|
|
|
|
|
|
|
find('.js-ci-variable-list-section .js-secret-value-reveal-button').click
|
|
|
|
first('.js-ci-variable-input-key').set('foo')
|
|
|
|
first('.js-ci-variable-input-value').set('bar')
|
2017-07-10 16:09:16 +00:00
|
|
|
click_button 'Save pipeline schedule'
|
2017-06-29 17:22:05 +00:00
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
scenario 'user sees the updated variable in edit window' do
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2018-01-26 06:25:26 +00:00
|
|
|
page.within('.ci-variable-list') do
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('foo')
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('bar')
|
2017-07-10 16:09:16 +00:00
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
end
|
2017-06-29 09:33:24 +00:00
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'when user removes a variable of a pipeline schedule' do
|
|
|
|
background do
|
|
|
|
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
|
|
|
|
create(:ci_pipeline_schedule_variable, key: 'AAA', value: 'AAA123', pipeline_schedule: pipeline_schedule)
|
|
|
|
end
|
|
|
|
|
|
|
|
visit_pipelines_schedules
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2018-01-26 06:25:26 +00:00
|
|
|
find('.ci-variable-list .ci-variable-row-remove-button').click
|
2017-07-10 16:09:16 +00:00
|
|
|
click_button 'Save pipeline schedule'
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user does not see the removed variable in edit window' do
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2018-01-26 06:25:26 +00:00
|
|
|
page.within('.ci-variable-list') do
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('')
|
|
|
|
expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('')
|
2017-07-10 16:09:16 +00:00
|
|
|
end
|
2017-06-29 17:22:05 +00:00
|
|
|
end
|
2017-06-29 09:33:24 +00:00
|
|
|
end
|
2017-08-03 17:23:02 +00:00
|
|
|
|
|
|
|
context 'when active is true and next_run_at is NULL' do
|
|
|
|
background do
|
|
|
|
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
|
|
|
|
pipeline_schedule.update_attribute(:cron, nil) # Consequently next_run_at will be nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user edit and recover the problematic pipeline schedule' do
|
2017-08-04 11:22:44 +00:00
|
|
|
visit_pipelines_schedules
|
|
|
|
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
|
2017-08-03 17:23:02 +00:00
|
|
|
fill_in 'schedule_cron', with: '* 1 2 3 4'
|
|
|
|
click_button 'Save pipeline schedule'
|
2017-08-04 11:22:44 +00:00
|
|
|
|
2017-08-03 17:23:02 +00:00
|
|
|
page.within('.pipeline-schedule-table-row:nth-child(1)') do
|
|
|
|
expect(page).to have_css(".next-run-cell time")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-29 09:33:24 +00:00
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
context 'logged in as non-member' do
|
|
|
|
before do
|
|
|
|
gitlab_sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET /projects/pipeline_schedules' do
|
|
|
|
before do
|
|
|
|
visit_pipelines_schedules
|
2017-06-19 15:59:10 +00:00
|
|
|
end
|
2017-07-04 08:45:07 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'The view' do
|
|
|
|
it 'does not show create schedule button' do
|
|
|
|
expect(page).not_to have_link('New schedule')
|
|
|
|
end
|
|
|
|
end
|
2017-06-29 09:33:24 +00:00
|
|
|
end
|
2017-07-10 16:09:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'not logged in' do
|
|
|
|
describe 'GET /projects/pipeline_schedules' do
|
|
|
|
before do
|
|
|
|
visit_pipelines_schedules
|
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
|
2017-07-10 16:09:16 +00:00
|
|
|
describe 'The view' do
|
|
|
|
it 'does not show create schedule button' do
|
|
|
|
expect(page).not_to have_link('New schedule')
|
|
|
|
end
|
2017-06-29 17:22:05 +00:00
|
|
|
end
|
2017-06-19 15:59:10 +00:00
|
|
|
end
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_new_pipeline_schedule
|
2017-07-06 16:20:50 +00:00
|
|
|
visit new_project_pipeline_schedule_path(project, pipeline_schedule)
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit_pipeline_schedule
|
2017-07-06 16:20:50 +00:00
|
|
|
visit edit_project_pipeline_schedule_path(project, pipeline_schedule)
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_pipelines_schedules
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_pipeline_schedules_path(project, scope: scope)
|
2017-05-07 22:35:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def select_timezone
|
2017-05-15 19:51:20 +00:00
|
|
|
find('.js-timezone-dropdown').click
|
2017-05-07 22:35:56 +00:00
|
|
|
click_link 'American Samoa'
|
|
|
|
end
|
|
|
|
|
|
|
|
def select_target_branch
|
2017-05-15 19:51:20 +00:00
|
|
|
find('.js-target-branch-dropdown').click
|
2017-05-07 22:35:56 +00:00
|
|
|
click_link 'master'
|
|
|
|
end
|
|
|
|
|
|
|
|
def save_pipeline_schedule
|
|
|
|
click_button 'Save pipeline schedule'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fill_in_schedule_form
|
|
|
|
fill_in 'schedule_description', with: 'my fancy description'
|
|
|
|
fill_in 'schedule_cron', with: '* 1 2 3 4'
|
|
|
|
|
|
|
|
select_timezone
|
|
|
|
select_target_branch
|
|
|
|
end
|
|
|
|
end
|