debian-mirror-gitlab/spec/services/pages_service_spec.rb

54 lines
1.1 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe PagesService do
2017-08-17 22:00:37 +05:30
let(:build) { create(:ci_build) }
let(:data) { Gitlab::DataBuilder::Build.build(build) }
2017-09-10 17:25:29 +05:30
let(:service) { described_class.new(data) }
2017-08-17 22:00:37 +05:30
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
context 'execute asynchronously for pages job' do
2017-09-10 17:25:29 +05:30
before do
build.name = 'pages'
end
2017-08-17 22:00:37 +05:30
context 'on success' do
2017-09-10 17:25:29 +05:30
before do
build.success
end
2017-08-17 22:00:37 +05:30
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
2017-09-10 17:25:29 +05:30
before do
build.status = status
end
2017-08-17 22:00:37 +05:30
it 'does not execute worker' do
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
expect(PagesWorker).not_to receive(:perform_async)
service.execute
end
end
end