A platform for community discussion. Free, open, simple.
DEV: Chat hashtag test (#25638)
Martin Brennand80345fa83a6
diff --git a/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb b/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rbindex 957f44996bd..a7058658d5b 100644--- a/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb+++ b/plugins/chat/spec/lib/chat/channel_hashtag_data_source_spec.rb@@ -24,6 +24,16 @@ RSpec.describe Chat::ChannelHashtagDataSource domessages_count: 78,)end+ fab!(:channel3) do+ Fabricate(+ :chat_channel,+ slug: "music",+ name: "Tunes",+ chatable: category,+ description: "A place for music lovers",+ messages_count: 437,+ )+ endlet!(:guardian) { Guardian.new(user) }before { SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:trust_level_1] }@@ -86,6 +96,31 @@ RSpec.describe Chat::ChannelHashtagDataSource doSiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:staff]expect(described_class.lookup(Guardian.new(user), ["random"])).to be_emptyend++ 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",+ },+ )+ endenddescribe "#search" dodiff --git a/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb b/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rbindex da3075b304e..fa80c4d32ac 100644--- a/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb+++ b/plugins/chat/spec/services/hashtag_autocomplete_service_spec.rb@@ -3,11 +3,7 @@RSpec.describe HashtagAutocompleteService dosubject(: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" doit "only returns data sources that are enabled" do@@ -16,11 +12,4 @@ RSpec.describe HashtagAutocompleteService do)endend-- 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- endend