ransack 1.8.10 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +12 -3
- data/CHANGELOG.md +29 -5
- data/Gemfile +1 -9
- data/README.md +16 -25
- data/Rakefile +1 -22
- data/lib/polyamorous.rb +5 -18
- data/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +2 -2
- data/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +2 -2
- data/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb +38 -0
- data/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb +75 -0
- data/lib/ransack/adapters/active_record.rb +0 -9
- data/lib/ransack/adapters/active_record/base.rb +8 -0
- data/lib/ransack/adapters/active_record/context.rb +118 -182
- data/lib/ransack/adapters/active_record/ransack/context.rb +1 -8
- data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -5
- data/lib/ransack/constants.rb +1 -1
- data/lib/ransack/context.rb +4 -0
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/search.rb +1 -1
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +4 -3
- data/spec/helpers/polyamorous_helper.rb +7 -9
- data/spec/ransack/adapters/active_record/base_spec.rb +35 -0
- data/spec/ransack/adapters/active_record/context_spec.rb +3 -6
- data/spec/ransack/helpers/form_builder_spec.rb +3 -15
- data/spec/ransack/helpers/form_helper_spec.rb +11 -99
- data/spec/ransack/join_association_spec.rb +1 -6
- data/spec/ransack/join_dependency_spec.rb +1 -6
- data/spec/ransack/search_spec.rb +2 -2
- data/spec/support/schema.rb +3 -21
- metadata +10 -83
- data/lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_association.rb +0 -76
- data/lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_dependency.rb +0 -96
- data/lib/polyamorous/activerecord_4.1_ruby_1.9/join_association.rb +0 -2
- data/lib/polyamorous/activerecord_4.1_ruby_1.9/join_dependency.rb +0 -4
- data/lib/polyamorous/activerecord_4.1_ruby_2/join_association.rb +0 -2
- data/lib/polyamorous/activerecord_4.1_ruby_2/join_dependency.rb +0 -3
- data/lib/polyamorous/activerecord_4.1_ruby_2/make_polyamorous_inner_joins.rb +0 -14
- data/lib/polyamorous/activerecord_4.2_ruby_1.9/join_association.rb +0 -46
- data/lib/polyamorous/activerecord_4.2_ruby_1.9/join_dependency.rb +0 -87
- data/lib/polyamorous/activerecord_4.2_ruby_2/join_association.rb +0 -2
- data/lib/polyamorous/activerecord_4.2_ruby_2/join_dependency.rb +0 -24
- data/lib/ransack/adapters/active_record/3.0/compat.rb +0 -173
- data/lib/ransack/adapters/active_record/3.0/context.rb +0 -203
- data/lib/ransack/adapters/active_record/3.1/context.rb +0 -212
- data/lib/ransack/adapters/active_record/3.2/context.rb +0 -44
- data/lib/ransack/adapters/mongoid.rb +0 -15
- data/lib/ransack/adapters/mongoid/3.2/.gitkeep +0 -0
- data/lib/ransack/adapters/mongoid/attributes/attribute.rb +0 -37
- data/lib/ransack/adapters/mongoid/attributes/order_predications.rb +0 -17
- data/lib/ransack/adapters/mongoid/attributes/predications.rb +0 -141
- data/lib/ransack/adapters/mongoid/base.rb +0 -134
- data/lib/ransack/adapters/mongoid/context.rb +0 -212
- data/lib/ransack/adapters/mongoid/inquiry_hash.rb +0 -23
- data/lib/ransack/adapters/mongoid/ransack/constants.rb +0 -88
- data/lib/ransack/adapters/mongoid/ransack/context.rb +0 -59
- data/lib/ransack/adapters/mongoid/ransack/nodes/condition.rb +0 -22
- data/lib/ransack/adapters/mongoid/ransack/translate.rb +0 -13
- data/lib/ransack/adapters/mongoid/ransack/visitor.rb +0 -18
- data/lib/ransack/adapters/mongoid/table.rb +0 -35
- data/spec/mongoid/adapters/mongoid/base_spec.rb +0 -314
- data/spec/mongoid/adapters/mongoid/context_spec.rb +0 -56
- data/spec/mongoid/configuration_spec.rb +0 -162
- data/spec/mongoid/dependencies_spec.rb +0 -8
- data/spec/mongoid/helpers/ransack_helper.rb +0 -11
- data/spec/mongoid/nodes/condition_spec.rb +0 -49
- data/spec/mongoid/nodes/grouping_spec.rb +0 -13
- data/spec/mongoid/predicate_spec.rb +0 -155
- data/spec/mongoid/search_spec.rb +0 -445
- data/spec/mongoid/support/mongoid.yml +0 -11
- data/spec/mongoid/support/schema.rb +0 -135
- data/spec/mongoid/translate_spec.rb +0 -14
- data/spec/mongoid_spec_helper.rb +0 -63
- data/spec/ransack/dependencies_spec.rb +0 -12
data/lib/ransack/version.rb
CHANGED
data/ransack.gemspec
CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.license = 'MIT'
|
16
16
|
|
17
17
|
s.rubyforge_project = "ransack"
|
18
|
-
|
19
|
-
s.add_dependency '
|
20
|
-
s.add_dependency '
|
18
|
+
|
19
|
+
s.add_dependency 'actionpack', '>= 5.0'
|
20
|
+
s.add_dependency 'activerecord', '>= 5.0'
|
21
|
+
s.add_dependency 'activesupport', '>= 5.0'
|
21
22
|
s.add_dependency 'i18n'
|
22
23
|
s.add_development_dependency 'rspec', '~> 3'
|
23
24
|
s.add_development_dependency 'machinist', '~> 1.0.6'
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module PolyamorousHelper
|
2
|
-
|
3
|
-
|
4
|
-
Polyamorous::JoinAssociation.new reflection, children, klass
|
5
|
-
end
|
6
|
-
else
|
7
|
-
def new_join_association(reflection, join_dependency, parent, klass)
|
8
|
-
Polyamorous::JoinAssociation.new reflection, join_dependency, parent, klass
|
9
|
-
end
|
2
|
+
def new_join_association(reflection, children, klass)
|
3
|
+
Polyamorous::JoinAssociation.new reflection, children, klass
|
10
4
|
end
|
11
5
|
|
12
|
-
if ActiveRecord::VERSION::STRING
|
6
|
+
if ActiveRecord::VERSION::STRING > "5.2.0"
|
7
|
+
def new_join_dependency(klass, associations = {})
|
8
|
+
Polyamorous::JoinDependency.new klass, klass.arel_table, associations
|
9
|
+
end
|
10
|
+
elsif ActiveRecord::VERSION::STRING == "5.2.0"
|
13
11
|
def new_join_dependency(klass, associations = {})
|
14
12
|
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(klass.connection, klass.table_name, [])
|
15
13
|
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, alias_tracker
|
@@ -97,6 +97,25 @@ module Ransack
|
|
97
97
|
expect(s.result.to_sql).to (include 'age > 0')
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
context "with ransackable_scopes_skip_sanitize_args enabled for scope" do
|
102
|
+
before do
|
103
|
+
allow(Person)
|
104
|
+
.to receive(:ransackable_scopes_skip_sanitize_args)
|
105
|
+
.and_return([:over_age])
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'passes true values to scopes' do
|
109
|
+
s = Person.ransack('over_age' => 1)
|
110
|
+
expect(s.result.to_sql).to (include 'age > 1')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'passes false values to scopes' do
|
114
|
+
s = Person.ransack('over_age' => 0)
|
115
|
+
expect(s.result.to_sql).to (include 'age > 0')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
100
119
|
end
|
101
120
|
|
102
121
|
it 'does not raise exception for string :params argument' do
|
@@ -436,6 +455,16 @@ module Ransack
|
|
436
455
|
end
|
437
456
|
end
|
438
457
|
|
458
|
+
it 'sorts with different join variants' do
|
459
|
+
comments = [
|
460
|
+
Comment.create(article: Article.create(title: 'Avenger'), person: Person.create(salary: 100_000)),
|
461
|
+
Comment.create(article: Article.create(title: 'Avenge'), person: Person.create(salary: 50_000)),
|
462
|
+
]
|
463
|
+
expect(Comment.ransack(article_title_cont: 'aven',s: 'person_salary desc').result).to eq(comments)
|
464
|
+
expect(Comment.joins(:person).ransack(s: 'persons_salarydesc', article_title_cont: 'aven').result).to eq(comments)
|
465
|
+
expect(Comment.joins(:person).ransack(article_title_cont: 'aven',s: 'persons_salary desc').result).to eq(comments)
|
466
|
+
end
|
467
|
+
|
439
468
|
it 'allows sort by `only_sort` field' do
|
440
469
|
s = Person.ransack(
|
441
470
|
's' => { '0' => { 'dir' => 'asc', 'name' => 'only_sort' } }
|
@@ -645,6 +674,12 @@ module Ransack
|
|
645
674
|
it { should eq [] }
|
646
675
|
end
|
647
676
|
|
677
|
+
describe '#ransackable_scopes_skip_sanitize_args' do
|
678
|
+
subject { Person.ransackable_scopes_skip_sanitize_args }
|
679
|
+
|
680
|
+
it { should eq [] }
|
681
|
+
end
|
682
|
+
|
648
683
|
end
|
649
684
|
end
|
650
685
|
end
|
@@ -10,8 +10,7 @@ module Ransack
|
|
10
10
|
subject { Context.new(Person) }
|
11
11
|
|
12
12
|
|
13
|
-
it 'has an Active Record alias tracker method'
|
14
|
-
if: AR_version >= '3.1' do
|
13
|
+
it 'has an Active Record alias tracker method' do
|
15
14
|
expect(subject.alias_tracker)
|
16
15
|
.to be_an ::ActiveRecord::Associations::AliasTracker
|
17
16
|
end
|
@@ -69,16 +68,14 @@ module Ransack
|
|
69
68
|
end
|
70
69
|
|
71
70
|
describe '#join_sources' do
|
72
|
-
# FIXME: fix this test for Rails 4.2 and 5.0.
|
73
71
|
it 'returns dependent arel join nodes for all searches run against
|
74
|
-
the context'
|
72
|
+
the context' do
|
75
73
|
parents, children = shared_context.join_sources
|
76
74
|
expect(children.left.name).to eq "children_people"
|
77
75
|
expect(parents.left.name).to eq "parents_people"
|
78
76
|
end
|
79
77
|
|
80
|
-
it 'can be rejoined to execute a valid query'
|
81
|
-
if: AR_version >= '3.1' do
|
78
|
+
it 'can be rejoined to execute a valid query' do
|
82
79
|
parents, children = shared_context.join_sources
|
83
80
|
|
84
81
|
expect { Person.joins(parents).joins(children).to_a }
|
@@ -21,11 +21,7 @@ module Ransack
|
|
21
21
|
@controller.view_context.search_form_for(@s) { |f| @f = f }
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'selects previously-entered time values with datetime_select'
|
25
|
-
unless: (
|
26
|
-
RUBY_VERSION >= '2.3' &&
|
27
|
-
::ActiveRecord::VERSION::STRING.first(3) < '3.2'
|
28
|
-
) do
|
24
|
+
it 'selects previously-entered time values with datetime_select' do
|
29
25
|
date_values = %w(2011 1 2 03 04 05)
|
30
26
|
# @s.created_at_eq = date_values # This works in Rails 4.x but not 3.x
|
31
27
|
@s.created_at_eq = [2011, 1, 2, 3, 4, 5] # so we have to do this
|
@@ -75,11 +71,7 @@ module Ransack
|
|
75
71
|
describe '#sort_link' do
|
76
72
|
it 'sort_link for ransack attribute' do
|
77
73
|
sort_link = @f.sort_link :name, :controller => 'people'
|
78
|
-
|
79
|
-
expect(sort_link).to match /people\?q%5Bs%5D=name\+asc/
|
80
|
-
else
|
81
|
-
expect(sort_link).to match /people\?q(%5B|\[)s(%5D|\])=name\+asc/
|
82
|
-
end
|
74
|
+
expect(sort_link).to match /people\?q(%5B|\[)s(%5D|\])=name\+asc/
|
83
75
|
expect(sort_link).to match /sort_link/
|
84
76
|
expect(sort_link).to match /Full Name<\/a>/
|
85
77
|
end
|
@@ -171,11 +163,7 @@ module Ransack
|
|
171
163
|
# Starting from Rails 4.2, the date_select html attributes are no longer
|
172
164
|
# `sort`ed (for a speed gain), so the tests have to be different:
|
173
165
|
def date_select_html(val)
|
174
|
-
|
175
|
-
%(<option value="#{val}" selected="selected">#{val}</option>)
|
176
|
-
else
|
177
|
-
%(<option selected="selected" value="#{val}">#{val}</option>)
|
178
|
-
end
|
166
|
+
%(<option value="#{val}" selected="selected">#{val}</option>)
|
179
167
|
end
|
180
168
|
|
181
169
|
end
|
@@ -30,15 +30,7 @@ module Ransack
|
|
30
30
|
controller: 'people'
|
31
31
|
)
|
32
32
|
}
|
33
|
-
it {
|
34
|
-
should match(
|
35
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
36
|
-
/people\?q%5Bs%5D=name\+asc/
|
37
|
-
else
|
38
|
-
/people\?q(%5B|\[)s(%5D|\])=name\+asc/
|
39
|
-
end
|
40
|
-
)
|
41
|
-
}
|
33
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=name\+asc/ }
|
42
34
|
it { should match /sort_link desc/ }
|
43
35
|
it { should match /Full Name ▼/ }
|
44
36
|
end
|
@@ -51,15 +43,7 @@ module Ransack
|
|
51
43
|
controller: 'people'
|
52
44
|
)
|
53
45
|
}
|
54
|
-
it {
|
55
|
-
should match(
|
56
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
57
|
-
/people\?q%5Bs%5D=name\+asc/
|
58
|
-
else
|
59
|
-
/people\?q(%5B|\[)s(%5D|\])=name\+asc/
|
60
|
-
end
|
61
|
-
)
|
62
|
-
}
|
46
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=name\+asc/ }
|
63
47
|
end
|
64
48
|
|
65
49
|
describe '#sort_link with default search_key defined as symbol' do
|
@@ -69,15 +53,7 @@ module Ransack
|
|
69
53
|
:name, controller: 'people'
|
70
54
|
)
|
71
55
|
}
|
72
|
-
it {
|
73
|
-
should match(
|
74
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
75
|
-
/people\?people_search%5Bs%5D=name\+asc/
|
76
|
-
else
|
77
|
-
/people\?people_search(%5B|\[)s(%5D|\])=name\+asc/
|
78
|
-
end
|
79
|
-
)
|
80
|
-
}
|
56
|
+
it { should match /people\?people_search(%5B|\[)s(%5D|\])=name\+asc/ }
|
81
57
|
end
|
82
58
|
|
83
59
|
describe '#sort_url with default search_key defined as symbol' do
|
@@ -87,15 +63,7 @@ module Ransack
|
|
87
63
|
:name, controller: 'people'
|
88
64
|
)
|
89
65
|
}
|
90
|
-
it {
|
91
|
-
should match(
|
92
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
93
|
-
/people\?people_search%5Bs%5D=name\+asc/
|
94
|
-
else
|
95
|
-
/people\?people_search(%5B|\[)s(%5D|\])=name\+asc/
|
96
|
-
end
|
97
|
-
)
|
98
|
-
}
|
66
|
+
it { should match /people\?people_search(%5B|\[)s(%5D|\])=name\+asc/ }
|
99
67
|
end
|
100
68
|
|
101
69
|
describe '#sort_link desc through association table defined as symbol' do
|
@@ -106,15 +74,7 @@ module Ransack
|
|
106
74
|
controller: 'people'
|
107
75
|
)
|
108
76
|
}
|
109
|
-
it {
|
110
|
-
should match(
|
111
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
112
|
-
/people\?q%5Bs%5D=comments.body\+desc/
|
113
|
-
else
|
114
|
-
/people\?q(%5B|\[)s(%5D|\])=comments.body\+desc/
|
115
|
-
end
|
116
|
-
)
|
117
|
-
}
|
77
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=comments.body\+desc/ }
|
118
78
|
it { should match /sort_link asc/ }
|
119
79
|
it { should match /Body ▲/ }
|
120
80
|
end
|
@@ -127,15 +87,7 @@ module Ransack
|
|
127
87
|
controller: 'people'
|
128
88
|
)
|
129
89
|
}
|
130
|
-
it {
|
131
|
-
should match(
|
132
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
133
|
-
/people\?q%5Bs%5D=comments.body\+desc/
|
134
|
-
else
|
135
|
-
/people\?q(%5B|\[)s(%5D|\])=comments.body\+desc/
|
136
|
-
end
|
137
|
-
)
|
138
|
-
}
|
90
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=comments.body\+desc/ }
|
139
91
|
end
|
140
92
|
|
141
93
|
describe '#sort_link through association table defined as a string' do
|
@@ -146,15 +98,7 @@ module Ransack
|
|
146
98
|
controller: 'people'
|
147
99
|
)
|
148
100
|
}
|
149
|
-
it {
|
150
|
-
should match(
|
151
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
152
|
-
/people\?q%5Bs%5D=comments.body\+asc/
|
153
|
-
else
|
154
|
-
/people\?q(%5B|\[)s(%5D|\])=comments.body\+asc/
|
155
|
-
end
|
156
|
-
)
|
157
|
-
}
|
101
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=comments.body\+asc/ }
|
158
102
|
it { should match /sort_link desc/ }
|
159
103
|
it { should match /Comments.body ▼/ }
|
160
104
|
end
|
@@ -167,15 +111,7 @@ module Ransack
|
|
167
111
|
controller: 'people'
|
168
112
|
)
|
169
113
|
}
|
170
|
-
it {
|
171
|
-
should match(
|
172
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
173
|
-
/people\?q%5Bs%5D=comments.body\+asc/
|
174
|
-
else
|
175
|
-
/people\?q(%5B|\[)s(%5D|\])=comments.body\+asc/
|
176
|
-
end
|
177
|
-
)
|
178
|
-
}
|
114
|
+
it { should match /people\?q(%5B|\[)s(%5D|\])=comments.body\+asc/ }
|
179
115
|
end
|
180
116
|
|
181
117
|
describe '#sort_link works even if search params are a blank string' do
|
@@ -214,15 +150,7 @@ module Ransack
|
|
214
150
|
controller: 'people'
|
215
151
|
)
|
216
152
|
}
|
217
|
-
it {
|
218
|
-
should match(
|
219
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
220
|
-
/people\?people_search%5Bs%5D=name\+asc/
|
221
|
-
else
|
222
|
-
/people\?people_search(%5B|\[)s(%5D|\])=name\+asc/
|
223
|
-
end
|
224
|
-
)
|
225
|
-
}
|
153
|
+
it { should match /people\?people_search(%5B|\[)s(%5D|\])=name\+asc/ }
|
226
154
|
end
|
227
155
|
|
228
156
|
describe '#sort_link with default_order defined with a string key' do
|
@@ -487,15 +415,7 @@ module Ransack
|
|
487
415
|
controller: 'notes'
|
488
416
|
)
|
489
417
|
}
|
490
|
-
it {
|
491
|
-
should match(
|
492
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
493
|
-
/notes\?q%5Bs%5D=notable_of_Person_type_name\+asc/
|
494
|
-
else
|
495
|
-
/notes\?q(%5B|\[)s(%5D|\])=notable_of_Person_type_name\+asc/
|
496
|
-
end
|
497
|
-
)
|
498
|
-
}
|
418
|
+
it { should match /notes\?q(%5B|\[)s(%5D|\])=notable_of_Person_type_name\+asc/ }
|
499
419
|
it { should match /sort_link/ }
|
500
420
|
it { should match /Notable/ }
|
501
421
|
end
|
@@ -508,15 +428,7 @@ module Ransack
|
|
508
428
|
controller: 'notes'
|
509
429
|
)
|
510
430
|
}
|
511
|
-
it {
|
512
|
-
should match(
|
513
|
-
if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
|
514
|
-
/notes\?q%5Bs%5D=notable_of_Person_type_name\+asc/
|
515
|
-
else
|
516
|
-
/notes\?q(%5B|\[)s(%5D|\])=notable_of_Person_type_name\+asc/
|
517
|
-
end
|
518
|
-
)
|
519
|
-
}
|
431
|
+
it { should match /notes\?q(%5B|\[)s(%5D|\])=notable_of_Person_type_name\+asc/ }
|
520
432
|
end
|
521
433
|
|
522
434
|
context 'view has existing parameters' do
|
@@ -3,12 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Polyamorous
|
4
4
|
describe JoinAssociation do
|
5
5
|
|
6
|
-
join_base, join_association_args, polymorphic =
|
7
|
-
if ActiveRecord::VERSION::STRING >= '4.1'
|
8
|
-
[:join_root, 'parent.children', 'reflection.options[:polymorphic]']
|
9
|
-
else
|
10
|
-
[:join_base, 'join_dependency, parent', 'options[:polymorphic]']
|
11
|
-
end
|
6
|
+
join_base, join_association_args, polymorphic = [:join_root, 'parent.children', 'reflection.options[:polymorphic]']
|
12
7
|
|
13
8
|
let(:join_dependency) { new_join_dependency Note, {} }
|
14
9
|
let(:reflection) { Note.reflect_on_association(:notable) }
|
@@ -3,12 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Polyamorous
|
4
4
|
describe JoinDependency do
|
5
5
|
|
6
|
-
method, join_associations, join_base =
|
7
|
-
if ActiveRecord::VERSION::STRING >= '4.1'
|
8
|
-
[:instance_eval, 'join_root.drop(1)', :join_root]
|
9
|
-
else
|
10
|
-
[:send, 'join_associations', :join_base]
|
11
|
-
end
|
6
|
+
method, join_associations, join_base = :instance_eval, 'join_root.drop(1)', :join_root
|
12
7
|
|
13
8
|
context 'with symbol joins' do
|
14
9
|
subject { new_join_dependency Person, articles: :comments }
|
data/spec/ransack/search_spec.rb
CHANGED
@@ -232,8 +232,8 @@ module Ransack
|
|
232
232
|
# https://github.com/activerecord-hackery/ransack/issues/374
|
233
233
|
#
|
234
234
|
it 'evaluates conditions for multiple `belongs_to` associations to the
|
235
|
-
same table contextually'
|
236
|
-
|
235
|
+
same table contextually' do
|
236
|
+
skip "Make this spec pass for Rails >5.0"
|
237
237
|
s = Search.new(
|
238
238
|
Recommendation,
|
239
239
|
person_name_eq: 'Ernie',
|
data/spec/support/schema.rb
CHANGED
@@ -25,26 +25,12 @@ else
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class Person < ActiveRecord::Base
|
28
|
-
|
29
|
-
default_scope order('id DESC')
|
30
|
-
else
|
31
|
-
default_scope { order(id: :desc) }
|
32
|
-
end
|
28
|
+
default_scope { order(id: :desc) }
|
33
29
|
belongs_to :parent, class_name: 'Person', foreign_key: :parent_id
|
34
30
|
has_many :children, class_name: 'Person', foreign_key: :parent_id
|
35
31
|
has_many :articles
|
36
|
-
|
37
|
-
if RUBY_VERSION >= '2.3'
|
38
|
-
has_many :published_articles, class_name: "Article",
|
39
|
-
conditions: "published = 't'"
|
40
|
-
else
|
41
|
-
has_many :published_articles, class_name: "Article",
|
42
|
-
conditions: { published: true }
|
43
|
-
end
|
44
|
-
else
|
45
|
-
has_many :published_articles, ->{ where(published: true) },
|
32
|
+
has_many :published_articles, ->{ where(published: true) },
|
46
33
|
class_name: "Article"
|
47
|
-
end
|
48
34
|
has_many :comments
|
49
35
|
has_many :authored_article_comments, through: :articles,
|
50
36
|
source: :comments, foreign_key: :person_id
|
@@ -144,11 +130,7 @@ class Article < ActiveRecord::Base
|
|
144
130
|
|
145
131
|
alias_attribute :content, :body
|
146
132
|
|
147
|
-
|
148
|
-
default_scope { where("'default_scope' = 'default_scope'") }
|
149
|
-
else # Rails 3.0 does not accept a block
|
150
|
-
default_scope where("'default_scope' = 'default_scope'")
|
151
|
-
end
|
133
|
+
default_scope { where("'default_scope' = 'default_scope'") }
|
152
134
|
end
|
153
135
|
|
154
136
|
class Recommendation < ActiveRecord::Base
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: actionpack
|
@@ -19,60 +19,42 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
23
|
-
- - "<"
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: '5.2'
|
22
|
+
version: '5.0'
|
26
23
|
type: :runtime
|
27
24
|
prerelease: false
|
28
25
|
version_requirements: !ruby/object:Gem::Requirement
|
29
26
|
requirements:
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
- - "<"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '5.2'
|
29
|
+
version: '5.0'
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: activerecord
|
38
32
|
requirement: !ruby/object:Gem::Requirement
|
39
33
|
requirements:
|
40
34
|
- - ">="
|
41
35
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
43
|
-
- - "<"
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '5.2'
|
36
|
+
version: '5.0'
|
46
37
|
type: :runtime
|
47
38
|
prerelease: false
|
48
39
|
version_requirements: !ruby/object:Gem::Requirement
|
49
40
|
requirements:
|
50
41
|
- - ">="
|
51
42
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
53
|
-
- - "<"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '5.2'
|
43
|
+
version: '5.0'
|
56
44
|
- !ruby/object:Gem::Dependency
|
57
45
|
name: activesupport
|
58
46
|
requirement: !ruby/object:Gem::Requirement
|
59
47
|
requirements:
|
60
48
|
- - ">="
|
61
49
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
63
|
-
- - "<"
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '5.2'
|
50
|
+
version: '5.0'
|
66
51
|
type: :runtime
|
67
52
|
prerelease: false
|
68
53
|
version_requirements: !ruby/object:Gem::Requirement
|
69
54
|
requirements:
|
70
55
|
- - ">="
|
71
56
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
73
|
-
- - "<"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5.2'
|
57
|
+
version: '5.0'
|
76
58
|
- !ruby/object:Gem::Dependency
|
77
59
|
name: i18n
|
78
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,33 +187,20 @@ files:
|
|
205
187
|
- README.md
|
206
188
|
- Rakefile
|
207
189
|
- lib/polyamorous.rb
|
208
|
-
- lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_association.rb
|
209
|
-
- lib/polyamorous/activerecord_3_and_4.0_ruby_1.9/join_dependency.rb
|
210
|
-
- lib/polyamorous/activerecord_4.1_ruby_1.9/join_association.rb
|
211
|
-
- lib/polyamorous/activerecord_4.1_ruby_1.9/join_dependency.rb
|
212
|
-
- lib/polyamorous/activerecord_4.1_ruby_2/join_association.rb
|
213
|
-
- lib/polyamorous/activerecord_4.1_ruby_2/join_dependency.rb
|
214
|
-
- lib/polyamorous/activerecord_4.1_ruby_2/make_polyamorous_inner_joins.rb
|
215
|
-
- lib/polyamorous/activerecord_4.2_ruby_1.9/join_association.rb
|
216
|
-
- lib/polyamorous/activerecord_4.2_ruby_1.9/join_dependency.rb
|
217
|
-
- lib/polyamorous/activerecord_4.2_ruby_2/join_association.rb
|
218
|
-
- lib/polyamorous/activerecord_4.2_ruby_2/join_dependency.rb
|
219
190
|
- lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb
|
220
191
|
- lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb
|
221
192
|
- lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb
|
222
193
|
- lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb
|
223
194
|
- lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb
|
224
195
|
- lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb
|
196
|
+
- lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb
|
197
|
+
- lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb
|
225
198
|
- lib/polyamorous/join.rb
|
226
199
|
- lib/polyamorous/swapping_reflection_class.rb
|
227
200
|
- lib/polyamorous/tree_node.rb
|
228
201
|
- lib/ransack.rb
|
229
202
|
- lib/ransack/adapters.rb
|
230
203
|
- lib/ransack/adapters/active_record.rb
|
231
|
-
- lib/ransack/adapters/active_record/3.0/compat.rb
|
232
|
-
- lib/ransack/adapters/active_record/3.0/context.rb
|
233
|
-
- lib/ransack/adapters/active_record/3.1/context.rb
|
234
|
-
- lib/ransack/adapters/active_record/3.2/context.rb
|
235
204
|
- lib/ransack/adapters/active_record/base.rb
|
236
205
|
- lib/ransack/adapters/active_record/compat.rb
|
237
206
|
- lib/ransack/adapters/active_record/context.rb
|
@@ -240,20 +209,6 @@ files:
|
|
240
209
|
- lib/ransack/adapters/active_record/ransack/nodes/condition.rb
|
241
210
|
- lib/ransack/adapters/active_record/ransack/translate.rb
|
242
211
|
- lib/ransack/adapters/active_record/ransack/visitor.rb
|
243
|
-
- lib/ransack/adapters/mongoid.rb
|
244
|
-
- lib/ransack/adapters/mongoid/3.2/.gitkeep
|
245
|
-
- lib/ransack/adapters/mongoid/attributes/attribute.rb
|
246
|
-
- lib/ransack/adapters/mongoid/attributes/order_predications.rb
|
247
|
-
- lib/ransack/adapters/mongoid/attributes/predications.rb
|
248
|
-
- lib/ransack/adapters/mongoid/base.rb
|
249
|
-
- lib/ransack/adapters/mongoid/context.rb
|
250
|
-
- lib/ransack/adapters/mongoid/inquiry_hash.rb
|
251
|
-
- lib/ransack/adapters/mongoid/ransack/constants.rb
|
252
|
-
- lib/ransack/adapters/mongoid/ransack/context.rb
|
253
|
-
- lib/ransack/adapters/mongoid/ransack/nodes/condition.rb
|
254
|
-
- lib/ransack/adapters/mongoid/ransack/translate.rb
|
255
|
-
- lib/ransack/adapters/mongoid/ransack/visitor.rb
|
256
|
-
- lib/ransack/adapters/mongoid/table.rb
|
257
212
|
- lib/ransack/configuration.rb
|
258
213
|
- lib/ransack/constants.rb
|
259
214
|
- lib/ransack/context.rb
|
@@ -301,23 +256,9 @@ files:
|
|
301
256
|
- spec/console.rb
|
302
257
|
- spec/helpers/polyamorous_helper.rb
|
303
258
|
- spec/helpers/ransack_helper.rb
|
304
|
-
- spec/mongoid/adapters/mongoid/base_spec.rb
|
305
|
-
- spec/mongoid/adapters/mongoid/context_spec.rb
|
306
|
-
- spec/mongoid/configuration_spec.rb
|
307
|
-
- spec/mongoid/dependencies_spec.rb
|
308
|
-
- spec/mongoid/helpers/ransack_helper.rb
|
309
|
-
- spec/mongoid/nodes/condition_spec.rb
|
310
|
-
- spec/mongoid/nodes/grouping_spec.rb
|
311
|
-
- spec/mongoid/predicate_spec.rb
|
312
|
-
- spec/mongoid/search_spec.rb
|
313
|
-
- spec/mongoid/support/mongoid.yml
|
314
|
-
- spec/mongoid/support/schema.rb
|
315
|
-
- spec/mongoid/translate_spec.rb
|
316
|
-
- spec/mongoid_spec_helper.rb
|
317
259
|
- spec/ransack/adapters/active_record/base_spec.rb
|
318
260
|
- spec/ransack/adapters/active_record/context_spec.rb
|
319
261
|
- spec/ransack/configuration_spec.rb
|
320
|
-
- spec/ransack/dependencies_spec.rb
|
321
262
|
- spec/ransack/helpers/form_builder_spec.rb
|
322
263
|
- spec/ransack/helpers/form_helper_spec.rb
|
323
264
|
- spec/ransack/join_association_spec.rb
|
@@ -364,23 +305,9 @@ test_files:
|
|
364
305
|
- spec/console.rb
|
365
306
|
- spec/helpers/polyamorous_helper.rb
|
366
307
|
- spec/helpers/ransack_helper.rb
|
367
|
-
- spec/mongoid/adapters/mongoid/base_spec.rb
|
368
|
-
- spec/mongoid/adapters/mongoid/context_spec.rb
|
369
|
-
- spec/mongoid/configuration_spec.rb
|
370
|
-
- spec/mongoid/dependencies_spec.rb
|
371
|
-
- spec/mongoid/helpers/ransack_helper.rb
|
372
|
-
- spec/mongoid/nodes/condition_spec.rb
|
373
|
-
- spec/mongoid/nodes/grouping_spec.rb
|
374
|
-
- spec/mongoid/predicate_spec.rb
|
375
|
-
- spec/mongoid/search_spec.rb
|
376
|
-
- spec/mongoid/support/mongoid.yml
|
377
|
-
- spec/mongoid/support/schema.rb
|
378
|
-
- spec/mongoid/translate_spec.rb
|
379
|
-
- spec/mongoid_spec_helper.rb
|
380
308
|
- spec/ransack/adapters/active_record/base_spec.rb
|
381
309
|
- spec/ransack/adapters/active_record/context_spec.rb
|
382
310
|
- spec/ransack/configuration_spec.rb
|
383
|
-
- spec/ransack/dependencies_spec.rb
|
384
311
|
- spec/ransack/helpers/form_builder_spec.rb
|
385
312
|
- spec/ransack/helpers/form_helper_spec.rb
|
386
313
|
- spec/ransack/join_association_spec.rb
|