diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/ci/trigger_schedules.rb (renamed from spec/factories/ci/scheduled_triggers.rb) | 0 | ||||
-rw-r--r-- | spec/factories/ci/triggers.rb | 2 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/workers/trigger_schedule_worker_spec.rb | 14 |
4 files changed, 12 insertions, 8 deletions
diff --git a/spec/factories/ci/scheduled_triggers.rb b/spec/factories/ci/trigger_schedules.rb index f909e343bf2..f909e343bf2 100644 --- a/spec/factories/ci/scheduled_triggers.rb +++ b/spec/factories/ci/trigger_schedules.rb diff --git a/spec/factories/ci/triggers.rb b/spec/factories/ci/triggers.rb index a27b04424e5..1feaa9b9fa1 100644 --- a/spec/factories/ci/triggers.rb +++ b/spec/factories/ci/triggers.rb @@ -1,7 +1,7 @@ FactoryGirl.define do factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger do - token 'token' + token { SecureRandom.hex(10) } end end end diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 4e34acc3585..d2f0337c260 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -214,9 +214,5 @@ describe Ci::CreatePipelineService, services: true do expect(Environment.find_by(name: "review/master")).not_to be_nil end end - - context 'when scheduled_trigger' do - # TODO: spec if approved - end end end diff --git a/spec/workers/trigger_schedule_worker_spec.rb b/spec/workers/trigger_schedule_worker_spec.rb index 6c7521e8339..2cf51a31c71 100644 --- a/spec/workers/trigger_schedule_worker_spec.rb +++ b/spec/workers/trigger_schedule_worker_spec.rb @@ -8,18 +8,26 @@ describe TriggerScheduleWorker do end context 'when there is a scheduled trigger within next_run_at' do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:trigger) { create(:ci_trigger, owner: user, project: project, ref: 'master') } + let!(:trigger_schedule) { create(:ci_trigger_schedule, :cron_nightly_build, :force_triggable, trigger: trigger, project: project) } + before do - create(:ci_trigger_schedule, :cron_nightly_build, :force_triggable) worker.perform end + it 'creates a new trigger request' do + expect(Ci::TriggerRequest.first.trigger_id).to eq(trigger.id) + end + it 'creates a new pipeline' do expect(Ci::Pipeline.last.status).to eq('pending') end it 'schedules next_run_at' do - trigger_schedule2 = create(:ci_trigger_schedule, :cron_nightly_build) - expect(Ci::TriggerSchedule.last.next_run_at).to eq(trigger_schedule2.next_run_at) + next_time = Ci::CronParser.new('0 1 * * *', 'Europe/Istanbul').next_time_from_now + expect(Ci::TriggerSchedule.last.next_run_at).to eq(next_time) end end |