FIX: `Group.search` should look up `Group#full_name` too.
https://meta.discourse.org/t/mentioning-group-by-full-name-doesnt-work/63437/3
This commit is contained in:
parent
7b35c55a1e
commit
5e156fbe85
|
@ -282,7 +282,9 @@ class Group < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.search_group(name)
|
||||
Group.where(visible: true).where("name ILIKE :term_like", term_like: "#{name}%")
|
||||
Group.where(visible: true).where(
|
||||
"name ILIKE :term_like OR full_name ILIKE :term_like", term_like: "#{name}%"
|
||||
)
|
||||
end
|
||||
|
||||
def self.lookup_group(name)
|
||||
|
|
|
@ -487,4 +487,18 @@ describe Group do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.search_group' do
|
||||
let(:group) { Fabricate(:group, name: 'tEsT', full_name: 'eSTt') }
|
||||
|
||||
it 'should return the right groups' do
|
||||
group
|
||||
|
||||
expect(Group.search_group('te')).to eq([group])
|
||||
expect(Group.search_group('TE')).to eq([group])
|
||||
expect(Group.search_group('es')).to eq([group])
|
||||
expect(Group.search_group('ES')).to eq([group])
|
||||
expect(Group.search_group('test2')).to eq([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue