summaryrefslogtreecommitdiff
path: root/spec/workers/ci
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-09-27 17:50:50 +0900
committerAlessio Caiazza <acaiazza@gitlab.com>2018-10-02 17:08:12 +0200
commit71fc37c9cf8aee5de3d4d43ec6ea97a56e34537d (patch)
tree23b8879719b4f36db301c4ca107a34a516860d54 /spec/workers/ci
parent80a92650faf9d7ca7a706b6a74019d869598fe41 (diff)
downloadgitlab-ce-71fc37c9cf8aee5de3d4d43ec6ea97a56e34537d.tar.gz
Add spec for BuildScheduleWorker and RunScheduledBuildService
Diffstat (limited to 'spec/workers/ci')
-rw-r--r--spec/workers/ci/build_schedule_worker_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/workers/ci/build_schedule_worker_spec.rb b/spec/workers/ci/build_schedule_worker_spec.rb
new file mode 100644
index 00000000000..c76537b9233
--- /dev/null
+++ b/spec/workers/ci/build_schedule_worker_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe Ci::BuildScheduleWorker do
+ subject { described_class.new.perform(build.id) }
+
+ context 'when build is found' do
+ context 'when build is scheduled' do
+ let(:build) { create(:ci_build, :scheduled) }
+
+ it 'executes RunScheduledBuildService' do
+ expect_any_instance_of(Ci::RunScheduledBuildService)
+ .to receive(:execute).once
+
+ subject
+ end
+ end
+
+ context 'when build is not scheduled' do
+ let(:build) { create(:ci_build, :created) }
+
+ it 'executes RunScheduledBuildService' do
+ expect_any_instance_of(Ci::RunScheduledBuildService)
+ .not_to receive(:execute)
+
+ subject
+ end
+ end
+ end
+
+ context 'when build is not found' do
+ let(:build) { build_stubbed(:ci_build, :scheduled) }
+
+ it 'does nothing' do
+ expect_any_instance_of(Ci::RunScheduledBuildService)
+ .not_to receive(:execute)
+
+ subject
+ end
+ end
+end