DEV: Chat hashtag test (#25638)
Followup a2a2785f0b
, moving
stuff to an existing test.
This commit is contained in:
parent
cf4d92f686
commit
d80345fa83
|
@ -24,6 +24,16 @@ RSpec.describe Chat::ChannelHashtagDataSource do
|
|||
messages_count: 78,
|
||||
)
|
||||
end
|
||||
fab!(:channel3) do
|
||||
Fabricate(
|
||||
:chat_channel,
|
||||
slug: "music",
|
||||
name: "Tunes",
|
||||
chatable: category,
|
||||
description: "A place for music lovers",
|
||||
messages_count: 437,
|
||||
)
|
||||
end
|
||||
let!(:guardian) { Guardian.new(user) }
|
||||
|
||||
before { SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:trust_level_1] }
|
||||
|
@ -86,6 +96,31 @@ RSpec.describe Chat::ChannelHashtagDataSource do
|
|||
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:staff]
|
||||
expect(described_class.lookup(Guardian.new(user), ["random"])).to be_empty
|
||||
end
|
||||
|
||||
it "can return multiple channels" do
|
||||
expect(described_class.lookup(guardian, %w[music random]).map(&:to_h)).to contain_exactly(
|
||||
{
|
||||
description: "Just weird stuff",
|
||||
icon: "comment",
|
||||
id: channel1.id,
|
||||
ref: nil,
|
||||
relative_url: channel1.relative_url,
|
||||
slug: "random",
|
||||
text: "Zany Things",
|
||||
type: "channel",
|
||||
},
|
||||
{
|
||||
description: "A place for music lovers",
|
||||
icon: "comment",
|
||||
id: channel3.id,
|
||||
ref: nil,
|
||||
relative_url: channel3.relative_url,
|
||||
slug: "music",
|
||||
text: "Tunes",
|
||||
type: "channel",
|
||||
},
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#search" do
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
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) }
|
||||
before { SiteSetting.chat_enabled = true }
|
||||
|
||||
describe ".enabled_data_sources" do
|
||||
it "only returns data sources that are enabled" do
|
||||
|
@ -16,11 +12,4 @@ RSpec.describe HashtagAutocompleteService do
|
|||
)
|
||||
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