Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-join Model and Record and fix failing specs in spec/. yes. that me…
…ans, green, motherfucker, do you speak it.
- Loading branch information
Sven Fuchs
committed
Nov 1, 2011
1 parent
c44c889
commit ecc4cdb
Showing
94 changed files
with
2,123 additions
and
1,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
--colour | ||
--tty | ||
--drb | ||
--format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ Travis.Job = Travis.Record.extend({ | |
}); | ||
|
||
Travis.Job.reopenClass({ | ||
resource: 'jobs' | ||
resource: 'queues' | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class QueuesController < ApplicationController | ||
def index | ||
respond_to do |format| | ||
format.json { render :json => jobs } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
namespace :test do | ||
desc "a little shortcut for ci testing" | ||
task :ci => ["db:drop", "db:create", "db:test:load", "spec"] | ||
desc 'a little shortcut for ci testing' | ||
task :ci => ['ci_env', 'db:drop', 'db:create', 'db:test:load', 'spec_fast', 'spec'] | ||
|
||
RSpec::Core::RakeTask.new(:spec_fast) do |t| | ||
t.rspec_opts = '-Ispec_fast' | ||
t.pattern = "./spec_fast/**/*_spec.rb" | ||
end | ||
end | ||
|
||
task :ci_env do | ||
ENV['CI'] = 'true' | ||
ENV['RAILS_ENV'] = 'test' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,88 @@ | ||
require 'simple_states' | ||
require 'active_record' | ||
require 'core_ext/active_record/base' | ||
require 'core_ext/hash/deep_symbolize_keys' | ||
|
||
module Travis | ||
class Model | ||
class Build < Model | ||
autoload :Notifications, 'travis/model/build/notifications' | ||
class Build < ActiveRecord::Base | ||
autoload :Notifications, 'travis/model/build/notifications' | ||
autoload :Matrix, 'travis/model/build/matrix' | ||
autoload :Messages, 'travis/model/build/messages' | ||
autoload :Denormalize, 'travis/model/build/denormalize' | ||
autoload :States, 'travis/model/build/states' | ||
|
||
include Notifications, SimpleStates, Travis::Notifications | ||
include Matrix, States, Messages | ||
|
||
states :created, :started, :finished | ||
PER_PAGE = 10 | ||
|
||
event :start, :to => :started | ||
event :finish, :to => :finished, :if => :matrix_finished? | ||
event :all, :after => [:denormalize, :notify] | ||
belongs_to :commit | ||
belongs_to :request | ||
belongs_to :repository, :autosave => true | ||
has_many :matrix, :as => :owner, :order => :id, :class_name => 'Job::Test' | ||
|
||
delegate :state, :state=, :config, :passed?, :failed?, :matrix_finished?, :denormalize, :to => :record | ||
validates :repository_id, :commit_id, :request_id, :presence => true | ||
|
||
serialize :config | ||
|
||
class << self | ||
def recent(options = {}) | ||
was_started.descending.paged(options).includes([:commit, { :matrix => :commit }]) | ||
end | ||
|
||
def was_started | ||
where(:state => ['started', 'finished']) | ||
end | ||
|
||
def finished | ||
where(:state => 'finished') | ||
end | ||
|
||
def on_branch(branches) | ||
branches = normalize_to_array(branches) | ||
joins(:commit).where(branches.present? ? ["commits.branch IN (?)", branches] : []) | ||
end | ||
|
||
def previous(build) | ||
where("builds.repository_id = ? AND builds.id < ?", build.repository_id, build.id).finished.descending.limit(1).first | ||
end | ||
|
||
def last_finished_on_branch(branches) | ||
finished.on_branch(branches).descending.first | ||
end | ||
|
||
def descending | ||
order(arel_table[:id].desc) | ||
end | ||
|
||
def paged(options) | ||
# TODO should use an offset when we use limit! | ||
# offset(PER_PAGE * options[:offset]).limit(options[:page]) | ||
limit(PER_PAGE * (options[:page] || 1).to_i) | ||
end | ||
|
||
def next_number | ||
maximum(floor('number')).to_i + 1 | ||
end | ||
|
||
protected | ||
|
||
def normalize_to_array(object) | ||
Array(object).compact.join(',').split(',') | ||
end | ||
end | ||
|
||
after_initialize do | ||
self.config = {} if config.nil? | ||
end | ||
|
||
before_create do | ||
self.number = repository.builds.next_number | ||
expand_matrix | ||
end | ||
|
||
def previous_on_branch | ||
Build.on_branch(commit.branch).previous(self) | ||
end | ||
|
||
def config=(config) | ||
super(config.deep_symbolize_keys) | ||
end | ||
end |
3 changes: 1 addition & 2 deletions
3
lib/travis/record/build/denormalize.rb → lib/travis/model/build/denormalize.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.