FIX: Look up all channel hashtags (#25617)
This commit is contained in:
parent
6311a80724
commit
a2a2785f0b
|
@ -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 = {})
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue