mongoid-filterable 0.4.0 → 0.4.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: e6168dc7e61425d57051a385ad08c7061e0690b68895a1a06791dbbe5ba6e3f0
4
- data.tar.gz: 51b6a89e1f0454f62d4b502d920b0e7b76d03d5f61d2fbb7ea613b9d09772968
3
+ metadata.gz: 71010c85b650681652bd079d24a156341bee7f1f9594d03fe3fd6d1636ab9083
4
+ data.tar.gz: 91a7a5441612055ea19400f403d94d934117b39a7d71a110684d2f9d502f1bc8
5
5
  SHA512:
6
- metadata.gz: 9e1d37765dd64fa1c3322045a5632a757ad217e7c243524696f026d70db8cc988d4f9825fd54e146dfba6b14d7534c80204e4c82abe27fe4a129f7edd17d94fe
7
- data.tar.gz: a6167fb4ecbd8b2e6342ba87ab703388a231b7dff891e26cbef84f2a22bc6c7e9b78683838b2b3e7987c8264f7014c409fbda03dcee4732668e69570a5b61662
6
+ metadata.gz: 0fe5207b06afd57c1681131cfb6acd99a87b8acdf66ffb97812f6f81e00dc34a5af512fdb6fc8c1246966ebe5d6ea3a3cafe8180b5fe78a64e6aba21dcbc94ee
7
+ data.tar.gz: cbb78b9092a458ca27e75b4ffbc44a29ca0b38fea927a6c6f53c8ce2c04255aa2029efe129535bea351670440f0d3f7e9c83db6904e9fa98ce809c77df9cebc5
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Mongoid::Filterable
2
+ ![Build Status](https://travis-ci.org/nosolosoftware/mongoid-filterable.svg?branch=master)
2
3
 
3
4
  Let you add scopes to mongoid document for filters.
4
5
 
@@ -14,7 +14,8 @@ module Mongoid
14
14
  criteria = unscoped
15
15
 
16
16
  filtering_params.each do |key, value|
17
- if !value.nil? && respond_to?("filter_with_#{key}")
17
+ # false is permitted in order to work properly with boolean fields
18
+ if (value.present? || value == false) && respond_to?("filter_with_#{key}")
18
19
  if value.is_a?(Array) && scopes["filter_with_#{key}".to_sym][:scope].arity > 1
19
20
  selectors.push criteria.public_send("filter_with_#{key}", *value).selector
20
21
  else
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Filterable
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mongoid-filterable/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "mongoid-filterable"
7
+ spec.name = 'mongoid-filterable'
8
8
  spec.version = Mongoid::Filterable::VERSION
9
- spec.authors = ["Rafael Jurado"]
10
- spec.email = ["rjurado@nosolosoftware.biz"]
11
- spec.summary = %q{Easy way to add scopes to your models.}
12
- spec.description = %q{Easy way to add scopes to your models.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
9
+ spec.authors = ['Rafael Jurado']
10
+ spec.email = ['rjurado@nosolosoftware.biz']
11
+ spec.summary = 'Easy way to add scopes to your models.'
12
+ spec.description = 'Easy way to add scopes to your models.'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
22
  spec.add_development_dependency 'rspec'
23
- spec.add_dependency 'mongoid'
24
- spec.add_dependency "i18n"
23
+ spec.add_dependency 'i18n'
24
+ spec.add_dependency 'mongoid', ['>= 3.0', '< 8.0']
25
25
  end
@@ -124,6 +124,22 @@ describe Mongoid::Filterable do
124
124
  end
125
125
  end
126
126
 
127
+ context 'when value is nil' do
128
+ it 'should ignore filter' do
129
+ City.create(people: 100)
130
+ City.create(people: 500)
131
+ expect(City.filter(people: nil).count).to eq(2)
132
+ end
133
+ end
134
+
135
+ context 'when value is empty string' do
136
+ it 'should ignore filter' do
137
+ City.create(people: 100)
138
+ City.create(people: 500)
139
+ expect(City.filter(people: '').count).to eq(2)
140
+ end
141
+ end
142
+
127
143
  context 'when value is a Boolean' do
128
144
  it 'should filter using a query' do
129
145
  City.create(name: 'city1')
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: 0.4.0
4
+ version: 0.4.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: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: mongoid
42
+ name: i18n
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,19 +53,25 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: i18n
56
+ name: mongoid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '8.0'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: '0'
71
+ version: '3.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '8.0'
69
75
  description: Easy way to add scopes to your models.
70
76
  email:
71
77
  - rjurado@nosolosoftware.biz