Files
fizzy/test/controllers/searches_controller_test.rb
T
Donal McBreen 28efe28f24 Replace Search::Index with Search::Records
Lean on ActiveRecord models for searching and strip out the raw SQL.
Replaces the search_index_* tables with sharded search_records_* tables
as that allows us to use a Search::Record model name.

A Class is dynamically created for each record table shard so that we
and we can access it via the Search::Record.for_account(account_id)
method.
2025-11-17 09:12:40 -05:00

34 lines
1.2 KiB
Ruby

require "test_helper"
class SearchesControllerTest < ActionDispatch::IntegrationTest
include SearchTestHelper
setup do
@board.update!(all_access: true)
@card = @board.cards.create!(title: "Layout is broken", creator: @user)
@comment_card = @board.cards.create!(title: "Some card", creator: @user)
@comment_card.comments.create!(body: "overflowing text issue", creator: @user)
untenanted { sign_in_as @user }
end
test "search" do
# Searching by card title
get search_path(q: "broken", script_name: "/#{@account.external_account_id}")
assert_select "li", text: /Layout is broken/
# Searching by comment
get search_path(q: "overflowing", script_name: "/#{@account.external_account_id}")
assert_select "li", text: /Some card/
# Searching by card id
get search_path(q: @card.id, script_name: "/#{@account.external_account_id}")
assert_select "form[data-controller='auto-submit']"
# Searching with non-existent card id
get search_path(q: "999999", script_name: "/#{@account.external_account_id}")
assert_select "form[data-controller='auto-submit']", count: 0
assert_select ".search__empty", text: "No matches"
end
end