Add case insensitive branches search

This commit is contained in:
George Andrinopoulos 2017-10-22 17:50:58 +03:00
parent cc8af554fd
commit 1cf35c3d1d
3 changed files with 15 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class BranchesFinder
def filter_by_name(branches)
if search
branches.select { |branch| branch.name.include?(search) }
branches.select { |branch| branch.name.upcase.include?(search.upcase) }
else
branches
end

View File

@ -0,0 +1,5 @@
---
title: Case insensitive search for branches
merge_request: 14995
author: George Andrinopoulos
type: fixed

View File

@ -46,6 +46,15 @@ describe BranchesFinder do
expect(result.count).to eq(1)
end
it 'filters branches by name ignoring letter case' do
branches_finder = described_class.new(repository, { search: 'FiX' })
result = branches_finder.execute
expect(result.first.name).to eq('fix')
expect(result.count).to eq(1)
end
it 'does not find any branch with that name' do
branches_finder = described_class.new(repository, { search: 'random' })