Commit 6eee8d2d authored by Shinya Maeda's avatar Shinya Maeda Committed by Alessio Caiazza

Fix process build service spec

parent af4b85ce
......@@ -98,6 +98,15 @@ FactoryBot.define do
success
end
trait :schedulable do
self.when 'delayed'
options start_in: '1 minute'
end
trait :actionable do
self.when 'manual'
end
trait :retried do
retried true
end
......
# frozen_string_literal: true
require 'spec_helper'
describe Ci::EnqueueBuildService, '#execute' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:ci_build) { create(:ci_build, :created) }
subject { described_class.new(project, user).execute(ci_build) }
it 'enqueues the build' do
subject
expect(ci_build.pending?).to be_truthy
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Ci::ProcessBuildService, '#execute' do
let(:user) { create(:user) }
let(:project) { create(:project) }
subject { described_class.new(project, user).execute(build) }
before do
project.add_maintainer(user)
end
context 'when build is schedulable' do
let(:build) { create(:ci_build, :created, :schedulable, user: user, project: project) }
context 'when ci_enable_scheduled_build feature flag is enabled' do
before do
stub_feature_flags(ci_enable_scheduled_build: true)
end
it 'schedules the build' do
subject
expect(build).to be_scheduled
end
end
context 'when ci_enable_scheduled_build feature flag is disabled' do
before do
stub_feature_flags(ci_enable_scheduled_build: false)
end
it 'enqueues the build' do
subject
expect(build).to be_pending
end
end
end
context 'when build is actionable' do
let(:build) { create(:ci_build, :created, :actionable, user: user, project: project) }
it 'actionizes the build' do
subject
expect(build).to be_manual
end
end
context 'when build does not have any actions' do
let(:build) { create(:ci_build, :created, user: user, project: project) }
it 'enqueues the build' do
subject
expect(build).to be_pending
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment