2015-08-26 01:42:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
describe 'Admin Builds' do
|
2015-08-26 01:42:46 +00:00
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(create(:admin))
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
describe 'GET /admin/builds' do
|
2016-06-03 14:22:26 +00:00
|
|
|
let(:pipeline) { create(:ci_pipeline) }
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'All tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have jobs' do
|
|
|
|
it 'shows all jobs' do
|
2016-06-03 14:22:26 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :pending)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :running)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :failed)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path
|
2015-12-04 11:55:23 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'All')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_selector('.row-content-block', text: 'All jobs')
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page.all('.build-link').size).to eq(4)
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
2015-12-04 11:55:23 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'All')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page).not_to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-05 12:39:55 +00:00
|
|
|
context 'Pending tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have pending jobs' do
|
|
|
|
it 'shows pending jobs' do
|
2016-07-05 12:39:55 +00:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
|
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :running)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
build4 = create(:ci_build, pipeline: pipeline, status: :failed)
|
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :pending)
|
2016-07-05 12:39:55 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Pending')
|
|
|
|
expect(page.find('.build-link')).to have_content(build1.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build2.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build3.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build4.id)
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs pending' do
|
2016-07-05 12:39:55 +00:00
|
|
|
it 'shows a message' do
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :pending)
|
2016-07-05 12:39:55 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Pending')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2016-07-05 12:39:55 +00:00
|
|
|
expect(page).not_to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'Running tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have running jobs' do
|
|
|
|
it 'shows running jobs' do
|
2016-07-05 12:39:55 +00:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :running)
|
2016-06-03 14:22:26 +00:00
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :failed)
|
2016-07-05 12:39:55 +00:00
|
|
|
build4 = create(:ci_build, pipeline: pipeline, status: :pending)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :running)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Running')
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page.find('.build-link')).to have_content(build1.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build2.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build3.id)
|
2016-07-05 12:39:55 +00:00
|
|
|
expect(page.find('.build-link')).not_to have_content(build4.id)
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs running' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2016-06-03 14:22:26 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :running)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Running')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page).not_to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'Finished tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have finished jobs' do
|
|
|
|
it 'shows finished jobs' do
|
2016-06-03 14:22:26 +00:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
|
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :running)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :success)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :finished)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Finished')
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page.find('.build-link')).not_to have_content(build1.id)
|
|
|
|
expect(page.find('.build-link')).not_to have_content(build2.id)
|
|
|
|
expect(page.find('.build-link')).to have_content(build3.id)
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs finished' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2016-06-03 14:22:26 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :running)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :finished)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2016-02-05 10:53:06 +00:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Finished')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|