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.
This commit is contained in:
committed by
GitHub
parent
641e67dc2e
commit
12928f530b
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user