Commit cba6fd2d by Pablo Cantero

Make mstart case insensitive

parent d968efe9
......@@ -33,7 +33,7 @@ module RansackMongo
def mstart_matcher(attr, value)
values = value.split(",").map do |current|
if (current = current.strip).length > 0
/^#{current}/
/^#{current}/i
end
end.compact
......
......@@ -46,19 +46,19 @@ module RansackMongo
it 'returns the matcher' do
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
it 'cleans up the input' do
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
it 'accepts single values' do
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
......
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