From b45b3fadf7ad1e6e24420c6db3af074129952c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Ko=CC=88tte?= Date: Thu, 7 Jan 2016 15:00:08 +0100 Subject: [PATCH] changes for new db structure --- lib/travis/api/v3/models/branch.rb | 2 +- lib/travis/api/v3/routes.rb | 2 +- lib/travis/api/v3/services/crons/create.rb | 13 +++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/travis/api/v3/models/branch.rb b/lib/travis/api/v3/models/branch.rb index 8768c9de..fa0d1682 100644 --- a/lib/travis/api/v3/models/branch.rb +++ b/lib/travis/api/v3/models/branch.rb @@ -4,7 +4,7 @@ module Travis::API::V3 belongs_to :last_build, class_name: 'Travis::API::V3::Models::Build'.freeze has_many :builds, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'builds.id DESC'.freeze, conditions: { event_type: 'push' } has_many :commits, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'commits.id DESC'.freeze - has_many :crons, dependent: :delete_all + has_one :crons, dependent: :delete def default_branch name == repository.default_branch_name diff --git a/lib/travis/api/v3/routes.rb b/lib/travis/api/v3/routes.rb index 6215ad48..5fdc8a89 100644 --- a/lib/travis/api/v3/routes.rb +++ b/lib/travis/api/v3/routes.rb @@ -86,7 +86,7 @@ module Travis::API::V3 get :find resource :crons do - route '/crons' + route '/cron' get :find post :create, '/create' diff --git a/lib/travis/api/v3/services/crons/create.rb b/lib/travis/api/v3/services/crons/create.rb index b5fba683..a8aa1de4 100644 --- a/lib/travis/api/v3/services/crons/create.rb +++ b/lib/travis/api/v3/services/crons/create.rb @@ -1,7 +1,7 @@ module Travis::API::V3 class Services::Crons::Create < Service result_type :cron - params :mon, :tue, :wed, :thu, :fri, :sat, :sun, :disable_by_push, :hour + params :type, :disable_by_build def run! raise LoginRequired unless access_control.logged_in? or access_control.full_access? @@ -9,15 +9,8 @@ module Travis::API::V3 raise NotFound unless branch = find(:branch, repository) access_control.permissions(repository).create_cron! Models::Cron.create(branch: branch, - mon: value("mon"), - tue: value("tue"), - wed: value("wed"), - thu: value("thu"), - fri: value("fri"), - sat: value("sat"), - sun: value("sun"), - hour: params["hour"], - disable_by_push: value("disable_by_push")) + type: params["type"], + disable_by_build: value("disable_by_build")) end def value s