mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: mixed case group mentions were not getting highligted in composer
This commit is contained in:
parent
8f8ad3fe4a
commit
f387dfe226
2 changed files with 9 additions and 1 deletions
|
@ -211,7 +211,6 @@ class UsersController < ApplicationController
|
||||||
def is_local_username
|
def is_local_username
|
||||||
usernames = params[:usernames]
|
usernames = params[:usernames]
|
||||||
usernames = [params[:username]] if usernames.blank?
|
usernames = [params[:username]] if usernames.blank?
|
||||||
usernames.each(&:downcase!)
|
|
||||||
|
|
||||||
groups = Group.where(name: usernames).pluck(:name)
|
groups = Group.where(name: usernames).pluck(:name)
|
||||||
mentionable_groups =
|
mentionable_groups =
|
||||||
|
@ -223,6 +222,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
usernames -= groups
|
usernames -= groups
|
||||||
|
usernames.each(&:downcase!)
|
||||||
|
|
||||||
result = User.where(staged: false)
|
result = User.where(staged: false)
|
||||||
.where(username_lower: usernames)
|
.where(username_lower: usernames)
|
||||||
|
|
|
@ -1516,6 +1516,7 @@ describe UsersController do
|
||||||
describe ".is_local_username" do
|
describe ".is_local_username" do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:group) { Fabricate(:group, name: "Discourse") }
|
||||||
|
|
||||||
it "finds the user" do
|
it "finds the user" do
|
||||||
xhr :get, :is_local_username, username: user.username
|
xhr :get, :is_local_username, username: user.username
|
||||||
|
@ -1524,6 +1525,13 @@ describe UsersController do
|
||||||
expect(json["valid"][0]).to eq(user.username)
|
expect(json["valid"][0]).to eq(user.username)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "finds the group" do
|
||||||
|
xhr :get, :is_local_username, username: group.name
|
||||||
|
expect(response).to be_success
|
||||||
|
json = JSON.parse(response.body)
|
||||||
|
expect(json["valid_groups"][0]).to eq(group.name)
|
||||||
|
end
|
||||||
|
|
||||||
it "supports multiples usernames" do
|
it "supports multiples usernames" do
|
||||||
xhr :get, :is_local_username, usernames: [user.username, "system"]
|
xhr :get, :is_local_username, usernames: [user.username, "system"]
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue