Make sure that comments show up in search properly
when the search term appears in both the comment and the card description
This commit is contained in:
@@ -1,25 +1,21 @@
|
||||
<li>
|
||||
<%= link_to result.source, class: "search__result", data: { turbo_frame: "_top", action: "bar#reset" } do %>
|
||||
<div>
|
||||
<h3 class="search__title txt--medium margin-none">
|
||||
# <%= result.card.number %> <%= result.card_title %>
|
||||
</h3>
|
||||
<div>
|
||||
<h3 class="search__title txt--medium margin-none">
|
||||
# <%= result.card.number %> <%= result.card_title %>
|
||||
</h3>
|
||||
|
||||
<% if result.card_description.present? %>
|
||||
<div class="search__excerpt">
|
||||
<%= result.card_description %>
|
||||
</div>
|
||||
<% else
|
||||
if result.comment_body.present? %>
|
||||
<div class="search__excerpt search__excerpt--comment">
|
||||
<%= avatar_preview_tag result.card.creator %>
|
||||
<div>
|
||||
<%= result.comment_body %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="overflow-ellipsis translucent txt-ink"><%= result.card.board.name %></div>
|
||||
<% if result.comment.present? %>
|
||||
<div class="search__excerpt search__excerpt--comment">
|
||||
<%= avatar_preview_tag result.card.creator %>
|
||||
<div><%= result.comment_body %></div>
|
||||
</div>
|
||||
<% elsif result.card_id.present? %>
|
||||
<div class="search__excerpt"><%= result.card_description %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="overflow-ellipsis translucent txt-ink">
|
||||
<%= result.card.board.name %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -5,9 +5,11 @@ class SearchesControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
setup do
|
||||
@board.update!(all_access: true)
|
||||
@card = @board.cards.create!(title: "Layout is broken", creator: @user)
|
||||
@card = @board.cards.create!(title: "Layout is broken", description: "Look at this mess.", creator: @user)
|
||||
@comment_card = @board.cards.create!(title: "Some card", creator: @user)
|
||||
@comment_card.comments.create!(body: "overflowing text issue", creator: @user)
|
||||
@comment2_card = @board.cards.create!(title: "Just haggis", description: "More haggis", creator: @user)
|
||||
@comment2_card.comments.create!(body: "I love haggis", creator: @user)
|
||||
|
||||
untenanted { sign_in_as @user }
|
||||
end
|
||||
@@ -15,11 +17,19 @@ class SearchesControllerTest < ActionDispatch::IntegrationTest
|
||||
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/
|
||||
assert_select "li .search__title", text: /Layout is broken/
|
||||
assert_select "li .search__excerpt", text: /Look at this mess/
|
||||
|
||||
# Searching by comment
|
||||
get search_path(q: "overflowing", script_name: "/#{@account.external_account_id}")
|
||||
assert_select "li", text: /Some card/
|
||||
assert_select "li .search__title", text: /Some card/
|
||||
assert_select "li .search__excerpt--comment", text: /overflowing text issue/
|
||||
|
||||
# Searching for a term that appears in a card and in a comment
|
||||
get search_path(q: "haggis", script_name: "/#{@account.external_account_id}")
|
||||
assert_select "li .search__title", text: /Just haggis/, count: 2 # card title shows up in two entries
|
||||
assert_select "li .search__excerpt", text: /More haggis/ # one entry for the card description
|
||||
assert_select "li .search__excerpt--comment", text: /I love haggis/ # one entry for the comment
|
||||
|
||||
# Searching by card id
|
||||
get search_path(q: @card.id, script_name: "/#{@account.external_account_id}")
|
||||
|
||||
Reference in New Issue
Block a user