fix: Use correct room messages in pagination tests

Fixed test bug identified by Copilot code review: pagination tests were
using Message.first and Message.last which could return messages from
different rooms than the test's @room (watercooler).

Now explicitly using messages(:fourth) and messages(:thirteenth) which
are fixtures belonging to the watercooler room where bender bot is a member.

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
John-Mason Shackelford
2026-04-08 14:45:02 -04:00
parent 057d56513e
commit c82a8d38c0
@@ -79,12 +79,16 @@ class Messages::ByBotsControlleTest < ActionDispatch::IntegrationTest
end
test "index supports pagination with before parameter" do
get room_bot_messages_index_url(@room, users(:bender).bot_key, before: Message.last.id)
# Use a message from the watercooler room (where bender is a member)
message_in_room = messages(:thirteenth) # Latest message in watercooler
get room_bot_messages_index_url(@room, users(:bender).bot_key, before: message_in_room.id)
assert_response :success
end
test "index supports pagination with after parameter" do
get room_bot_messages_index_url(@room, users(:bender).bot_key, after: Message.first.id)
# Use a message from the watercooler room (where bender is a member)
message_in_room = messages(:fourth) # First message in watercooler
get room_bot_messages_index_url(@room, users(:bender).bot_key, after: message_in_room.id)
assert_response :success
end