Retain content-validated message fragments across unrelated commits

This commit is contained in:
GPT on behalf of DHH
2026-10-08 12:00:45 +02:00
parent 59e1c6d3d7
commit 74381e8b58
10 changed files with 48 additions and 9 deletions
+15
View File
@@ -74,6 +74,21 @@ class FragmentRenderingTest < ActionDispatch::IntegrationTest
assert_select "form[action=?]", message_boosts_path(@message)
end
test "a commit in another room retains content-validated message collection hits" do
ResponseCache.instance.stubs(:budget).returns(0)
get room_messages_url(@room)
assert_response :success
foreign_write("UPDATE rooms SET name = ? WHERE id = ?", "Unrelated room rename", rooms(:pets).id)
collections = []
ActiveSupport::Notifications.subscribed(->(event) { collections << event.payload }, "render_collection.action_view") do
get room_messages_url(@room)
end
assert_response :success
messages = collections.find { |payload| payload[:identifier].end_with?("messages/_message.html.erb") }
assert messages
assert_equal @room.messages.count, messages[:cache_hits]
end
test "a foreign commit after capture bypasses old native fragment lookups" do
ResponseCache.instance.stubs(:budget).returns(0)
get room_messages_url(@room)