From f387dfe2263ef198701d8876977881ce99fe385c Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sun, 22 May 2016 18:31:46 +0530 Subject: [PATCH] FIX: mixed case group mentions were not getting highligted in composer --- app/controllers/users_controller.rb | 2 +- spec/controllers/users_controller_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 719dcf37aa2..af4708fb7ef 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 43887f1ea57..9edaa64734f 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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