gitlab-org--gitlab-foss/spec/services/pages_service_spec.rb

54 lines
1.1 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe PagesService, services: true do
let(:build) { create(:ci_build) }
2016-08-17 06:27:19 -04:00
let(:data) { Gitlab::DataBuilder::Build.build(build) }
let(:service) { PagesService.new(data) }
2015-12-15 16:48:23 -05:00
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
context 'execute asynchronously for pages job' do
before do
build.name = 'pages'
end
context 'on success' do
before do
build.success
end
it 'executes 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 do
build.status = status
end
it 'does not execute worker' do
2016-05-30 04:11:46 -04:00
expect(PagesWorker).not_to receive(:perform_async)
service.execute
end
end
end
end
context 'for other jobs' do
before do
build.name = 'other job'
build.success
end
it 'does not execute worker' do
2016-05-30 04:11:46 -04:00
expect(PagesWorker).not_to receive(:perform_async)
service.execute
end
end
end