2015-11-03 15:28:07 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UpdatePagesService, services: true do
|
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
let(:data) { Gitlab::BuildDataBuilder.build(build) }
|
|
|
|
let(:service) { UpdatePagesService.new(data) }
|
|
|
|
|
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
|
|
|
|
before { build.name = 'pages' }
|
|
|
|
|
|
|
|
context 'on success' do
|
|
|
|
before { build.success }
|
|
|
|
|
|
|
|
it 'should execute worker' do
|
|
|
|
expect(PagesWorker).to receive(:perform_async)
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
%w(pending running failed canceled).each do |status|
|
|
|
|
context "on #{status}" do
|
|
|
|
before { build.status = status }
|
|
|
|
|
|
|
|
it 'should not execute worker' do
|
|
|
|
expect(PagesWorker).to_not receive(:perform_async)
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for other jobs' do
|
|
|
|
before do
|
|
|
|
build.name = 'other job'
|
|
|
|
build.success
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not execute worker' do
|
|
|
|
expect(PagesWorker).to_not receive(:perform_async)
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|