check for correct interval
allow only one cronjob per branch
This commit is contained in:
parent
0920041375
commit
68ba4b9fce
|
@ -7,7 +7,14 @@ module Travis::API::V3
|
||||||
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
|
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
|
||||||
raise NotFound unless repository = find(:repository)
|
raise NotFound unless repository = find(:repository)
|
||||||
raise NotFound unless branch = find(:branch, 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!
|
access_control.permissions(repository).create_cron!
|
||||||
|
|
||||||
|
if branch.cron
|
||||||
|
access_control.permissions(branch.cron).delete!
|
||||||
|
branch.cron.destroy
|
||||||
|
end
|
||||||
|
|
||||||
Models::Cron.create(branch: branch,
|
Models::Cron.create(branch: branch,
|
||||||
interval: params["interval"],
|
interval: params["interval"],
|
||||||
disable_by_build: params["disable_by_build"] ? params["disable_by_build"] : false)
|
disable_by_build: params["disable_by_build"] ? params["disable_by_build"] : false)
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user