FIX: mixed case group mentions were not getting highligted in composer

This commit is contained in:
Arpit Jalan 2016-05-22 18:31:46 +05:30
parent 8f8ad3fe4a
commit f387dfe226
2 changed files with 9 additions and 1 deletions

View File

@ -211,7 +211,6 @@ class UsersController < ApplicationController
def is_local_username
usernames = params[:usernames]
usernames = [params[:username]] if usernames.blank?
usernames.each(&:downcase!)
groups = Group.where(name: usernames).pluck(:name)
mentionable_groups =
@ -223,6 +222,7 @@ class UsersController < ApplicationController
end
usernames -= groups
usernames.each(&:downcase!)
result = User.where(staged: false)
.where(username_lower: usernames)

View File

@ -1516,6 +1516,7 @@ describe UsersController do
describe ".is_local_username" do
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group, name: "Discourse") }
it "finds the user" do
xhr :get, :is_local_username, username: user.username
@ -1524,6 +1525,13 @@ describe UsersController do
expect(json["valid"][0]).to eq(user.username)
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
xhr :get, :is_local_username, usernames: [user.username, "system"]
expect(response).to be_success