FIX: Look up all channel hashtags (#25617)

This commit is contained in:
Bianca Nenciu 2024-02-09 19:59:38 +02:00 committed by GitHub
parent 6311a80724
commit a2a2785f0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -80,7 +80,6 @@ module Chat
.where(chatable_type: Chat::Channel.public_channel_chatable_types) .where(chatable_type: Chat::Channel.public_channel_chatable_types)
.where("chat_channels.id IN (#{allowed_channel_ids})") .where("chat_channels.id IN (#{allowed_channel_ids})")
.where("chat_channels.slug IN (:slugs)", slugs: slugs) .where("chat_channels.slug IN (:slugs)", slugs: slugs)
.limit(1)
end end
def self.secured_public_channel_search(guardian, options = {}) def self.secured_public_channel_search(guardian, options = {})

View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
RSpec.describe HashtagAutocompleteService do
subject(:service) { described_class.new(guardian) }
fab!(:channel1) { Fabricate(:chat_channel, name: "Music Lounge", slug: "music") }
fab!(:channel2) { Fabricate(:chat_channel, name: "Random", slug: "random") }
fab!(:admin)
let(:guardian) { Guardian.new(admin) }
describe ".enabled_data_sources" do
it "only returns data sources that are enabled" do
expect(HashtagAutocompleteService.enabled_data_sources).to include(
Chat::ChannelHashtagDataSource,
)
end
end
describe "#lookup" do
it "returns hashtags for channels" do
result = service.lookup(%w[music::channel random::channel], ["channel"])
expect(result[:channel].map(&:slug)).to contain_exactly("music", "random")
end
end
end