active_record_filterable 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f3fd07975c6a48200e596542644ddad458e3ff3293bee739151f4d25eae5231
4
- data.tar.gz: c9415f4f77e93081d2189f9891709d3a009e98fc01c613ca6c059363f5f581b4
3
+ metadata.gz: 629ee506d50151bbc9513fbfbdac243a5d976056cd5eab2da800ddb3ac46f015
4
+ data.tar.gz: 313ef4b6f506ee73d6ba3a7d3952095de754cb2c9e2ed9d3a67752fa4edcb4fb
5
5
  SHA512:
6
- metadata.gz: 13c55dec18594a7ec978776e58ad25c0613e29d1258f68fd209ebcc2687fe46ff2981b240d29e2544db6819ad02dc85a5fc8c43324c6d3ffa29fd43ee19725d9
7
- data.tar.gz: 42a9dc6a30c48bb94473ab9f9685944e0bbc65367806a7b5bdd97a703bb4536c3d873147f31308bc0e5d51301cfe8272812a1495098c8686ba49b77ae846d6c8
6
+ metadata.gz: 307c77ae2ce3677ea92f7aa5b674c16ac7d6bc7e97a2ed02f77c1c615cbe805967b34f4642b8c67cc34e0a4113645225bb7596763531feedad90d56d79a761a8
7
+ data.tar.gz: d815a6685ac11c677a480d313079b95ff390e89324a4a51b6430e1b02b1d39c8eb78fa771e5287380b39d01ad7fa008dd410f0d49f239df855a6bd8a3fe1e48f
data/.travis.yml CHANGED
@@ -23,3 +23,7 @@ script: bundle exec rspec
23
23
 
24
24
  gemfile:
25
25
  - Gemfile
26
+
27
+ services:
28
+ - mysql
29
+ - postgresql
data/README.md CHANGED
@@ -41,6 +41,7 @@ City.filtrate({name: 'city'}).count # => 2
41
41
  City.filtrate({name: 'city1'}).count # => 1
42
42
  City.filtrate({name: ''}).count # => 0
43
43
  City.filtrate({people: 500}) # => 1
44
+ City.filtrate({invalid: 'x'}) # => 2 (is ignored)
44
45
  ```
45
46
 
46
47
  #### Operator
@@ -37,7 +37,7 @@ module ActiveRecord
37
37
  end
38
38
  end
39
39
 
40
- criteria == self ? none : merge(criteria)
40
+ merge(criteria)
41
41
  end
42
42
 
43
43
  def scope(name, scope_options, &block)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Filterable
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -35,7 +35,19 @@ RSpec.describe ActiveRecord::Filterable do
35
35
  end
36
36
 
37
37
  it 'doesn\'t find anything with partial match' do
38
- expect(City.filtrate(name: :city).count).to eq(0)
38
+ expect(City.filtrate(code: :code).count).to eq(0)
39
+ end
40
+ end
41
+
42
+ context 'when filter is invalid' do
43
+ before do
44
+ City.create(code: :code1)
45
+ City.create(code: :code2)
46
+ end
47
+
48
+ it 'ignore filter' do
49
+ expect(City.filtrate(code: :code1, invalid: 'xxx').count).to eq(1)
50
+ expect(City.filtrate(invalid: 'xxx').count).to eq(2)
39
51
  end
40
52
  end
41
53
 
@@ -123,7 +135,7 @@ RSpec.describe ActiveRecord::Filterable do
123
135
  end
124
136
  end
125
137
 
126
- context 'when partial matching is used' do
138
+ context 'when normalize matching is used' do
127
139
  before do
128
140
  City.create(name: 'spaIn')
129
141
  City.create(name: 'frAnce')
@@ -145,7 +157,7 @@ RSpec.describe ActiveRecord::Filterable do
145
157
  end
146
158
  end
147
159
 
148
- context 'when filter is applied on a scope' do
160
+ context 'when is applied in query' do
149
161
  before do
150
162
  City.create(name: '2', people: 100)
151
163
  City.create(name: '1', people: 500)
@@ -155,19 +167,14 @@ RSpec.describe ActiveRecord::Filterable do
155
167
 
156
168
  it 'is maintained' do
157
169
  expect(City.where(name: '2').filtrate(nil).count).to eq(1)
158
- end
159
- end
160
-
161
- context 'when is applied in query' do
162
- before do
163
- City.create(name: 'city1', people: 100)
164
- City.create(name: 'city2', people: 1000)
165
- City.create(name: 'city3', people: 2000)
170
+ expect(City.where(name: '2').filtrate(nil).first.name).to eq('2')
171
+ expect(City.where(name: '1').filtrate(people: 900).count).to eq(2)
166
172
  end
167
173
 
168
- it 'respects previous selector' do
169
- expect(City.where(name: 'city2').filtrate(people: '500').count).to eq(1)
170
- expect(City.where(name: 'city2').filtrate(people: '500').first.name).to eq('city2')
174
+ context 'when filter is invalid' do
175
+ it 'ignore filter' do
176
+ expect(City.where(name: '1').filtrate(invalid: 900).count).to eq(3)
177
+ end
171
178
  end
172
179
  end
173
180
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_filterable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Padillo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-12 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -133,7 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.0.1
136
+ rubyforge_project:
137
+ rubygems_version: 2.7.3
137
138
  signing_key:
138
139
  specification_version: 4
139
140
  summary: Easy way to add scopes to your models.