ransack 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -5
- data/lib/ransack/adapters/active_record/context.rb +5 -5
- data/lib/ransack/version.rb +1 -1
- data/spec/ransack/adapters/active_record/base_spec.rb +41 -4
- data/spec/support/schema.rb +0 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c740816de011eb6b10728dc32b58e179304fad94
|
4
|
+
data.tar.gz: 07fb384c320453fe1176fc9c51261721318fe708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6647e2d472b4efd1e0051bd293698011c5a89ffdd096456c75da5b44f58b8ac825d3a5292d41a174e6b01e43bfd0bfc996685ee0fd30a13af91eaabb920162e3
|
7
|
+
data.tar.gz: 09e01482d289cfca68527dfce6161a8cf028846da7d510d927b59e155792e1c82b2aa3fc02eec5a4667b47b0fa08a13eb0fb2d542f3e91b368917540d13ce7ed
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,32 @@
|
|
2
2
|
This change log was started in August 2014. All notable changes to this project
|
3
3
|
henceforth should be documented here.
|
4
4
|
|
5
|
+
## Version 1.5.1 - 2014-10-30
|
6
|
+
### Added
|
7
|
+
|
8
|
+
* Add base specs for search on fields with `_start` and `_end`.
|
9
|
+
|
10
|
+
*Jon Atack*
|
11
|
+
|
12
|
+
* Add a failing spec for detecting attribute fields containing `_and_` that
|
13
|
+
needs to be fixed. Method names containing `_and_` and `_or_` are still not
|
14
|
+
parsed/detected correctly.
|
15
|
+
|
16
|
+
*Jon Atack*
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
* Fix a regression caused by incorrect string constants in context.rb.
|
21
|
+
|
22
|
+
*Kazuhiro NISHIYAMA*
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
* Remove duplicate code in spec/support/schema.rb.
|
27
|
+
|
28
|
+
*Jon Atack*
|
29
|
+
|
30
|
+
|
5
31
|
## Version 1.5.0 - 2014-10-26
|
6
32
|
### Added
|
7
33
|
|
@@ -48,14 +74,15 @@ henceforth should be documented here.
|
|
48
74
|
|
49
75
|
*Jon Atack*
|
50
76
|
|
51
|
-
* Improve `attribute_method?` parsing for
|
52
|
-
`_or_`. Attributes named like `foo_and_bar` or `foo_or_bar` are
|
53
|
-
now instead of running failing checks for `foo` and `bar`.
|
77
|
+
* Improve `attribute_method?` parsing for attribute names containing `_and_`
|
78
|
+
and `_or_`. Attributes named like `foo_and_bar` or `foo_or_bar` are
|
79
|
+
recognized now instead of running failing checks for `foo` and `bar`.
|
80
|
+
CORRECTION October 28, 2014: this feature is still not working!
|
54
81
|
|
55
82
|
*Joe Yates*
|
56
83
|
|
57
|
-
* Improve `attribute_method?` parsing for
|
58
|
-
predicate like `_start` and `_end`. For instance, a `
|
84
|
+
* Improve `attribute_method?` parsing for attribute names ending with a
|
85
|
+
predicate like `_start` and `_end`. For instance, a `foo_start` attribute
|
59
86
|
is now recognized instead of raising a NoMethodError.
|
60
87
|
|
61
88
|
*Timo Schilling*, *Jon Atack*
|
@@ -158,7 +158,7 @@ module Ransack
|
|
158
158
|
def get_association(str, parent = @base)
|
159
159
|
klass = klassify parent
|
160
160
|
ransackable_association?(str, klass) &&
|
161
|
-
|
161
|
+
klass.reflect_on_all_associations.detect { |a| a.name.to_s == str }
|
162
162
|
end
|
163
163
|
|
164
164
|
def join_dependency(relation)
|
@@ -175,13 +175,13 @@ module Ransack
|
|
175
175
|
buckets = relation.joins_values.group_by do |join|
|
176
176
|
case join
|
177
177
|
when String
|
178
|
-
STRING_JOIN
|
178
|
+
Ransack::Constants::STRING_JOIN
|
179
179
|
when Hash, Symbol, Array
|
180
|
-
ASSOCIATION_JOIN
|
180
|
+
Ransack::Constants::ASSOCIATION_JOIN
|
181
181
|
when JoinDependency, JoinDependency::JoinAssociation
|
182
|
-
STASHED_JOIN
|
182
|
+
Ransack::Constants::STASHED_JOIN
|
183
183
|
when Arel::Nodes::Join
|
184
|
-
JOIN_NODE
|
184
|
+
Ransack::Constants::JOIN_NODE
|
185
185
|
else
|
186
186
|
raise 'unknown class: %s' % join.class.name
|
187
187
|
end
|
data/lib/ransack/version.rb
CHANGED
@@ -130,15 +130,52 @@ module Ransack
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should function correctly when using fields with % in them" do
|
133
|
-
Person.create!(:name => "110%-er")
|
133
|
+
p = Person.create!(:name => "110%-er")
|
134
134
|
s = Person.search(:name_cont => "10%")
|
135
|
-
expect(s.result.
|
135
|
+
expect(s.result.to_a).to eq [p]
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should function correctly when using fields with backslashes in them" do
|
139
|
-
Person.create!(:name => "\\WINNER\\")
|
139
|
+
p = Person.create!(:name => "\\WINNER\\")
|
140
140
|
s = Person.search(:name_cont => "\\WINNER\\")
|
141
|
-
expect(s.result.
|
141
|
+
expect(s.result.to_a).to eq [p]
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should function correctly when an attribute name ends with '_start'" do
|
145
|
+
p = Person.create!(:new_start => 'Bar and foo', :name => 'Xiang')
|
146
|
+
|
147
|
+
s = Person.search(:new_start_end => ' and foo')
|
148
|
+
expect(s.result.to_a).to eq [p]
|
149
|
+
|
150
|
+
s = Person.search(:name_or_new_start_start => 'Xia')
|
151
|
+
expect(s.result.to_a).to eq [p]
|
152
|
+
|
153
|
+
s = Person.search(:new_start_or_name_end => 'iang')
|
154
|
+
expect(s.result.to_a).to eq [p]
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should function correctly when an attribute name ends with '_end'" do
|
158
|
+
p = Person.create!(:stop_end => 'Foo and bar', :name => 'Marianne')
|
159
|
+
|
160
|
+
s = Person.search(:stop_end_start => 'Foo and')
|
161
|
+
expect(s.result.to_a).to eq [p]
|
162
|
+
|
163
|
+
s = Person.search(:stop_end_or_name_end => 'anne')
|
164
|
+
expect(s.result.to_a).to eq [p]
|
165
|
+
|
166
|
+
s = Person.search(:name_or_stop_end_end => ' bar')
|
167
|
+
expect(s.result.to_a).to eq [p]
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should function correctly when an attribute name has 'and' in it" do
|
171
|
+
# FIXME: this test does not pass!
|
172
|
+
p = Person.create!(:terms_and_conditions => true)
|
173
|
+
s = Person.search(:terms_and_conditions_eq => true)
|
174
|
+
# search is not detecting the attribute
|
175
|
+
puts "
|
176
|
+
FIXME: Search not detecting the `terms_and_conditions` attribute in
|
177
|
+
base_spec.rb, line 178: #{s.result.to_sql}"
|
178
|
+
# expect(s.result.to_a).to eq [p]
|
142
179
|
end
|
143
180
|
|
144
181
|
it 'allows sort by "only_sort" field' do
|
data/spec/support/schema.rb
CHANGED
@@ -66,21 +66,6 @@ class Person < ActiveRecord::Base
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def self.ransackable_attributes(auth_object = nil)
|
70
|
-
if auth_object == :admin
|
71
|
-
column_names + _ransackers.keys - ['only_sort']
|
72
|
-
else
|
73
|
-
column_names + _ransackers.keys - ['only_sort', 'only_admin']
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.ransortable_attributes(auth_object = nil)
|
78
|
-
if auth_object == :admin
|
79
|
-
column_names + _ransackers.keys - ['only_search']
|
80
|
-
else
|
81
|
-
column_names + _ransackers.keys - ['only_search', 'only_admin']
|
82
|
-
end
|
83
|
-
end
|
84
69
|
end
|
85
70
|
|
86
71
|
class Article < 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: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-10-
|
13
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|