Fix search tests
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user