mongoid-filterable 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid-filterable/filterable.rb +1 -1
- data/lib/mongoid-filterable/version.rb +1 -1
- data/spec/filterable_spec.rb +12 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e725b5df6b63eb4d44d79274df5a6e73ccbb2cc08846d07b875a904fab545ac7
|
4
|
+
data.tar.gz: 6f7f5b1bc693af8de774b66c95de58f60f11dd837382b7efd49ffd525095e427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23d3e2bb35a38d799ceb299435dbfaaa5ab42484434855aedb9a413196e3fae5ef89da18b6dc5498bb55953d401e192a02bc2f1e53959c79d11a864503aad389
|
7
|
+
data.tar.gz: eed2b359ffad18cca89a6b6a8ca8fe40706f96b6431a2df3e3fa1d3428a9d88f83f69ed14eff1858d3a77afd295dc088d1ed76a695f38a5e9d8ed87a9a019d92
|
@@ -47,7 +47,7 @@ module Mongoid
|
|
47
47
|
def filter_by_normalized(attr)
|
48
48
|
normalized_name = (attr.to_s + '_normalized').to_sym
|
49
49
|
scope "filter_with_#{attr}", lambda { |value|
|
50
|
-
where(normalized_name => Regexp.new(I18n.transliterate(value), 'i'))
|
50
|
+
where(normalized_name => Regexp.new(Regexp.escape(I18n.transliterate(value)), 'i'))
|
51
51
|
}
|
52
52
|
end
|
53
53
|
end
|
data/spec/filterable_spec.rb
CHANGED
@@ -58,11 +58,18 @@ describe Mongoid::Filterable do
|
|
58
58
|
expect(City.filtrate(people: 500).first.people).to eq(1000)
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
context 'when using a normalized filter' do
|
62
|
+
it 'should filter' do
|
63
|
+
City.create(country_normalized: 'spain')
|
64
|
+
City.create(country_normalized: 'france')
|
65
|
+
expect(City.filtrate(country: 'spain').count).to eq(1)
|
66
|
+
expect(City.filtrate(country: 'spain').first.country_normalized).to eq('spain')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should admit special regexp chars' do
|
70
|
+
expect { City.filtrate(country: 'spain (') }.to_not raise_error
|
71
|
+
expect { City.filtrate(country: 'spain [') }.to_not raise_error
|
72
|
+
end
|
66
73
|
end
|
67
74
|
|
68
75
|
it 'should respect previous selector' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-filterable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Jurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,7 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.7.3
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: Easy way to add scopes to your models.
|