FIX: Don't downcase group name.
This commit is contained in:
parent
aa0d32231c
commit
ad833c4485
|
@ -598,12 +598,13 @@ class Group < ActiveRecord::Base
|
|||
|
||||
def name_format_validator
|
||||
self.name.strip!
|
||||
self.name.downcase!
|
||||
|
||||
UsernameValidator.perform_validation(self, 'name') || begin
|
||||
if will_save_change_to_name? && name_was&.downcase != self.name
|
||||
name_lower = self.name.downcase
|
||||
|
||||
if self.will_save_change_to_name? && self.name_was&.downcase != name_lower
|
||||
existing = Group.exec_sql(
|
||||
User::USERNAME_EXISTS_SQL, username: self.name
|
||||
User::USERNAME_EXISTS_SQL, username: name_lower
|
||||
).values.present?
|
||||
|
||||
if existing
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Group do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#username' do
|
||||
describe '#name' do
|
||||
context 'when a user with a similar name exists' do
|
||||
it 'should not be valid' do
|
||||
new_group = Fabricate.build(:group, name: admin.username.upcase)
|
||||
|
|
Loading…
Reference in New Issue