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 +4 -4
- data/.travis.yml +4 -0
- data/README.md +1 -0
- data/lib/active_record_filterable/filterable.rb +1 -1
- data/lib/active_record_filterable/version.rb +1 -1
- data/spec/filterable_spec.rb +21 -14
- 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: 629ee506d50151bbc9513fbfbdac243a5d976056cd5eab2da800ddb3ac46f015
|
4
|
+
data.tar.gz: 313ef4b6f506ee73d6ba3a7d3952095de754cb2c9e2ed9d3a67752fa4edcb4fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 307c77ae2ce3677ea92f7aa5b674c16ac7d6bc7e97a2ed02f77c1c615cbe805967b34f4642b8c67cc34e0a4113645225bb7596763531feedad90d56d79a761a8
|
7
|
+
data.tar.gz: d815a6685ac11c677a480d313079b95ff390e89324a4a51b6430e1b02b1d39c8eb78fa771e5287380b39d01ad7fa008dd410f0d49f239df855a6bd8a3fe1e48f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/spec/filterable_spec.rb
CHANGED
@@ -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(
|
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
|
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
|
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
|
-
|
159
|
-
|
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
|
-
|
169
|
-
|
170
|
-
|
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.
|
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-
|
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
|
-
|
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.
|