mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 13:15:17 +01:00
Eliminated unnecessary double UPDATE on each todo when activating deferred Todos.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@659 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
b16ff933cb
commit
584fdf2d34
3 changed files with 3 additions and 8 deletions
|
|
@ -60,11 +60,6 @@ class Todo < ActiveRecord::Base
|
|||
return saved
|
||||
end
|
||||
|
||||
def activate_and_save!
|
||||
activate!
|
||||
save!
|
||||
end
|
||||
|
||||
def show_from
|
||||
self[:show_from]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class User < ActiveRecord::Base
|
|||
:conditions => [ 'state = ?', 'deferred' ],
|
||||
:order => 'show_from ASC, todos.created_at DESC' do
|
||||
def find_and_activate_ready
|
||||
find(:all, :conditions => ['show_from <= ?', proxy_owner.time ]).collect { |t| t.activate_and_save! }
|
||||
find(:all, :conditions => ['show_from <= ?', proxy_owner.time ]).collect { |t| t.activate! }
|
||||
end
|
||||
end
|
||||
has_many :completed_todos,
|
||||
|
|
|
|||
|
|
@ -107,13 +107,13 @@ class TodoTest < Test::Rails::TestCase
|
|||
assert_equal :active, t.current_state
|
||||
end
|
||||
|
||||
def test_activate_and_save
|
||||
def test_activate_also_saves
|
||||
t = @not_completed1
|
||||
t.show_from = 1.week.from_now.to_date
|
||||
t.save!
|
||||
assert t.deferred?
|
||||
t.reload
|
||||
t.activate_and_save!
|
||||
t.activate!
|
||||
assert t.active?
|
||||
t.reload
|
||||
assert t.active?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue