mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-05 23:41:48 +01:00
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:
parent
d29fb230f0
commit
6805b22945
6 changed files with 17 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
9
tracks/db/migrate/036_add_project_completed_at_column.rb
Normal file
9
tracks/db/migrate/036_add_project_completed_at_column.rb
Normal 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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue