summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-06 18:52:48 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-06 23:46:59 +0900
commit48e07eab5755770bff9d5ee1aca33526e4120637 (patch)
tree5e0fa0adcbb54fef88262dd2469f5c902c54f157 /spec/workers
parent12a5380f5cb2ce8b652344f053b2333f6f5e80a9 (diff)
downloadgitlab-ce-48e07eab5755770bff9d5ee1aca33526e4120637.tar.gz
Improve trigger_schedule.rb
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/trigger_schedule_worker_spec.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/workers/trigger_schedule_worker_spec.rb b/spec/workers/trigger_schedule_worker_spec.rb
index 3997369489f..c48f1406c34 100644
--- a/spec/workers/trigger_schedule_worker_spec.rb
+++ b/spec/workers/trigger_schedule_worker_spec.rb
@@ -8,10 +8,12 @@ describe TriggerScheduleWorker do
end
context 'when there is a scheduled trigger within next_run_at' do
- let!(:trigger_schedule) { create(:ci_trigger_schedule, :nightly, :force_triggable) }
- let(:next_time) { Gitlab::Ci::CronParser.new(trigger_schedule.cron, trigger_schedule.cron_timezone).next_time_from(Time.now) }
+ let!(:trigger_schedule) { create(:ci_trigger_schedule, :nightly) }
+ let(:next_time) { Gitlab::Ci::CronParser.new(trigger_schedule.cron, trigger_schedule.cron_timezone).next_time_from(@time_future) }
before do
+ @time_future = Time.now + 10.days
+ allow(Time).to receive(:now).and_return(@time_future)
worker.perform
end
@@ -43,4 +45,21 @@ describe TriggerScheduleWorker do
expect(trigger_schedule.next_run_at).to eq(Ci::TriggerSchedule.last.next_run_at)
end
end
+
+ context 'when next_run_at is nil' do
+ let!(:trigger_schedule) { create(:ci_trigger_schedule, :nightly) }
+
+ before do
+ trigger_schedule.update_attribute(:next_run_at, nil)
+ worker.perform
+ end
+
+ it 'does not create a new pipeline' do
+ expect(Ci::Pipeline.count).to eq(0)
+ end
+
+ it 'does not update next_run_at' do
+ expect(trigger_schedule.next_run_at).to eq(Ci::TriggerSchedule.last.next_run_at)
+ end
+ end
end