Commit cba6fd2d by Pablo Cantero

Make mstart case insensitive

parent d968efe9
...@@ -33,7 +33,7 @@ module RansackMongo ...@@ -33,7 +33,7 @@ module RansackMongo
def mstart_matcher(attr, value) def mstart_matcher(attr, value)
values = value.split(",").map do |current| values = value.split(",").map do |current|
if (current = current.strip).length > 0 if (current = current.strip).length > 0
/^#{current}/ /^#{current}/i
end end
end.compact end.compact
......
...@@ -46,19 +46,19 @@ module RansackMongo ...@@ -46,19 +46,19 @@ module RansackMongo
it 'returns the matcher' do it 'returns the matcher' do
subject.mstart_matcher('name', 'Pablo, Bruno,Dude') subject.mstart_matcher('name', 'Pablo, Bruno,Dude')
expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/, /^Bruno/, /^Dude/] }) expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/i, /^Bruno/i, /^Dude/i] })
end end
it 'cleans up the input' do it 'cleans up the input' do
subject.mstart_matcher('name', ',, , ,Pablo,,,, ,, , , ,') subject.mstart_matcher('name', ',, , ,Pablo,,,, ,, , , ,')
expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/] }) expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/i] })
end end
it 'accepts single values' do it 'accepts single values' do
subject.mstart_matcher('name', 'Pablo') subject.mstart_matcher('name', 'Pablo')
expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/] }) expect(subject.to_query).to eq("name" => { "$in" => [/^Pablo/i] })
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment