From 12928f530b0415144d4f6864e30678dc339bf754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Pinz=C3=B3n=20Eslava?= <10928518+pinzonjulian@users.noreply.github.com> Date: Sun, 21 Dec 2025 00:23:21 +1100 Subject: [PATCH] Refactor search test to use instance variables The included SearchTestHelper disables transactional tests and has a specific setup that does not use fixtures. This test however, ignores the setup and uses fixtures directly by creating comments and publishing cards making test state unpredictable. By using the records set by the helper instead of fixtures, the state of the system is not polluted. --- test/models/filter/search_test.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/models/filter/search_test.rb b/test/models/filter/search_test.rb index 6adeebacb4..f7b7e79686 100644 --- a/test/models/filter/search_test.rb +++ b/test/models/filter/search_test.rb @@ -4,15 +4,12 @@ class Filter::SearchTest < ActiveSupport::TestCase include SearchTestHelper test "deduplicate multiple results" do - user = users(:david) - - board = boards(:writebook) - card = board.cards.create!(title: "Duplicate results test", description: "Have you had any haggis today?", creator: user) + card = @board.cards.create!(title: "Duplicate results test", description: "Have you had any haggis today?", creator: @user) card.published! - card.comments.create(body: "I hate haggis.", creator: user) - card.comments.create(body: "I love haggis.", creator: user) + card.comments.create(body: "I hate haggis.", creator: @user) + card.comments.create(body: "I love haggis.", creator: @user) - filter = user.filters.new(terms: [ "haggis" ], indexed_by: "all", sorted_by: "latest") + filter = @user.filters.new(terms: [ "haggis" ], indexed_by: "all", sorted_by: "latest") assert_equal [ card ], filter.cards.to_a end