2015-08-25 21:42:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
describe 'Admin Builds' do
|
2015-08-25 21:42:46 -04:00
|
|
|
before do
|
2015-12-04 06:55:23 -05:00
|
|
|
login_as :admin
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
describe 'GET /admin/builds' do
|
2016-06-03 10:22:26 -04:00
|
|
|
let(:pipeline) { create(:ci_pipeline) }
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'All tab' do
|
|
|
|
context 'when have builds' do
|
|
|
|
it 'shows all builds' do
|
2016-06-03 10:22:26 -04: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-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
visit admin_builds_path
|
2015-12-04 06:55:23 -05:00
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'All')
|
2016-05-11 10:46:19 -04:00
|
|
|
expect(page).to have_selector('.row-content-block', text: 'All builds')
|
2015-12-30 09:25:42 -05:00
|
|
|
expect(page.all('.build-link').size).to eq(4)
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'when have no builds' do
|
|
|
|
it 'shows a message' do
|
|
|
|
visit admin_builds_path
|
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'All')
|
2015-12-30 09:25:42 -05:00
|
|
|
expect(page).to have_content 'No builds to show'
|
|
|
|
expect(page).not_to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'Running tab' do
|
|
|
|
context 'when have running builds' do
|
|
|
|
it 'shows running builds' do
|
2016-06-03 10:22:26 -04:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
|
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :failed)
|
2015-12-30 09:25:42 -05:00
|
|
|
|
|
|
|
visit admin_builds_path(scope: :running)
|
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Running')
|
2015-12-30 09:25:42 -05: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)
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'when have no builds running' do
|
|
|
|
it 'shows a message' do
|
2016-06-03 10:22:26 -04:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
visit admin_builds_path(scope: :running)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Running')
|
2015-12-30 09:25:42 -05:00
|
|
|
expect(page).to have_content 'No builds to show'
|
|
|
|
expect(page).not_to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'Finished tab' do
|
|
|
|
context 'when have finished builds' do
|
|
|
|
it 'shows finished builds' do
|
2016-06-03 10:22:26 -04: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 09:25:42 -05:00
|
|
|
|
|
|
|
visit admin_builds_path(scope: :finished)
|
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Finished')
|
2015-12-30 09:25:42 -05: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-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
context 'when have no builds finished' do
|
|
|
|
it 'shows a message' do
|
2016-06-03 10:22:26 -04:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :running)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2015-12-30 09:25:42 -05:00
|
|
|
visit admin_builds_path(scope: :finished)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2016-02-05 05:53:06 -05:00
|
|
|
expect(page).to have_selector('.nav-links li.active', text: 'Finished')
|
2015-12-30 09:25:42 -05:00
|
|
|
expect(page).to have_content 'No builds to show'
|
|
|
|
expect(page).to have_link 'Cancel all'
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|