From 7d82a53dfed3daa563f5262aaf3538aa49196993 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 6 Mar 2017 17:24:03 +0800 Subject: [PATCH] FIX: `Group#name` is case insensitive. --- app/models/group.rb | 2 +- spec/models/group_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index 8e457c72de7..2aea0ab9dcf 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -180,7 +180,7 @@ class Group < ActiveRecord::Base validator = UsernameValidator.new(localized_name) group.name = - if !Group.where(name: localized_name).exists? && validator.valid_format? + if !Group.where("lower(name) = ?", localized_name).exists? && validator.valid_format? localized_name else name diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index e3475bd1620..c70426e04c9 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -182,7 +182,7 @@ describe Group do I18n.locale = SiteSetting.default_locale = 'de' another_group = Fabricate(:group, - name: I18n.t('groups.default_names.staff') + name: I18n.t('groups.default_names.staff').upcase ) group = Group.refresh_automatic_group!(:staff)