move cron creation to query

This commit is contained in:
Steffen Kötte 2016-02-01 16:50:10 +01:00
parent 0d1dbaadd7
commit 3fa9c09c0c
2 changed files with 7 additions and 4 deletions

View File

@ -12,5 +12,10 @@ module Travis::API::V3
def find_for_branch(branch)
branch.cron
end
def create(branch, interval, disable_by_build)
branch.cron.destroy unless branch.cron.nil?
Models::Cron.create(branch: branch, interval: interval, disable_by_build: disable_by_build)
end
end
end

View File

@ -12,12 +12,10 @@ module Travis::API::V3
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)
query.create(branch, params["interval"], params["disable_by_build"] ? params["disable_by_build"] : false)
end
end