rename next_build_time to next_enqueuing

This commit is contained in:
Steffen Kötte 2016-01-28 13:46:35 +01:00
parent 24b0af35e9
commit 64478d50d1
9 changed files with 27 additions and 27 deletions

View File

@ -16,7 +16,7 @@ module Travis::API::V3
payload payload
end end
def next_build_time def next_enqueuing
if (disable_by_build) && (last_non_cron_build_date > last_planned_time) if (disable_by_build) && (last_non_cron_build_date > last_planned_time)
return after_next_planned_time return after_next_planned_time

View File

@ -3,7 +3,7 @@ require 'travis/api/v3/renderer/model_renderer'
module Travis::API::V3 module Travis::API::V3
class Renderer::Cron < Renderer::ModelRenderer class Renderer::Cron < Renderer::ModelRenderer
representation(:minimal, :id) representation(:minimal, :id)
representation(:standard, :id, :repository, :branch, :interval, :disable_by_build, :next_build_time) representation(:standard, :id, :repository, :branch, :interval, :disable_by_build, :next_enqueuing)
def repository def repository
model.branch.repository model.branch.repository

View File

@ -5,7 +5,7 @@ module Travis::API::V3
started = [] started = []
Models::Cron.all.each do |cron| Models::Cron.all.each do |cron|
if cron.next_build_time <= Time.now if cron.next_enqueuing <= Time.now
cron.start cron.start
started.push cron started.push cron
end end

View File

@ -18,7 +18,7 @@ describe Travis::API::V3::Models::Cron do
it "for daily builds" do it "for daily builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 1, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 1, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -26,7 +26,7 @@ describe Travis::API::V3::Models::Cron do
it "for weekly builds" do it "for weekly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 7, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 7, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -34,7 +34,7 @@ describe Travis::API::V3::Models::Cron do
it "for monthly builds" do it "for monthly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 31, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 31, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -55,7 +55,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false)
cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 1, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 1, 16)
cron_build.destroy cron_build.destroy
push_build.destroy push_build.destroy
cron.destroy cron.destroy
@ -65,7 +65,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false)
cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 7, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 7, 16)
cron_build.destroy cron_build.destroy
push_build.destroy push_build.destroy
cron.destroy cron.destroy
@ -75,7 +75,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false)
cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') cron_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') push_build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 31, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 31, 16)
cron_build.destroy cron_build.destroy
push_build.destroy push_build.destroy
cron.destroy cron.destroy
@ -96,7 +96,7 @@ describe Travis::API::V3::Models::Cron do
it "for daily builds" do it "for daily builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 2, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 2, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -104,7 +104,7 @@ describe Travis::API::V3::Models::Cron do
it "for weekly builds" do it "for weekly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 14, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 14, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -112,7 +112,7 @@ describe Travis::API::V3::Models::Cron do
it "for monthly builds" do it "for monthly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'push')
expect(cron.next_build_time).to be == DateTime.new(2016, 2, 29, 16) # it's a leap year :-D expect(cron.next_enqueuing).to be == DateTime.new(2016, 2, 29, 16) # it's a leap year :-D
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -132,7 +132,7 @@ describe Travis::API::V3::Models::Cron do
it "for daily builds" do it "for daily builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 1, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 1, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -140,7 +140,7 @@ describe Travis::API::V3::Models::Cron do
it "for weekly builds" do it "for weekly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 7, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 7, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -148,7 +148,7 @@ describe Travis::API::V3::Models::Cron do
it "for monthly builds" do it "for monthly builds" do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
expect(cron.next_build_time).to be == DateTime.new(2016, 1, 31, 16) expect(cron.next_enqueuing).to be == DateTime.new(2016, 1, 31, 16)
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -171,7 +171,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 1, 19)) Timecop.freeze(DateTime.new(2016, 1, 1, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -181,7 +181,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'daily', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 1, 19)) Timecop.freeze(DateTime.new(2016, 1, 1, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -191,7 +191,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 7, 19)) Timecop.freeze(DateTime.new(2016, 1, 7, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -201,7 +201,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'weekly', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 7, 19)) Timecop.freeze(DateTime.new(2016, 1, 7, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -211,7 +211,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: true)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 31, 19)) Timecop.freeze(DateTime.new(2016, 1, 31, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end
@ -221,7 +221,7 @@ describe Travis::API::V3::Models::Cron do
cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false) cron = Travis::API::V3::Models::Cron.create(branch_id: branch.id, interval: 'monthly', disable_by_build: false)
build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron') build = Travis::API::V3::Models::Build.create(:repository_id => repo.id, :branch_name => branch.name, :event_type => 'cron')
Timecop.freeze(DateTime.new(2016, 1, 31, 19)) Timecop.freeze(DateTime.new(2016, 1, 31, 19))
expect(cron.next_build_time).to be == DateTime.now expect(cron.next_enqueuing).to be == DateTime.now
build.destroy build.destroy
cron.destroy cron.destroy
end end

View File

@ -39,7 +39,7 @@ describe Travis::API::V3::Services::Cron::Create do
"name" => "#{branch.name}" }, "name" => "#{branch.name}" },
"interval" => "monthly", "interval" => "monthly",
"disable_by_build" => false, "disable_by_build" => false,
"next_build_time" => current_cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => current_cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
}} }}
end end

View File

@ -35,7 +35,7 @@ describe Travis::API::V3::Services::Cron::Delete do
"name" => branch.name }, "name" => branch.name },
"interval" => "daily", "interval" => "daily",
"disable_by_build" => true, "disable_by_build" => true,
"next_build_time" => cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
}} }}
end end

View File

@ -31,7 +31,7 @@ describe Travis::API::V3::Services::Cron::Find do
"name" => branch.name }, "name" => branch.name },
"interval" => "daily", "interval" => "daily",
"disable_by_build" => true, "disable_by_build" => true,
"next_build_time" => cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
}} }}
end end
@ -89,7 +89,7 @@ describe Travis::API::V3::Services::Cron::Find do
"name" => branch.name }, "name" => branch.name },
"interval" => "daily", "interval" => "daily",
"disable_by_build" => true, "disable_by_build" => true,
"next_build_time" => cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
}} }}
end end

View File

@ -32,7 +32,7 @@ describe Travis::API::V3::Services::Cron::ForBranch do
"name" => branch.name }, "name" => branch.name },
"interval" => "daily", "interval" => "daily",
"disable_by_build" => true, "disable_by_build" => true,
"next_build_time" => cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
}} }}
end end

View File

@ -53,7 +53,7 @@ describe Travis::API::V3::Services::Crons::ForRepository do
"name" => "#{branch.name}" }, "name" => "#{branch.name}" },
"interval" => "daily", "interval" => "daily",
"disable_by_build" => true, "disable_by_build" => true,
"next_build_time" => cron.next_build_time.strftime('%Y-%m-%dT%H:%M:%SZ') "next_enqueuing" => cron.next_enqueuing.strftime('%Y-%m-%dT%H:%M:%SZ')
} }
] ]
}} }}