Skip to content

A platform for community discussion. Free, open, simple.

FIX: Look up all channel hashtags (#25617)

Bianca Nenciua2a2785f0b85
diff --git a/plugins/chat/lib/chat/channel_fetcher.rb b/plugins/chat/lib/chat/channel_fetcher.rb
index 9daaf6908f1..6680aed3f9f 100644
--- a/plugins/chat/lib/chat/channel_fetcher.rb
+++ b/plugins/chat/lib/chat/channel_fetcher.rb
@@ -80,7 +80,6 @@ module Chat
.where(chatable_type: Chat::Channel.public_channel_chatable_types)
.where("chat_channels.id IN (#{allowed_channel_ids})")
.where("chat_channels.slug IN (:slugs)", slugs: slugs)
- .limit(1)
end
def self.secured_public_channel_search(guardian, options = {})
diff --git a/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb b/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb
new file mode 100644
index 00000000000..da3075b304e
--- /dev/null
+++ b/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb
@@ -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