filter_form 0.8.3 → 0.8.4
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/filter_form.gemspec +1 -0
- data/lib/filter_form/input_options/base.rb +5 -1
- data/lib/filter_form/input_options_builder.rb +5 -1
- data/lib/filter_form/version.rb +1 -1
- data/spec/fixtures/migration.rb +5 -0
- data/spec/models/input_options_builder_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d514e906d56ea65624a343c6b63c6443145189d
|
4
|
+
data.tar.gz: 4b527e87032319ec14595dd2d2abfe1679d2bf54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9a7f928908891e6ada8e519641653211762b32d75b1024063c674655c8a447552f032d6bb804434ca00040706d08c921ab312e9e3fe006a3b0ab39b82e5f34
|
7
|
+
data.tar.gz: cacb7a8fa03accd3b001f1253b6e794bd6e4a87451c69469703b657dca9badfce293c7d13dc0d323750579d785483970f1685fc0838dee15bffccecce106fa41
|
data/filter_form.gemspec
CHANGED
@@ -70,7 +70,11 @@ module FilterForm
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def association
|
73
|
-
|
73
|
+
if ActiveRecord.try(:version).to_s.to_f >= 4.2
|
74
|
+
object.klass.reflections[attribute_name]
|
75
|
+
else
|
76
|
+
object.klass.reflections[attribute_name.to_sym]
|
77
|
+
end
|
74
78
|
end
|
75
79
|
|
76
80
|
def current_predicate
|
@@ -69,7 +69,11 @@ module FilterForm
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def association?
|
72
|
-
|
72
|
+
if ActiveRecord.try(:version).to_s.to_f >= 4.2
|
73
|
+
!!object.klass.reflections[attribute_name]
|
74
|
+
else
|
75
|
+
!!object.klass.reflections[attribute_name.to_sym]
|
76
|
+
end
|
73
77
|
end
|
74
78
|
|
75
79
|
def money?
|
data/lib/filter_form/version.rb
CHANGED
data/spec/fixtures/migration.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
class User < ActiveRecord::Base
|
4
|
+
has_one :dog
|
5
|
+
end
|
6
|
+
|
7
|
+
class Dog < ActiveRecord::Base
|
4
8
|
end
|
5
9
|
|
6
10
|
describe FilterForm::InputOptionsBuilder do
|
7
11
|
let(:search) { User.search }
|
8
12
|
let(:builder) { FilterForm::InputOptionsBuilder.new(object: search) }
|
9
13
|
|
14
|
+
context 'association' do
|
15
|
+
it 'returns correct options with predicate "select"' do
|
16
|
+
builder.attribute_name = :dog
|
17
|
+
|
18
|
+
result = builder.build
|
19
|
+
|
20
|
+
expected_result = { as: :select, required: false, label: 'Dog EQUALS', input_html: { name: 'q[user_id_eq]' }, include_blank: true, selected: nil }
|
21
|
+
expect(result.except(:collection)).to eq(expected_result)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
10
25
|
context 'boolean' do
|
11
26
|
context 'default predicate' do
|
12
27
|
it 'returns correct options with predicate "true"' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filter_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Li
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: Build filter forms easily
|
126
140
|
email:
|
127
141
|
- exaspark@gmail.com
|