Commit 62480461 authored by Shinya Maeda's avatar Shinya Maeda

Fixed failed tests

parent d9574c0c
...@@ -21,7 +21,7 @@ describe Ci::TriggerSchedule, models: true do ...@@ -21,7 +21,7 @@ describe Ci::TriggerSchedule, models: true do
trigger_schedule.valid? trigger_schedule.valid?
end end
context 'when every hour' do context 'when cron frequency is too short' do
let(:cron) { '0 * * * *' } # 00:00, 01:00, 02:00, ..., 23:00 let(:cron) { '0 * * * *' } # 00:00, 01:00, 02:00, ..., 23:00
it 'gets an error' do it 'gets an error' do
...@@ -29,8 +29,8 @@ describe Ci::TriggerSchedule, models: true do ...@@ -29,8 +29,8 @@ describe Ci::TriggerSchedule, models: true do
end end
end end
context 'when each six hours' do context 'when cron frequency is eligible' do
let(:cron) { '0 */6 * * *' } # 00:00, 06:00, 12:00, 18:00 let(:cron) { '0 0 1 1 *' } # every 00:00, January 1st
it 'gets no errors' do it 'gets no errors' do
expect(trigger_schedule.errors[:cron]).to be_empty expect(trigger_schedule.errors[:cron]).to be_empty
...@@ -39,17 +39,15 @@ describe Ci::TriggerSchedule, models: true do ...@@ -39,17 +39,15 @@ describe Ci::TriggerSchedule, models: true do
end end
describe '#schedule_next_run!' do describe '#schedule_next_run!' do
context 'when more_than_1_hour_from_now' do let(:trigger_schedule) { create(:ci_trigger_schedule, :cron_nightly_build) }
let(:trigger_schedule) { create(:ci_trigger_schedule, :cron_nightly_build) }
before do before do
trigger_schedule.schedule_next_run! trigger_schedule.schedule_next_run!
end end
it 'updates next_run_at' do it 'updates next_run_at' do
next_time = Ci::CronParser.new(trigger_schedule.cron, trigger_schedule.cron_time_zone).next_time_from(Time.now) next_time = Ci::CronParser.new(trigger_schedule.cron, trigger_schedule.cron_time_zone).next_time_from(Time.now)
expect(Ci::TriggerSchedule.last.next_run_at).to eq(next_time) expect(Ci::TriggerSchedule.last.next_run_at).to eq(next_time)
end
end end
end 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