filterrific 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +13 -15
- data/app/assets/javascripts/filterrific/filterrific-jquery.js +14 -3
- data/lib/filterrific/action_view_extension.rb +8 -12
- data/lib/filterrific/active_record_extension.rb +4 -2
- data/lib/filterrific/engine.rb +6 -2
- data/lib/filterrific/param_set.rb +13 -4
- data/lib/filterrific/version.rb +1 -1
- data/spec/filterrific/action_controller_extension_spec.rb +18 -18
- data/spec/filterrific/action_view_extension_spec.rb +4 -4
- data/spec/filterrific/active_record_extension_spec.rb +35 -14
- data/spec/filterrific/param_set_spec.rb +76 -66
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e942aed2e691e4dc777ac1e8011bba4d72ec314
|
4
|
+
data.tar.gz: 59b0a72bd4e47c51ed2262f1fa86f6d6fb44485d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 659b8b69290422638847f5634ac6970b88194c5c6316c5af47b03b40ca9fbeabd1b9073d57bbc505771ace4bf9c6f7b4caf1a5792ae63cabafed7740a9bd0f3e
|
7
|
+
data.tar.gz: 6145fce069f6007e3f9f4fdcbe6e744adcc6614479a068369db2e1419515cc96b294cc1337d313660ab4e5b760a7a4c90f1e2d3f8b0de37b4fac041cdd323051
|
data/CHANGELOG.md
CHANGED
@@ -39,6 +39,18 @@
|
|
39
39
|
},
|
40
40
|
)
|
41
41
|
|
42
|
+
|
43
|
+
## 2.1.0
|
44
|
+
|
45
|
+
* Updated filterrific for Rails 5 compatibility:
|
46
|
+
* Turbolinks compatibility (thanks @olegantonyan)
|
47
|
+
* Updated to Ruby 2.2.2 in CI test matrix
|
48
|
+
* Added Ruby 2.3.1 to CI test matrix (thanks @rodrigoargumedo)
|
49
|
+
* Fixed #stringify_keys deprecation warning (thanks @olegantonyan)
|
50
|
+
* When generating sorting headers, allow usage of HTML (e.g., for icons) using #safe_join (thanks @ScottKolo)
|
51
|
+
* Improved param casting to Int: hyphens and zeros (thanks @grit96)
|
52
|
+
|
53
|
+
|
42
54
|
### 2.0.5
|
43
55
|
|
44
56
|
* Feature: Allow disabling of session persistence by passing `false` as
|
data/README.md
CHANGED
@@ -26,12 +26,13 @@ or with bundler in your Gemfile:
|
|
26
26
|
|
27
27
|
Every commit to Filterrific is automatically tested against the following scenarios:
|
28
28
|
|
29
|
-
| Rails version | Ruby environments
|
30
|
-
|
31
|
-
| Rails
|
32
|
-
| Rails 4.
|
33
|
-
| Rails 4.
|
34
|
-
| Rails
|
29
|
+
| Rails version | Ruby environments | Database adapters | Build status |
|
30
|
+
|---------------|---------------------------------------|------------------------------------|--------------|
|
31
|
+
| Rails 5.x | MRI 1.9.3, 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-5.x)](https://travis-ci.org/jhund/filterrific_demo)|
|
32
|
+
| Rails 4.2 | MRI 1.9.3, 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-4.2)](https://travis-ci.org/jhund/filterrific_demo)|
|
33
|
+
| Rails 4.1 | MRI 1.9.3, 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-4.1)](https://travis-ci.org/jhund/filterrific_demo)|
|
34
|
+
| Rails 4.0 | MRI 1.9.3, 2.0.0, 2.1.7, 2.2.3, 2.3.1 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-4.0)](https://travis-ci.org/jhund/filterrific_demo)|
|
35
|
+
| Rails 3.2 | MRI 1.9.3, 2.0.0, 2.1.7 | mysql, mysql2, postgresql, sqlite3 |[![Build Status](https://travis-ci.org/jhund/filterrific_demo.svg?branch=rails-3.2)](https://travis-ci.org/jhund/filterrific_demo)|
|
35
36
|
|
36
37
|
Filterrific version 1.x should work on older versions of Rails and Ruby, however
|
37
38
|
the 1.x branch is not supported any more.
|
@@ -39,9 +40,11 @@ the 1.x branch is not supported any more.
|
|
39
40
|
|
40
41
|
### Guidelines for submitting issues
|
41
42
|
|
42
|
-
|
43
|
+
Please post questions related to usage at [StackOverflow](http://stackoverflow.com/questions/tagged/filterrific) under the `filterrific` tag.
|
43
44
|
|
44
|
-
|
45
|
+
If you think you've found a bug, or have a feature request, then create an issue here on Github. You'll make my job easier if you follow these guidelines:
|
46
|
+
|
47
|
+
* Please keep in mind that I do this in my spare time. I appreciate it if you first do everything you can on your own: read the detailed filterrific documentation, look for similar issues on StackOverflow, search the internets, etc. To you this software is free as in `beer`, to me it's free as in `baby`.
|
45
48
|
* If you're stuck, give me sufficient context so that I have a chance to identify the issue:
|
46
49
|
* what version of filterrific are you using? (look in your `Gemfile.lock`)
|
47
50
|
* what version of Rails are you using? (look in your `Gemfile.lock`)
|
@@ -58,18 +61,13 @@ I'm happy to help you if you encounter problems when using filterrific. You'll m
|
|
58
61
|
* [Changelog](https://github.com/jhund/filterrific/blob/master/CHANGELOG.md)
|
59
62
|
* [Source code (github)](https://github.com/jhund/filterrific)
|
60
63
|
* [Issues](https://github.com/jhund/filterrific/issues)
|
64
|
+
* [Questions on Stack Overflow](http://stackoverflow.com/questions/tagged/filterrific) (tagged `filterrific`)
|
61
65
|
* [Rubygems.org](http://rubygems.org/gems/filterrific)
|
62
66
|
|
63
67
|
[![Build Status](https://travis-ci.org/jhund/filterrific.svg?branch=master)](https://travis-ci.org/jhund/filterrific)
|
64
68
|
|
65
69
|
[![Code Climate](https://codeclimate.com/github/jhund/filterrific.png)](https://codeclimate.com/github/jhund/filterrific)
|
66
70
|
|
67
|
-
### Related projects
|
68
|
-
|
69
|
-
* has_scope
|
70
|
-
* http://www.justinweiss.com/blog/2014/02/17/search-and-filter-rails-models-without-bloating-your-controller/
|
71
|
-
* https://github.com/laserlemon/periscope
|
72
|
-
|
73
71
|
### License
|
74
72
|
|
75
73
|
[MIT licensed](https://github.com/jhund/filterrific/blob/master/MIT-LICENSE).
|
@@ -78,4 +76,4 @@ I'm happy to help you if you encounter problems when using filterrific. You'll m
|
|
78
76
|
|
79
77
|
### Copyright
|
80
78
|
|
81
|
-
Copyright (c) 2010 -
|
79
|
+
Copyright (c) 2010 - 2016 Jo Hund. See [(MIT) LICENSE](https://github.com/jhund/filterrific/blob/master/MIT-LICENSE) for details.
|
@@ -78,9 +78,7 @@ Filterrific.submitFilterForm = function(){
|
|
78
78
|
})(jQuery);
|
79
79
|
|
80
80
|
|
81
|
-
|
82
|
-
// Initialize event observers on document ready and turbolinks page:load
|
83
|
-
jQuery(document).on('ready page:load', function() {
|
81
|
+
Filterrific.init = function() {
|
84
82
|
// Add change event handler to all Filterrific filter inputs.
|
85
83
|
$('#filterrific_filter').on(
|
86
84
|
"change",
|
@@ -94,4 +92,17 @@ jQuery(document).on('ready page:load', function() {
|
|
94
92
|
0.5,
|
95
93
|
Filterrific.submitFilterForm
|
96
94
|
);
|
95
|
+
};
|
96
|
+
|
97
|
+
|
98
|
+
// Initialize event observers on document ready and turbolinks page:load
|
99
|
+
jQuery(document).on('turbolinks:load', function() {
|
100
|
+
// Prevent double initilisation. With turbolinks 5 this function
|
101
|
+
// will be called twice: on 'ready' and 'turbolinks:load'
|
102
|
+
jQuery(document).off('ready page:load')
|
103
|
+
Filterrific.init();
|
104
|
+
});
|
105
|
+
|
106
|
+
jQuery(document).on('ready page:load', function() {
|
107
|
+
Filterrific.init();
|
97
108
|
});
|
@@ -101,22 +101,18 @@ module Filterrific
|
|
101
101
|
# @return [String] an HTML fragment
|
102
102
|
def filterrific_sorting_link_reverse_order(filterrific, new_sort_key, opts)
|
103
103
|
# current sort column, toggle search_direction
|
104
|
-
new_sort_direction
|
105
|
-
|
106
|
-
|
107
|
-
['asc', opts[:descending_indicator]]
|
108
|
-
end
|
109
|
-
new_sorting = [new_sort_key, new_sort_direction].join('_')
|
110
|
-
css_classes = [
|
104
|
+
new_sort_direction = 'asc' == opts[:current_sort_direction] ? 'desc' : 'asc'
|
105
|
+
new_sorting = safe_join([new_sort_key, new_sort_direction], '_')
|
106
|
+
css_classes = safe_join([
|
111
107
|
opts[:active_column_class],
|
112
108
|
opts[:html_attrs].delete(:class)
|
113
|
-
].compact
|
109
|
+
].compact, ' ')
|
114
110
|
new_filterrific_params = filterrific.to_hash
|
115
111
|
.with_indifferent_access
|
116
112
|
.merge(opts[:sorting_scope_name] => new_sorting)
|
117
113
|
url_for_attrs = opts[:url_for_attrs].merge(:filterrific => new_filterrific_params)
|
118
114
|
link_to(
|
119
|
-
[opts[:label], opts[:current_sort_direction_indicator]]
|
115
|
+
safe_join([opts[:label], opts[:current_sort_direction_indicator]], ' '),
|
120
116
|
url_for(url_for_attrs),
|
121
117
|
opts[:html_attrs].reverse_merge(:class => css_classes, :method => :get, :remote => true)
|
122
118
|
)
|
@@ -129,11 +125,11 @@ module Filterrific
|
|
129
125
|
# @return [String] an HTML fragment
|
130
126
|
def filterrific_sorting_link_new_column(filterrific, new_sort_key, opts)
|
131
127
|
new_sort_direction = opts[:default_sort_direction]
|
132
|
-
new_sorting = [new_sort_key, new_sort_direction]
|
133
|
-
css_classes = [
|
128
|
+
new_sorting = safe_join([new_sort_key, new_sort_direction], '_')
|
129
|
+
css_classes = safe_join([
|
134
130
|
opts[:inactive_column_class],
|
135
131
|
opts[:html_attrs].delete(:class)
|
136
|
-
].compact
|
132
|
+
].compact, ' ')
|
137
133
|
new_filterrific_params = filterrific.to_hash
|
138
134
|
.with_indifferent_access
|
139
135
|
.merge(opts[:sorting_scope_name] => new_sorting)
|
@@ -19,8 +19,10 @@ module Filterrific
|
|
19
19
|
# @option opts [Hash, optional] default_filter_params: default filter parameters
|
20
20
|
# @return [void]
|
21
21
|
def filterrific(opts)
|
22
|
-
|
23
|
-
|
22
|
+
class << self
|
23
|
+
attr_accessor :filterrific_available_filters
|
24
|
+
attr_accessor :filterrific_default_filter_params
|
25
|
+
end
|
24
26
|
self.filterrific_available_filters = []
|
25
27
|
|
26
28
|
opts.stringify_keys!
|
data/lib/filterrific/engine.rb
CHANGED
@@ -28,8 +28,12 @@ module Filterrific
|
|
28
28
|
extend Filterrific::ActiveRecordExtension
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
# sprockets-rails 3 tracks down the calls to `font_path` and `image_path`
|
32
|
+
# and automatically precompiles the referenced assets.
|
33
|
+
unless Rails::VERSION::MAJOR < 5
|
34
|
+
initializer "filterrific.assets.precompile" do |app|
|
35
|
+
app.config.assets.precompile += %w(filterrific/filterrific-spinner.gif)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
end
|
@@ -28,7 +28,11 @@ module Filterrific
|
|
28
28
|
# Persistence, baby. By the time you submit changes to one filter, all the others
|
29
29
|
# will be already initialized with the defaults.
|
30
30
|
filterrific_params = model_class.filterrific_default_filter_params if filterrific_params.blank?
|
31
|
-
filterrific_params.
|
31
|
+
if defined?(ActionController::Parameters) && filterrific_params.is_a?(ActionController::Parameters)
|
32
|
+
filterrific_params = filterrific_params.permit(model_class.filterrific_available_filters).to_h.stringify_keys
|
33
|
+
else
|
34
|
+
filterrific_params.stringify_keys!
|
35
|
+
end
|
32
36
|
filterrific_params = condition_filterrific_params(filterrific_params)
|
33
37
|
define_and_assign_attr_accessors_for_each_filter(filterrific_params)
|
34
38
|
end
|
@@ -79,7 +83,7 @@ module Filterrific
|
|
79
83
|
protected
|
80
84
|
|
81
85
|
# Conditions params: Evaluates Procs and type casts integer values.
|
82
|
-
# Why are we type casting integers?
|
86
|
+
# TODO: Why are we type casting integers?
|
83
87
|
# @param fp [Hash] the filterrific params hash
|
84
88
|
# @return[Hash] the conditioned params hash
|
85
89
|
def condition_filterrific_params(fp)
|
@@ -90,12 +94,12 @@ module Filterrific
|
|
90
94
|
fp[key] = val.call
|
91
95
|
when val.is_a?(Array)
|
92
96
|
# type cast integers in the array
|
93
|
-
fp[key] = fp[key].map { |e| e =~
|
97
|
+
fp[key] = fp[key].map { |e| e =~ integer_detector_regex ? e.to_i : e }
|
94
98
|
when val.is_a?(Hash)
|
95
99
|
# type cast Hash to OpenStruct so that nested params render correctly
|
96
100
|
# in the form
|
97
101
|
fp[key] = OpenStruct.new(fp[key])
|
98
|
-
when val =~
|
102
|
+
when val =~ integer_detector_regex
|
99
103
|
# type cast integer
|
100
104
|
fp[key] = fp[key].to_i
|
101
105
|
end
|
@@ -103,6 +107,11 @@ module Filterrific
|
|
103
107
|
fp
|
104
108
|
end
|
105
109
|
|
110
|
+
# Regex to detect if str represents and int
|
111
|
+
def integer_detector_regex
|
112
|
+
/\A-?([1-9]\d*|0)\z/
|
113
|
+
end
|
114
|
+
|
106
115
|
# Defines attr accessors for each available_filter on self and assigns
|
107
116
|
# values based on fp.
|
108
117
|
# @param fp [Hash] filterrific_params with stringified keys
|
data/lib/filterrific/version.rb
CHANGED
@@ -3,28 +3,28 @@ require 'filterrific/action_controller_extension'
|
|
3
3
|
|
4
4
|
module Filterrific
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
'
|
6
|
+
describe ActionControllerExtension do
|
7
|
+
|
8
|
+
class TestController
|
9
|
+
include ActionControllerExtension
|
10
|
+
def action_name; 'index'; end
|
11
|
+
def controller_name; 'test_controller'; end
|
12
|
+
def session
|
13
|
+
{
|
14
|
+
'test_controller#index' => {
|
15
|
+
'filter1' => '1_from_session',
|
16
|
+
'filter2' => '2_from_session',
|
17
|
+
}
|
15
18
|
}
|
16
|
-
|
19
|
+
end
|
17
20
|
end
|
18
|
-
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
class TestModelClass
|
23
|
+
def self.filterrific_available_filters; %w[filter1 filter2]; end
|
24
|
+
def self.filterrific_default_filter_params
|
25
|
+
{ 'filter1' => '1_from_model_defaults' }
|
26
|
+
end
|
24
27
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ActionControllerExtension do
|
28
28
|
|
29
29
|
describe '#initialize_filterrific' do
|
30
30
|
|
@@ -3,12 +3,12 @@ require 'filterrific/action_view_extension'
|
|
3
3
|
|
4
4
|
module Filterrific
|
5
5
|
|
6
|
-
class ViewContext
|
7
|
-
include ActionViewExtension
|
8
|
-
end
|
9
|
-
|
10
6
|
describe ActionViewExtension do
|
11
7
|
|
8
|
+
class ViewContext
|
9
|
+
include ActionViewExtension
|
10
|
+
end
|
11
|
+
|
12
12
|
it 'responds to #form_for_filterrific' do
|
13
13
|
ViewContext.new.must_respond_to(:form_for_filterrific)
|
14
14
|
end
|
@@ -6,26 +6,26 @@ ActiveRecord::Base.extend Filterrific::ActiveRecordExtension
|
|
6
6
|
|
7
7
|
module Filterrific
|
8
8
|
|
9
|
-
|
10
|
-
class TestData
|
9
|
+
describe ActiveRecordExtension do
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
# Container for test data
|
12
|
+
class TestDataARES
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def self.filterrific_available_filters
|
15
|
+
%w[search_query sorted_by with_country_id]
|
16
|
+
end
|
19
17
|
|
20
|
-
|
18
|
+
def self.filterrific_default_filter_params
|
19
|
+
{ 'sorted_by' => 'name_asc' }
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
end
|
23
23
|
|
24
24
|
let(:filterrific_class){
|
25
25
|
Class.new(ActiveRecord::Base) do
|
26
26
|
filterrific(
|
27
|
-
available_filters:
|
28
|
-
default_filter_params:
|
27
|
+
available_filters: TestDataARES.filterrific_available_filters,
|
28
|
+
default_filter_params: TestDataARES.filterrific_default_filter_params
|
29
29
|
)
|
30
30
|
end
|
31
31
|
}
|
@@ -46,13 +46,13 @@ module Filterrific
|
|
46
46
|
|
47
47
|
it "initializes filterrific_available_filters" do
|
48
48
|
filterrific_class.filterrific_available_filters.must_equal(
|
49
|
-
|
49
|
+
TestDataARES.filterrific_available_filters
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "initializes filterrific_default_filter_params" do
|
54
54
|
filterrific_class.filterrific_default_filter_params.must_equal(
|
55
|
-
|
55
|
+
TestDataARES.filterrific_default_filter_params
|
56
56
|
)
|
57
57
|
end
|
58
58
|
|
@@ -90,4 +90,25 @@ module Filterrific
|
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
93
|
+
|
94
|
+
describe "Single Table Inheritance" do
|
95
|
+
|
96
|
+
class Daddy < ActiveRecord::Base
|
97
|
+
filterrific(available_filters: [:one, :two])
|
98
|
+
end
|
99
|
+
|
100
|
+
class Girl < Daddy
|
101
|
+
filterrific(available_filters: [:three, :four])
|
102
|
+
end
|
103
|
+
|
104
|
+
%w(one two).each do |value|
|
105
|
+
it { Daddy.filterrific_available_filters.must_include value }
|
106
|
+
end
|
107
|
+
|
108
|
+
%w(three four).each do |value|
|
109
|
+
it { Girl.filterrific_available_filters.must_include value }
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
93
114
|
end
|
@@ -3,83 +3,93 @@ require 'filterrific/param_set'
|
|
3
3
|
|
4
4
|
module Filterrific
|
5
5
|
|
6
|
-
|
7
|
-
class TestData
|
8
|
-
|
9
|
-
def self.filterrific_available_filters
|
10
|
-
%w[
|
11
|
-
filter_almost_int
|
12
|
-
filter_array_int
|
13
|
-
filter_array_string
|
14
|
-
filter_hash
|
15
|
-
filter_int
|
16
|
-
filter_negative_int
|
17
|
-
filter_proc
|
18
|
-
filter_string
|
19
|
-
]
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.filterrific_default_filter_params
|
23
|
-
{ 'filter_int' => 42 }
|
24
|
-
end
|
6
|
+
describe ParamSet do
|
25
7
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
8
|
+
# Container for test data
|
9
|
+
class TestData
|
10
|
+
|
11
|
+
def self.filterrific_available_filters
|
12
|
+
%w[
|
13
|
+
filter_almost_int
|
14
|
+
filter_array_int
|
15
|
+
filter_array_string
|
16
|
+
filter_hash
|
17
|
+
filter_hyphen
|
18
|
+
filter_int
|
19
|
+
filter_negative_int
|
20
|
+
filter_proc
|
21
|
+
filter_string
|
22
|
+
filter_zero
|
23
|
+
]
|
24
|
+
end
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
'filter_array_int' => [1, 2, 3],
|
43
|
-
'filter_array_string' => %w[one two three],
|
44
|
-
'filter_hash' => OpenStruct.new(a: 1, b: 2),
|
45
|
-
'filter_int' => 42,
|
46
|
-
'filter_negative_int' => -42,
|
47
|
-
'filter_proc' => 2,
|
48
|
-
'filter_string' => 'forty-two',
|
49
|
-
}
|
50
|
-
end
|
26
|
+
def self.filterrific_default_filter_params
|
27
|
+
{ 'filter_int' => 42 }
|
28
|
+
end
|
51
29
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
30
|
+
def self.filterrific_params
|
31
|
+
{
|
32
|
+
'filter_almost_int' => '042',
|
33
|
+
'filter_array_int' => %w[1 2 3],
|
34
|
+
'filter_array_string' => %w[one two three],
|
35
|
+
'filter_hash' => { a: 1, b: 2 },
|
36
|
+
'filter_hyphen' => '-',
|
37
|
+
'filter_int' => '42',
|
38
|
+
'filter_negative_int' => '-42',
|
39
|
+
'filter_proc' => lambda { 1 + 1 },
|
40
|
+
'filter_string' => 'forty-two',
|
41
|
+
'filter_zero' => '0',
|
42
|
+
}
|
43
|
+
end
|
64
44
|
|
65
|
-
|
45
|
+
def self.filterrific_params_after_conditioning
|
46
|
+
{
|
47
|
+
'filter_almost_int' => '042',
|
48
|
+
'filter_array_int' => [1, 2, 3],
|
49
|
+
'filter_array_string' => %w[one two three],
|
50
|
+
'filter_hash' => OpenStruct.new(a: 1, b: 2),
|
51
|
+
'filter_hyphen' => '-',
|
52
|
+
'filter_int' => 42,
|
53
|
+
'filter_negative_int' => -42,
|
54
|
+
'filter_proc' => 2,
|
55
|
+
'filter_string' => 'forty-two',
|
56
|
+
'filter_zero' => 0,
|
57
|
+
}
|
58
|
+
end
|
66
59
|
|
67
|
-
|
68
|
-
|
60
|
+
def self.filterrific_params_as_hash
|
61
|
+
{
|
62
|
+
'filter_almost_int' => '042',
|
63
|
+
'filter_array_int' => [1, 2, 3],
|
64
|
+
'filter_array_string' => %w[one two three],
|
65
|
+
'filter_hash' => { a: 1, b: 2 },
|
66
|
+
'filter_hyphen' => '-',
|
67
|
+
'filter_int' => 42,
|
68
|
+
'filter_negative_int' => -42,
|
69
|
+
'filter_proc' => 2,
|
70
|
+
'filter_string' => 'forty-two',
|
71
|
+
'filter_zero' => 0,
|
72
|
+
}
|
73
|
+
end
|
69
74
|
|
70
|
-
def self.filterrific_default_filter_params
|
71
|
-
TestData.filterrific_default_filter_params
|
72
|
-
end
|
73
|
-
def self.filterrific_available_filters
|
74
|
-
TestData.filterrific_available_filters
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
# Simulates a class that would include the filterrific directive
|
78
|
+
class ModelClass
|
78
79
|
|
79
|
-
|
80
|
+
def self.filterrific_default_filter_params
|
81
|
+
TestData.filterrific_default_filter_params
|
82
|
+
end
|
83
|
+
def self.filterrific_available_filters
|
84
|
+
TestData.filterrific_available_filters
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
80
88
|
|
81
89
|
let(:filterrific_param_set){
|
82
|
-
|
90
|
+
Kernel::silence_warnings {
|
91
|
+
Filterrific::ParamSet.new(ModelClass, TestData.filterrific_params)
|
92
|
+
}
|
83
93
|
}
|
84
94
|
|
85
95
|
describe "initialization" do
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filterrific
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Hund
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.6.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gem-release
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.7.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.7.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 10.3.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 10.3.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: wwtd
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.5.5
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.5.5
|
83
83
|
description: Filterrific is a Rails Engine plugin that makes it easy to filter, search,
|
@@ -126,17 +126,17 @@ require_paths:
|
|
126
126
|
- lib
|
127
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 1.9.3
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- -
|
134
|
+
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.1
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: A Rails engine plugin for filtering ActiveRecord lists.
|