Unverified Commit 4131ed2b authored by Shinya Maeda's avatar Shinya Maeda Committed by Kamil Trzcinski

before_create :set_project. Now TriggerSchedule saves project from parent

parent ea8574fd
......@@ -15,11 +15,15 @@ module Ci
validates :cron_timezone, cron_timezone: true, presence: { unless: :importing? }
validates :ref, presence: { unless: :importing? }
before_create :set_project
before_save :set_next_run_at
def set_project
self.project = trigger.project
end
def set_next_run_at
self.next_run_at = Gitlab::Ci::CronParser.new(cron, cron_timezone).next_time_from(Time.now)
self.project = trigger.project
end
def schedule_next_run!
......
......@@ -4,10 +4,6 @@ FactoryGirl.define do
cron '0 1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
after(:build) do |trigger_schedule, evaluator|
trigger_schedule.update!(project: trigger_schedule.trigger.project)
end
trait :nightly do
cron '0 1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
......
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