filter_form 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 61f48ddb9a951f24ca2c7f1c637f8c46387ebb63
4
- data.tar.gz: a44a6a392a2f1714c06ce37d3eb83f20d8c89e3c
3
+ metadata.gz: 2d514e906d56ea65624a343c6b63c6443145189d
4
+ data.tar.gz: 4b527e87032319ec14595dd2d2abfe1679d2bf54
5
5
  SHA512:
6
- metadata.gz: 912056cb716eabd7eb85bb4182cfbffb18819cc202c396f62b8001c2b3b637b0a124ba7acb788f8c26c49f1499e0696d95a1c3d268551f97359e9291b2e8dc6a
7
- data.tar.gz: 612c03cae32f18acf25a6543bc03c33597a442387582b435f08638437a28f092c808b612639e8fe212db3b3dba9e166ae038a3566fcdee9d0a1f42e1a0948a2f
6
+ metadata.gz: dd9a7f928908891e6ada8e519641653211762b32d75b1024063c674655c8a447552f032d6bb804434ca00040706d08c921ab312e9e3fe006a3b0ab39b82e5f34
7
+ data.tar.gz: cacb7a8fa03accd3b001f1253b6e794bd6e4a87451c69469703b657dca9badfce293c7d13dc0d323750579d785483970f1685fc0838dee15bffccecce106fa41
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'rake'
27
27
  spec.add_development_dependency 'rspec', '~> 3.0.0'
28
28
  spec.add_development_dependency 'sqlite3'
29
+ spec.add_development_dependency 'pry'
29
30
  end
@@ -70,7 +70,11 @@ module FilterForm
70
70
  end
71
71
 
72
72
  def association
73
- object.klass.reflections[attribute_name]
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
- !!object.klass.reflections[attribute_name]
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?
@@ -1,3 +1,3 @@
1
1
  module FilterForm
2
- VERSION = '0.8.3'
2
+ VERSION = '0.8.4'
3
3
  end
@@ -9,3 +9,8 @@ ActiveRecord::Migration.create_table :users do |t|
9
9
  t.integer :city_id
10
10
  t.string :gender
11
11
  end
12
+
13
+ ActiveRecord::Migration.create_table :dog do |t|
14
+ t.string :name
15
+ t.integer :user_id
16
+ end
@@ -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
@@ -1,4 +1,5 @@
1
1
  require 'rails'
2
+ require 'pry'
2
3
  require 'action_view'
3
4
  require 'active_model'
4
5
 
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.3
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