FIX: do not filter on category name (#22442)

This commit is contained in:
Joffrey JAFFEUX 2023-07-05 21:12:39 +02:00 committed by GitHub
parent cfdf5b9518
commit 2ce9364c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -45,7 +45,7 @@ module Chat
end
def fetch_memberships(guardian:, **)
context.memberships = Chat::ChannelMembershipManager.all_for_user(guardian.user)
context.memberships = ::Chat::ChannelMembershipManager.all_for_user(guardian.user)
end
def fetch_users(guardian:, **)
@ -58,8 +58,10 @@ module Chat
return if context.mode == :user
context.category_channels =
Chat::ChannelFetcher.secured_public_channels(
::Chat::ChannelFetcher.secured_public_channel_search(
guardian,
filter_on_category_name: false,
match_filter_on_starts_with: false,
filter: context.term,
status: :open,
limit: 10,
@ -76,7 +78,7 @@ module Chat
end
channels =
Chat::ChannelFetcher.secured_direct_message_channels_search(
::Chat::ChannelFetcher.secured_direct_message_channels_search(
guardian.user.id,
guardian,
limit: 10,
@ -97,7 +99,7 @@ module Chat
end
def search_users(term, guardian)
user_search = UserSearch.new(term, limit: 10)
user_search = ::UserSearch.new(term, limit: 10)
if term.blank?
user_search.scoped_users.includes(:user_option)

View File

@ -235,6 +235,22 @@ RSpec.describe "New message", type: :system do
before { channel_1.add(current_user) }
context "when query is the name of the category" do
fab!(:category) { Fabricate(:category, name: "dev") }
fab!(:channel_1) { Fabricate(:category_channel, chatable: category, name: "something dev") }
fab!(:channel_2) { Fabricate(:category_channel, chatable: category, name: "something else") }
it "favors the channel name" do
visit("/")
chat_page.open_new_message
chat_page.message_creator.filter("dev")
expect(chat_page.message_creator).to be_listing(channel_1)
expect(chat_page.message_creator).to be_not_listing(channel_2)
end
end
context "with no prefix" do
it "lists all matching content" do
visit("/")