Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-03-29 21:33:23 +0300
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-06 17:46:58 +0300
commit2a1a7310d04f6d64a983d2438fdcc515e7118d91 (patch)
tree6726a9c68d322a292665bceedd7df9fea212a74b /lib
parent75f5e710434fbe6d709e6895c8c9328c9e92962e (diff)
Add validation to Ci::TriggerSchedule (Halfway)
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/cron_parser.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/ci/cron_parser.rb b/lib/ci/cron_parser.rb
index 24c4dd676dc..b0ffb48dabc 100644
--- a/lib/ci/cron_parser.rb
+++ b/lib/ci/cron_parser.rb
@@ -6,20 +6,22 @@ module Ci
end
def next_time_from_now
- cronLine = try_parse_cron
+ cronLine = try_parse_cron(@cron, @cron_time_zone)
return nil unless cronLine.present?
cronLine.next_time
end
- def valid_syntax?
- try_parse_cron.present? ? true : false
+ def validation
+ is_valid_cron = try_parse_cron(@cron, 'Europe/Istanbul').present?
+ is_valid_cron_time_zone = try_parse_cron('* * * * *', @cron_time_zone).present?
+ return is_valid_cron, is_valid_cron_time_zone
end
private
- def try_parse_cron
+ def try_parse_cron(cron, cron_time_zone)
begin
- Rufus::Scheduler.parse("#{@cron} #{@cron_time_zone}")
+ Rufus::Scheduler.parse("#{cron} #{cron_time_zone}")
rescue
nil
end