check for correct interval

allow only one cronjob per branch
This commit is contained in:
Steffen Kötte 2016-01-11 14:54:02 +01:00
parent 0920041375
commit 68ba4b9fce
2 changed files with 7 additions and 9 deletions

View File

@ -7,7 +7,14 @@ module Travis::API::V3
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
raise NotFound unless repository = find(:repository)
raise NotFound unless branch = find(:branch, repository)
raise ArgumentError, 'interval must be "daily", "weekly" or "monthly"' unless ["daily", "weekly", "monthly"].include?(params["interval"])
access_control.permissions(repository).create_cron!
if branch.cron
access_control.permissions(branch.cron).delete!
branch.cron.destroy
end
Models::Cron.create(branch: branch,
interval: params["interval"],
disable_by_build: params["disable_by_build"] ? params["disable_by_build"] : false)

View File

@ -1,9 +0,0 @@
module Travis::API::V3
class Services::Crons::Find < Service
paginate
def run!
query.find(find(:branch, find(:repository)))
end
end
end