2015-11-03 15:28:07 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-01-15 06:21:52 -05:00
|
|
|
describe PagesService, services: true do
|
2015-11-03 15:28:07 -05:00
|
|
|
let(:build) { create(:ci_build) }
|
2016-08-17 06:27:19 -04:00
|
|
|
let(:data) { Gitlab::DataBuilder::Build.build(build) }
|
2016-01-15 06:21:52 -05:00
|
|
|
let(:service) { PagesService.new(data) }
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2015-12-15 16:48:23 -05:00
|
|
|
before do
|
|
|
|
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
|
|
|
|
end
|
|
|
|
|
2015-11-03 15:28:07 -05:00
|
|
|
context 'execute asynchronously for pages job' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.name = 'pages'
|
|
|
|
end
|
2015-11-03 15:28:07 -05:00
|
|
|
|
|
|
|
context 'on success' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.success
|
|
|
|
end
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2016-08-11 11:30:18 -04:00
|
|
|
it 'executes worker' do
|
2015-11-03 15:28:07 -05:00
|
|
|
expect(PagesWorker).to receive(:perform_async)
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%w(pending running failed canceled).each do |status|
|
|
|
|
context "on #{status}" do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
build.status = status
|
|
|
|
end
|
2015-11-03 15:28:07 -05:00
|
|
|
|
2016-08-11 11:30:18 -04:00
|
|
|
it 'does not execute worker' do
|
2016-05-30 04:11:46 -04:00
|
|
|
expect(PagesWorker).not_to receive(:perform_async)
|
2015-11-03 15:28:07 -05:00
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for other jobs' do
|
|
|
|
before do
|
|
|
|
build.name = 'other job'
|
|
|
|
build.success
|
|
|
|
end
|
|
|
|
|
2016-08-11 11:30:18 -04:00
|
|
|
it 'does not execute worker' do
|
2016-05-30 04:11:46 -04:00
|
|
|
expect(PagesWorker).not_to receive(:perform_async)
|
2015-11-03 15:28:07 -05:00
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|