Fix search tests

This commit is contained in:
Jose Farias
2024-10-27 12:33:33 -06:00
parent 993870c10c
commit ede04d6d96
2 changed files with 9 additions and 5 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ module Bubble::Searchable
scope :mentioning, ->(query) do
if query = query.presence
bubbles = search(query).select(:id).to_sql
comments = Comment.search(query).select(:bubble_id).to_sql
left_joins(:comments).where("bubbles.id in (#{bubbles}) or comments.bubble_id in (#{comments})").distinct
comments = Comment.search(query).select(:id).to_sql
left_joins(:messages).where("bubbles.id in (#{bubbles}) or messages.messageable_id in (#{comments})").distinct
end
end
end
+7 -3
View File
@@ -1,9 +1,13 @@
require "test_helper"
class CommentTest < ActiveSupport::TestCase
test "searchable by body" do
comment = bubbles(:logo).comments.create! body: "I'd prefer something more rustic", creator: users(:kevin)
setup do
Current.session = sessions(:david)
end
assert_includes Comment.search("something rustic"), comment
test "searchable by body" do
message = bubbles(:logo).comment "I'd prefer something more rustic"
assert_includes Comment.search("something rustic"), message.comment
end
end