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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee668ea1b497adc91c147956f1f390abf02038e6b9968dff39345c1c3901c0be
4
- data.tar.gz: 0f94be3a0505256cb8bd205c281ed5a2beb239262c05528efd71876aa5516360
3
+ metadata.gz: e725b5df6b63eb4d44d79274df5a6e73ccbb2cc08846d07b875a904fab545ac7
4
+ data.tar.gz: 6f7f5b1bc693af8de774b66c95de58f60f11dd837382b7efd49ffd525095e427
5
5
  SHA512:
6
- metadata.gz: 265830fc7d04d50f90e2d19907baeeb7e6fc324e297f3b21108022ac6606d0881b6a967566db18f133e80090b0d6b7eb1b40198847a5dff631a931ac9d8477a8
7
- data.tar.gz: a4fc72a06601a609655d67ff7276fd8e7ccf11f1ccc533641445681fab98f8baa900986db840a61d5928c365c955326b4bfb08e18aceee453256b636ac94131d
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
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Filterable
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -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
- it 'should filter by normalized filter' do
62
- City.create(country_normalized: 'spain')
63
- City.create(country_normalized: 'france')
64
- expect(City.filtrate(country: 'spain').count).to eq(1)
65
- expect(City.filtrate(country: 'spain').first.country_normalized).to eq('spain')
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.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-04-09 00:00:00.000000000 Z
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
- rubygems_version: 3.0.1
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.