[#5734] Fix the cost caching case where Time Entry attributes changed

A cost value wasn't getting recaclulated by TimeEntry#cost when the
attributes were changing. It only was recalculated when .cost changed.
This commit is contained in:
Eric Davis
2011-04-06 09:27:20 -07:00
parent b20ebe587b
commit 4c3e6b6b6d
2 changed files with 32 additions and 4 deletions
@@ -71,6 +71,21 @@ class RateTimeEntryPatchTest < ActiveSupport::TestCase
assert_equal 2000.0, @time_entry.read_attribute(:cost)
end
should "clear and recalculate the cache when the attribute is already set but stale" do
# Set the cost
assert @time_entry.save
assert_equal 2000.0, @time_entry.read_attribute(:cost)
@time_entry.reload
@time_entry.hours = 20
assert @time_entry.save
assert_equal 4000.0, @time_entry.read_attribute(:cost)
assert_equal 4000.0, @time_entry.reload.cost
end
end