add completed_at to projects table per ticket #550. Note that this changeset includes a migration, so don't forget to rake db:migrate.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@578 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-08-28 12:38:16 +00:00
parent d29fb230f0
commit 6805b22945
6 changed files with 17 additions and 4 deletions

View file

@ -1,6 +1,6 @@
class Context < ActiveRecord::Base
has_many :todos, :dependent => :delete_all, :include => :project, :order => "completed_at DESC"
has_many :todos, :dependent => :delete_all, :include => :project, :order => "todos.completed_at DESC"
belongs_to :user
acts_as_list :scope => :user

View file

@ -16,7 +16,7 @@ class Project < ActiveRecord::Base
state :active
state :hidden, :enter => :hide_todos, :exit => :unhide_todos
state :completed
state :completed#, :enter => Proc.new { |p| p.completed_at = Time.now.utc }, :exit => Proc.new { |p| p.completed_at = nil }
event :activate do
transitions :to => :active, :from => [:hidden, :completed]

View file

@ -53,7 +53,7 @@ class User < ActiveRecord::Base
end
end
has_many :todos,
:order => 'completed_at DESC, todos.created_at DESC',
:order => 'todos.completed_at DESC, todos.created_at DESC',
:dependent => :delete_all
has_many :deferred_todos,
:class_name => 'Todo',

View file

@ -0,0 +1,9 @@
class AddProjectCompletedAtColumn < ActiveRecord::Migration
def self.up
add_column :projects, :completed_at, :datetime
end
def self.down
remove_column :projects, :completed_at
end
end

View file

@ -2,7 +2,7 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
ActiveRecord::Schema.define(:version => 34) do
ActiveRecord::Schema.define(:version => 36) do
create_table "bow_wows", :force => true do |t|
t.column "name", :string
@ -132,6 +132,7 @@ ActiveRecord::Schema.define(:version => 34) do
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "default_context_id", :integer
t.column "completed_at", :datetime
end
add_index "projects", ["user_id"], :name => "index_projects_on_user_id"

View file

@ -57,9 +57,12 @@ class ProjectTest < Test::Rails::TestCase
end
def test_complete_project
assert_nil @timemachine.completed_at
@timemachine.complete!
assert_equal :completed, @timemachine.current_state
assert @timemachine.completed?
assert_not_nil @timemachine.completed_at, "completed_at not expected to be nil"
assert_in_delta Time.now, @timemachine.completed_at, 1
end
def test_find_project_by_namepart_with_exact_match