[#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:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user