scopable 1.1.1 → 1.1.3

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.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
- gem 'codeclimate-test-reporter', group: :test, require: nil
3
+ group :test do
4
+ gem "simplecov"
5
+ gem "codeclimate-test-reporter", "~> 1.0.0"
6
+ end
File without changes
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
+ [![RubyGems](https://img.shields.io/gem/dt/scopable.svg)](https://rubygems.org/gems/scopable)
2
+ [![Build](https://img.shields.io/travis/haggen/scopable.svg)](https://travis-ci.org/haggen/scopable)
3
+ [![Code Climate](https://img.shields.io/codeclimate/github/haggen/scopable.svg)](https://codeclimate.com/github/haggen/scopable)
4
+ [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/haggen/scopable.svg)](https://codeclimate.com/github/haggen/scopable/coverage)
5
+
1
6
  # Scopable
2
7
 
3
8
  > Apply or skip model scopes based on options and request parameters.
4
9
 
5
- [![Code Climate](https://codeclimate.com/github/haggen/scopable/badges/gpa.svg?1)](https://codeclimate.com/github/haggen/scopable)
6
- [![Test Coverage](https://codeclimate.com/github/haggen/scopable/badges/coverage.svg?1)](https://codeclimate.com/github/haggen/scopable/coverage)
7
- [![Build](https://travis-ci.org/haggen/scopable.svg)](https://travis-ci.org/haggen/scopable)
8
-
9
10
  ## Installation
10
11
 
11
12
  Add this line to your application's Gemfile:
@@ -116,6 +117,10 @@ Key | Description
116
117
  `:except` | The scope will be applied to all actions except these.
117
118
  `&block` | Block will be called in the context of the action and will be given the current relation and evaluated value.
118
119
 
120
+ ## License
121
+
122
+ See [LICENSE](LICENSE).
123
+
119
124
  ## Contributing
120
125
 
121
126
  1. Fork it ( https://github.com/[my-github-username]/scopable/fork )
@@ -123,7 +128,3 @@ Key | Description
123
128
  3. Commit your changes (`git commit -am 'Add some feature'`)
124
129
  4. Push to the branch (`git push origin my-new-feature`)
125
130
  5. Create a new Pull Request
126
-
127
- ## License
128
-
129
- See [LICENSE.txt](LICENSE.txt).
@@ -1,3 +1,3 @@
1
1
  module Scopable
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.3"
3
3
  end
data/lib/scopable.rb CHANGED
@@ -60,10 +60,11 @@ module Scopable
60
60
 
61
61
  # For advanced scopes that require more than a method call on the model.
62
62
  # When a block is given, it is ran no matter the scope value.
63
- # The proc will be given the model being scoped and the resulting value from the options above, and it'll be executed inside the context of the controller's action.
63
+ # The proc will be given the model being scoped and the resulting value from the
64
+ # options above, and it'll be executed inside the context of the controller's action.
64
65
  block = options[:block]
65
66
 
66
- if block.nil? && value.nil?
67
+ if block.nil? && value.blank?
67
68
  next relation
68
69
  end
69
70
 
data/scopable.gemspec CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'activesupport', '>= 3.2'
22
- # spec.add_runtime_dependency 'railties', '>= 4.2.0', '< 5.1'
21
+ spec.required_ruby_version = '>= 2.2.2'
22
+
23
+ spec.add_runtime_dependency 'activesupport', '>= 3.2', '<= 5.0.0'
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.7'
25
26
  spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rspec', '~> 3.5'
27
28
  end
@@ -18,7 +18,7 @@ describe Scopable do
18
18
  end
19
19
 
20
20
  #
21
- # Test single scope, no options, with and without matching parameters.
21
+ # Test single scope, no options.
22
22
  #
23
23
  describe 'with one optional scope' do
24
24
  let :controller do
@@ -27,7 +27,7 @@ describe Scopable do
27
27
  end
28
28
  end
29
29
 
30
- context 'without matching parameters' do
30
+ context 'with the parameter absent' do
31
31
  subject :action do
32
32
  controller.new
33
33
  end
@@ -37,7 +37,7 @@ describe Scopable do
37
37
  end
38
38
  end
39
39
 
40
- context 'with one matching parameter' do
40
+ context 'with the parameter present' do
41
41
  subject :action do
42
42
  controller.new(nil, search: 'test')
43
43
  end
@@ -46,6 +46,16 @@ describe Scopable do
46
46
  expect(action.relation.scopes).to include(search: 'test')
47
47
  end
48
48
  end
49
+
50
+ context 'with the parameter present but blank' do
51
+ subject :action do
52
+ controller.new(nil, search: '')
53
+ end
54
+
55
+ it 'should skip the scope' do
56
+ expect(action.relation.scopes).to be_empty
57
+ end
58
+ end
49
59
  end
50
60
 
51
61
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Corenzan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.2'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +62,16 @@ dependencies:
56
62
  name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: '3.5'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ">="
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: '3.5'
69
75
  description:
70
76
  email:
71
77
  - arthur@corenzan.com
@@ -79,7 +85,7 @@ files:
79
85
  - ".rubocop.yml"
80
86
  - ".travis.yml"
81
87
  - Gemfile
82
- - LICENSE.txt
88
+ - LICENSE
83
89
  - README.md
84
90
  - Rakefile
85
91
  - lib/scopable.rb
@@ -101,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
107
  requirements:
102
108
  - - ">="
103
109
  - !ruby/object:Gem::Version
104
- version: '0'
110
+ version: 2.2.2
105
111
  required_rubygems_version: !ruby/object:Gem::Requirement
106
112
  requirements:
107
113
  - - ">="