mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
9ebabc1de8
Previously we would bypass touching `Topic.updated_at` for whispers and post recovery / deletions. This meant that certain types of caching can not be done where we rely on this information for cache accuracy. For example if we know we have zero unread topics as of yesterday and whisper is made I need to bump this date so the cache remains accurate This is only half of a larger change but provides the groundwork. Confirmed none of our serializers leak out Topic.updated_at so this is safe spot for this info At the moment edits still do not change this but it is not relevant for the unread cache. This commit also cleans up some specs to use the new `eq_time` matcher for millisecond fidelity comparison of times Previously `freeze_time` would fudge this which is not that clean.
18 lines
492 B
Ruby
18 lines
492 B
Ruby
RSpec::Matchers.define :be_within_one_second_of do |expected_time|
|
|
match do |actual_time|
|
|
(actual_time - expected_time).abs < 1
|
|
end
|
|
failure_message do |actual_time|
|
|
"#{actual_time} is not within 1 second of #{expected_time}"
|
|
end
|
|
end
|
|
|
|
RSpec::Matchers.define :eq_time do |expected_time|
|
|
match do |actual_time|
|
|
(actual_time - expected_time).abs < 0.001
|
|
end
|
|
failure_message do |actual_time|
|
|
"#{actual_time} is not within 1 millisecond of #{expected_time}"
|
|
end
|
|
end
|