searchlogic 2.5.6 → 2.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +12 -12
- data/VERSION.yml +3 -3
- data/lib/searchlogic/search/method_missing.rb +1 -5
- data/searchlogic.gemspec +9 -23
- data/spec/searchlogic/search_spec.rb +82 -74
- data/spec/spec_helper.rb +0 -1
- metadata +35 -53
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activerecord (2.3.
|
5
|
-
activesupport (= 2.3.
|
6
|
-
activesupport (2.3.
|
4
|
+
activerecord (2.3.12)
|
5
|
+
activesupport (= 2.3.12)
|
6
|
+
activesupport (2.3.12)
|
7
7
|
archive-tar-minitar (0.5.2)
|
8
|
-
columnize (0.3.
|
8
|
+
columnize (0.3.4)
|
9
9
|
git (1.2.5)
|
10
|
-
jeweler (1.
|
11
|
-
bundler (~> 1.0
|
10
|
+
jeweler (1.6.4)
|
11
|
+
bundler (~> 1.0)
|
12
12
|
git (>= 1.2.5)
|
13
13
|
rake
|
14
|
-
linecache19 (0.5.
|
14
|
+
linecache19 (0.5.12)
|
15
15
|
ruby_core_source (>= 0.1.4)
|
16
|
-
rake (0.
|
16
|
+
rake (0.9.2)
|
17
17
|
rspec (1.3.1)
|
18
|
-
ruby-debug-base19 (0.11.
|
18
|
+
ruby-debug-base19 (0.11.25)
|
19
19
|
columnize (>= 0.3.1)
|
20
20
|
linecache19 (>= 0.5.11)
|
21
21
|
ruby_core_source (>= 0.1.4)
|
@@ -23,15 +23,15 @@ GEM
|
|
23
23
|
columnize (>= 0.3.1)
|
24
24
|
linecache19 (>= 0.5.11)
|
25
25
|
ruby-debug-base19 (>= 0.11.19)
|
26
|
-
ruby_core_source (0.1.
|
26
|
+
ruby_core_source (0.1.5)
|
27
27
|
archive-tar-minitar (>= 0.5.2)
|
28
|
-
sqlite3 (1.3.
|
28
|
+
sqlite3 (1.3.4)
|
29
29
|
|
30
30
|
PLATFORMS
|
31
31
|
ruby
|
32
32
|
|
33
33
|
DEPENDENCIES
|
34
|
-
activerecord (~> 2.3.
|
34
|
+
activerecord (~> 2.3.12)
|
35
35
|
jeweler
|
36
36
|
rspec (= 1.3.1)
|
37
37
|
ruby-debug19
|
data/VERSION.yml
CHANGED
@@ -101,11 +101,7 @@ module Searchlogic
|
|
101
101
|
|
102
102
|
if Time.zone && casted_value.is_a?(Time)
|
103
103
|
if value.is_a?(String)
|
104
|
-
|
105
|
-
casted_value.utc
|
106
|
-
else
|
107
|
-
(casted_value + (Time.zone.utc_offset * -1)).in_time_zone
|
108
|
-
end
|
104
|
+
(casted_value + (Time.zone.utc_offset * -1)).in_time_zone
|
109
105
|
else
|
110
106
|
if options[:skip_conversion]
|
111
107
|
casted_value.utc
|
data/searchlogic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{searchlogic}
|
8
|
-
s.version = "2.5.
|
8
|
+
s.version = "2.5.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Johnson of Binary Logic"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-14}
|
13
13
|
s.description = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
|
14
14
|
s.email = %q{bjohnson@binarylogic.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -65,36 +65,22 @@ Gem::Specification.new do |s|
|
|
65
65
|
]
|
66
66
|
s.homepage = %q{http://github.com/binarylogic/searchlogic}
|
67
67
|
s.require_paths = ["lib"]
|
68
|
-
s.rubygems_version = %q{1.
|
68
|
+
s.rubygems_version = %q{1.6.2}
|
69
69
|
s.summary = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
|
70
|
-
s.test_files = [
|
71
|
-
"spec/searchlogic/active_record/association_proxy_spec.rb",
|
72
|
-
"spec/searchlogic/active_record/consistency_spec.rb",
|
73
|
-
"spec/searchlogic/core_ext/object_spec.rb",
|
74
|
-
"spec/searchlogic/core_ext/proc_spec.rb",
|
75
|
-
"spec/searchlogic/named_scopes/alias_scope_spec.rb",
|
76
|
-
"spec/searchlogic/named_scopes/association_conditions_spec.rb",
|
77
|
-
"spec/searchlogic/named_scopes/association_ordering_spec.rb",
|
78
|
-
"spec/searchlogic/named_scopes/column_conditions_spec.rb",
|
79
|
-
"spec/searchlogic/named_scopes/or_conditions_spec.rb",
|
80
|
-
"spec/searchlogic/named_scopes/ordering_spec.rb",
|
81
|
-
"spec/searchlogic/search_spec.rb",
|
82
|
-
"spec/spec_helper.rb"
|
83
|
-
]
|
84
70
|
|
85
71
|
if s.respond_to? :specification_version then
|
86
72
|
s.specification_version = 3
|
87
73
|
|
88
74
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
89
|
-
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.
|
90
|
-
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.
|
75
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.12"])
|
76
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.12"])
|
91
77
|
else
|
92
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.
|
93
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.
|
78
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
79
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
94
80
|
end
|
95
81
|
else
|
96
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.
|
97
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.
|
82
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
83
|
+
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
98
84
|
end
|
99
85
|
end
|
100
86
|
|
@@ -6,11 +6,11 @@ describe Searchlogic::Search do
|
|
6
6
|
it "should create a search proxy" do
|
7
7
|
User.search(:username => "joe").should be_kind_of(Searchlogic::Search)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should create a search proxy using the same class" do
|
11
11
|
User.search.klass.should == User
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should pass on the current scope to the proxy" do
|
15
15
|
company = Company.create
|
16
16
|
user = company.users.create
|
@@ -19,18 +19,18 @@ describe Searchlogic::Search do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
context "#initialize" do
|
24
24
|
it "should require a class" do
|
25
25
|
lambda { Searchlogic::Search.new }.should raise_error(ArgumentError)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should set the conditions" do
|
29
29
|
search = User.search(:username => "bjohnson")
|
30
30
|
search.conditions.should == {:username => "bjohnson"}
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
context "#clone" do
|
35
35
|
it "should clone properly" do
|
36
36
|
company = Company.create
|
@@ -42,7 +42,7 @@ describe Searchlogic::Search do
|
|
42
42
|
search2.all.should == User.all
|
43
43
|
search1.all.should == [user2]
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "should clone properly without scope" do
|
47
47
|
user1 = User.create(:age => 5)
|
48
48
|
user2 = User.create(:age => 25)
|
@@ -53,20 +53,20 @@ describe Searchlogic::Search do
|
|
53
53
|
search1.all.should == [user2]
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
context "#conditions" do
|
58
58
|
it "should set the conditions and be accessible individually" do
|
59
59
|
search = User.search
|
60
60
|
search.conditions = {:username => "bjohnson"}
|
61
61
|
search.username.should == "bjohnson"
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should set the conditions and allow string keys" do
|
65
65
|
search = User.search
|
66
66
|
search.conditions = {"username" => "bjohnson"}
|
67
67
|
search.username.should == "bjohnson"
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should use custom scopes before normalizing" do
|
71
71
|
User.create(:username => "bjohnson")
|
72
72
|
User.named_scope :username, lambda { |value| {:conditions => {:username => value.reverse}} }
|
@@ -75,7 +75,7 @@ describe Searchlogic::Search do
|
|
75
75
|
search1.count.should == 0
|
76
76
|
search2.count.should == 1
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
# We ignore them upon execution. But we still want to accept the condition so that returning the conditions
|
80
80
|
# preserves the values.
|
81
81
|
it "should ignore blank values but still return on conditions" do
|
@@ -84,24 +84,24 @@ describe Searchlogic::Search do
|
|
84
84
|
search.username.should be_nil
|
85
85
|
search.conditions.should == {:username => ""}
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "should not ignore blank values and should not cast them" do
|
89
89
|
search = User.search
|
90
90
|
search.conditions = {"id_equals" => ""}
|
91
91
|
search.id_equals.should be_nil
|
92
92
|
search.conditions.should == {:id_equals => ""}
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it "should ignore blank values in arrays" do
|
96
96
|
search = User.search
|
97
97
|
search.conditions = {"username_equals_any" => [""]}
|
98
98
|
search.username_equals_any.should be_nil
|
99
|
-
|
99
|
+
|
100
100
|
search.conditions = {"id_equals_any" => ["", "1"]}
|
101
101
|
search.id_equals_any.should == [1]
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
context "#compact_conditions" do
|
106
106
|
it "should remove conditions with blank values" do
|
107
107
|
search = User.search
|
@@ -109,20 +109,20 @@ describe Searchlogic::Search do
|
|
109
109
|
search.compact_conditions.should == {:name_equals => "Ben"}
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
context "condition accessors" do
|
114
114
|
it "should allow setting exact columns individually" do
|
115
115
|
search = User.search
|
116
116
|
search.username = "bjohnson"
|
117
117
|
search.username.should == "bjohnson"
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
it "should allow setting local column conditions individually" do
|
121
121
|
search = User.search
|
122
122
|
search.username_gt = "bjohnson"
|
123
123
|
search.username_gt.should == "bjohnson"
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
it "should allow chaining conditions" do
|
127
127
|
user = User.create(:username => "bjohnson", :age => 20)
|
128
128
|
User.create(:username => "bjohnson", :age => 5)
|
@@ -130,27 +130,27 @@ describe Searchlogic::Search do
|
|
130
130
|
search.username_equals("bjohnson").age_gt(10)
|
131
131
|
search.all.should == [user]
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
it "should allow setting association conditions" do
|
135
135
|
search = User.search
|
136
136
|
search.orders_total_gt = 10
|
137
137
|
search.orders_total_gt.should == 10
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
it "should allow setting pre-existing association conditions" do
|
141
141
|
User.named_scope :uname, lambda { |value| {:conditions => ["users.username = ?", value]} }
|
142
142
|
search = Company.search
|
143
143
|
search.users_uname = "bjohnson"
|
144
144
|
search.users_uname.should == "bjohnson"
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
it "should allow setting pre-existing association alias conditions" do
|
148
148
|
User.alias_scope :username_has, lambda { |value| User.username_like(value) }
|
149
149
|
search = Company.search
|
150
150
|
search.users_username_has = "bjohnson"
|
151
151
|
search.users_username_has.should == "bjohnson"
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
it "should allow using custom conditions" do
|
155
155
|
User.named_scope(:four_year_olds, { :conditions => { :age => 4 } })
|
156
156
|
search = User.search
|
@@ -158,7 +158,7 @@ describe Searchlogic::Search do
|
|
158
158
|
search.four_year_olds.should == true
|
159
159
|
search.proxy_options.should == User.four_year_olds.proxy_options
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
it "should not merge conflicting conditions into one value" do
|
163
163
|
# This class should JUST be a proxy. It should not do anything more than that.
|
164
164
|
# A user would be allowed to call both named scopes if they wanted.
|
@@ -168,158 +168,165 @@ describe Searchlogic::Search do
|
|
168
168
|
search.username_greater_than.should == "bjohnson1"
|
169
169
|
search.username_gt.should == "bjohnson2"
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
it "should allow setting custom conditions individually with an arity of 0" do
|
173
173
|
User.named_scope(:four_year_olds, :conditions => {:age => 4})
|
174
174
|
search = User.search
|
175
175
|
search.four_year_olds = true
|
176
176
|
search.four_year_olds.should == true
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
it "should allow setting custom conditions individually with an arity of 1" do
|
180
180
|
User.named_scope(:username_should_be, lambda { |u| {:conditions => {:username => u}} })
|
181
181
|
search = User.search
|
182
182
|
search.username_should_be = "bjohnson"
|
183
183
|
search.username_should_be.should == "bjohnson"
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
it "should not allow setting conditions that are not scopes" do
|
187
187
|
search = User.search
|
188
188
|
lambda { search.unknown = true }.should raise_error(Searchlogic::Search::UnknownConditionError)
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
it "should not allow setting conditions on sensitive methods" do
|
192
192
|
search = User.search
|
193
193
|
lambda { search.destroy = true }.should raise_error(Searchlogic::Search::UnknownConditionError)
|
194
194
|
end
|
195
|
-
|
195
|
+
|
196
196
|
it "should not use the ruby implementation of the id method" do
|
197
197
|
search = User.search
|
198
198
|
search.id.should be_nil
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
context "type casting" do
|
202
202
|
it "should be a Boolean given true" do
|
203
203
|
search = User.search
|
204
204
|
search.id_nil = true
|
205
205
|
search.id_nil.should == true
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
it "should be a Boolean given 'true'" do
|
209
209
|
search = User.search
|
210
210
|
search.id_nil = "true"
|
211
211
|
search.id_nil.should == true
|
212
212
|
end
|
213
|
-
|
213
|
+
|
214
214
|
it "should be a Boolean given '1'" do
|
215
215
|
search = User.search
|
216
216
|
search.id_nil = "1"
|
217
217
|
search.id_nil.should == true
|
218
218
|
end
|
219
|
-
|
219
|
+
|
220
220
|
it "should be a Boolean given false" do
|
221
221
|
search = User.search
|
222
222
|
search.id_nil = false
|
223
223
|
search.id_nil.should == false
|
224
224
|
end
|
225
|
-
|
225
|
+
|
226
226
|
it "should be a Boolean given 'false'" do
|
227
227
|
search = User.search
|
228
228
|
search.id_nil = "false"
|
229
229
|
search.id_nil.should == false
|
230
230
|
end
|
231
|
-
|
231
|
+
|
232
232
|
it "should be a Boolean given '0'" do
|
233
233
|
search = User.search
|
234
234
|
search.id_nil = "0"
|
235
235
|
search.id_nil.should == false
|
236
236
|
end
|
237
|
-
|
237
|
+
|
238
238
|
it "should be an Integer given ''" do
|
239
239
|
search = User.search
|
240
240
|
search.id_gt = ''
|
241
241
|
search.id_gt.should == 0
|
242
242
|
end
|
243
|
-
|
243
|
+
|
244
244
|
it "should be an Integer given 1" do
|
245
245
|
search = User.search
|
246
246
|
search.id_gt = 1
|
247
247
|
search.id_gt.should == 1
|
248
248
|
end
|
249
|
-
|
249
|
+
|
250
250
|
it "should be an Integer given '1'" do
|
251
251
|
search = User.search
|
252
252
|
search.id_gt = "1"
|
253
253
|
search.id_gt.should == 1
|
254
254
|
end
|
255
|
-
|
255
|
+
|
256
256
|
it "should be a Float given 1.0" do
|
257
257
|
search = Order.search
|
258
258
|
search.total_gt = 1.0
|
259
259
|
search.total_gt.should == 1.0
|
260
260
|
end
|
261
|
-
|
261
|
+
|
262
262
|
it "should be a Float given '1'" do
|
263
263
|
search = Order.search
|
264
264
|
search.total_gt = "1"
|
265
265
|
search.total_gt.should == 1.0
|
266
266
|
end
|
267
|
-
|
267
|
+
|
268
268
|
it "should be a Float given '1.5'" do
|
269
269
|
search = Order.search
|
270
270
|
search.total_gt = "1.5"
|
271
271
|
search.total_gt.should == 1.5
|
272
272
|
end
|
273
|
-
|
273
|
+
|
274
274
|
it "should be a Range given 1..3" do
|
275
275
|
search = Order.search
|
276
276
|
search.total_eq = (1..3)
|
277
277
|
search.total_eq.should == (1..3)
|
278
278
|
end
|
279
|
-
|
279
|
+
|
280
280
|
it "should be a Date given 'Jan 1, 2009'" do
|
281
281
|
search = Order.search
|
282
282
|
search.shipped_on_after = "Jan 1, 2009"
|
283
283
|
search.shipped_on_after.should == Date.parse("Jan 1, 2009")
|
284
284
|
end
|
285
|
-
|
285
|
+
|
286
286
|
it "should be a Time given 'Jan 1, 2009'" do
|
287
287
|
search = Order.search
|
288
288
|
search.created_at_after = "Jan 1, 2009"
|
289
289
|
search.created_at_after.should == Time.zone.parse("Jan 1, 2009")
|
290
290
|
end
|
291
|
-
|
291
|
+
|
292
292
|
it "should be a Time given 'Jan 1, 2009 9:33AM'" do
|
293
293
|
search = Order.search
|
294
294
|
search.created_at_after = "Jan 1, 2009 9:33AM"
|
295
295
|
search.created_at_after.should == Time.zone.parse("Jan 1, 2009 9:33AM")
|
296
296
|
end
|
297
|
-
|
298
|
-
it "should
|
297
|
+
|
298
|
+
it "should still convert for strings, even if the conversion is skipped for the attribute" do
|
299
299
|
search = User.search
|
300
300
|
search.whatever_at_after = "Jan 1, 2009 9:33AM"
|
301
|
-
search.whatever_at_after.should == Time.parse("Jan 1, 2009 9:33AM")
|
301
|
+
search.whatever_at_after.should == Time.zone.parse("Jan 1, 2009 9:33AM")
|
302
302
|
end
|
303
|
-
|
303
|
+
|
304
304
|
it "should convert the time to the current zone" do
|
305
305
|
search = Order.search
|
306
306
|
now = Time.now
|
307
307
|
search.created_at_after = now
|
308
308
|
search.created_at_after.should == now.in_time_zone
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
|
+
it "should skip time zone conversion for attributes skipped" do
|
312
|
+
search = User.search
|
313
|
+
now = Time.now
|
314
|
+
search.whatever_at_after = now
|
315
|
+
search.whatever_at_after.should == now.utc
|
316
|
+
end
|
317
|
+
|
311
318
|
it "should be an Array and cast it's values given ['1', '2', '3']" do
|
312
319
|
search = Order.search
|
313
320
|
search.id_equals_any = ["1", "2", "3"]
|
314
321
|
search.id_equals_any.should == [1, 2, 3]
|
315
322
|
end
|
316
|
-
|
323
|
+
|
317
324
|
it "should type cast association conditions" do
|
318
325
|
search = User.search
|
319
326
|
search.orders_total_gt = "10"
|
320
327
|
search.orders_total_gt.should == 10
|
321
328
|
end
|
322
|
-
|
329
|
+
|
323
330
|
it "should type cast deep association conditions" do
|
324
331
|
search = Company.search
|
325
332
|
search.users_orders_total_gt = "10"
|
@@ -333,7 +340,7 @@ describe Searchlogic::Search do
|
|
333
340
|
end
|
334
341
|
end
|
335
342
|
end
|
336
|
-
|
343
|
+
|
337
344
|
context "#delete" do
|
338
345
|
it "should delete the condition" do
|
339
346
|
search = User.search(:username_like => "bjohnson")
|
@@ -342,55 +349,55 @@ describe Searchlogic::Search do
|
|
342
349
|
search.conditions["username_like"].should be_nil
|
343
350
|
end
|
344
351
|
end
|
345
|
-
|
352
|
+
|
346
353
|
context "#ordering_by" do
|
347
354
|
it "should return nil if we aren't ordering" do
|
348
355
|
search = User.search
|
349
356
|
search.ordering_by.should be_nil
|
350
357
|
end
|
351
|
-
|
358
|
+
|
352
359
|
it "should return the column name for ascending" do
|
353
360
|
search = User.search(:order => "ascend_by_first_name")
|
354
361
|
search.ordering_by.should == "first_name"
|
355
362
|
end
|
356
|
-
|
363
|
+
|
357
364
|
it "should return the column name for descending" do
|
358
365
|
search = User.search(:order => "descend_by_first_name")
|
359
366
|
search.ordering_by.should == "first_name"
|
360
367
|
end
|
361
|
-
|
368
|
+
|
362
369
|
it "should handle symbols" do
|
363
370
|
search = User.search(:order => :descend_by_first_name)
|
364
371
|
search.ordering_by.should == "first_name"
|
365
372
|
end
|
366
373
|
end
|
367
|
-
|
374
|
+
|
368
375
|
context "#method_missing" do
|
369
376
|
context "setting" do
|
370
377
|
it "should call named scopes for conditions" do
|
371
378
|
User.search(:age_less_than => 5).proxy_options.should == User.age_less_than(5).proxy_options
|
372
379
|
end
|
373
|
-
|
380
|
+
|
374
381
|
it "should alias exact column names to use equals" do
|
375
382
|
User.search(:username => "joe").proxy_options.should == User.username_equals("joe").proxy_options
|
376
383
|
end
|
377
|
-
|
384
|
+
|
378
385
|
it "should recognize conditions with a value of true where the named scope has an arity of 0" do
|
379
386
|
User.search(:username_nil => true).proxy_options.should == User.username_nil.proxy_options
|
380
387
|
end
|
381
|
-
|
388
|
+
|
382
389
|
it "should ignore conditions with a value of false where the named scope has an arity of 0" do
|
383
390
|
User.search(:username_nil => false).proxy_options.should == {}
|
384
391
|
end
|
385
|
-
|
392
|
+
|
386
393
|
it "should not ignore conditions with a value of false where the named scope does not have an arity of 0" do
|
387
394
|
User.search(:username_is => false).proxy_options.should == User.username_is(false).proxy_options
|
388
395
|
end
|
389
|
-
|
396
|
+
|
390
397
|
it "should recognize the order condition" do
|
391
398
|
User.search(:order => "ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
|
392
399
|
end
|
393
|
-
|
400
|
+
|
394
401
|
it "should pass array values as multiple arguments with arity -1" do
|
395
402
|
User.named_scope(:multiple_args, lambda { |*args|
|
396
403
|
raise "This should not be an array, it should be 1" if args.first.is_a?(Array)
|
@@ -398,7 +405,7 @@ describe Searchlogic::Search do
|
|
398
405
|
})
|
399
406
|
User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
|
400
407
|
end
|
401
|
-
|
408
|
+
|
402
409
|
it "should pass array as a single value with arity >= 0" do
|
403
410
|
User.named_scope(:multiple_args, lambda { |args|
|
404
411
|
raise "This should be an array" if !args.is_a?(Array)
|
@@ -406,13 +413,13 @@ describe Searchlogic::Search do
|
|
406
413
|
})
|
407
414
|
User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args([1,2]).proxy_options
|
408
415
|
end
|
409
|
-
|
416
|
+
|
410
417
|
it "should not split out dates or times (big fix)" do
|
411
418
|
s = User.search
|
412
419
|
s.created_at_after = Time.now
|
413
420
|
lambda { s.count }.should_not raise_error
|
414
421
|
end
|
415
|
-
|
422
|
+
|
416
423
|
it "should not include blank values" do
|
417
424
|
s = User.search
|
418
425
|
s.conditions = {"id_equals" => ""}
|
@@ -420,43 +427,43 @@ describe Searchlogic::Search do
|
|
420
427
|
end
|
421
428
|
end
|
422
429
|
end
|
423
|
-
|
430
|
+
|
424
431
|
context "#respond_to?" do
|
425
432
|
it "should respond to created_at_lte" do
|
426
433
|
s = User.search
|
427
434
|
s.respond_to?(:created_at_lte).should == true
|
428
435
|
end
|
429
|
-
|
436
|
+
|
430
437
|
it "should respond to created_at" do
|
431
438
|
s = User.search
|
432
439
|
s.respond_to?(:created_at).should == true
|
433
440
|
end
|
434
|
-
|
441
|
+
|
435
442
|
it "should not respond to created_at_or_whatever" do
|
436
443
|
s = User.search
|
437
444
|
s.respond_to?(:created_at_or_whatever)
|
438
445
|
end
|
439
446
|
end
|
440
|
-
|
447
|
+
|
441
448
|
context "delegation" do
|
442
449
|
it "should return all when not given any conditions" do
|
443
450
|
3.times { User.create }
|
444
451
|
User.search.all.length.should == 3
|
445
452
|
end
|
446
|
-
|
453
|
+
|
447
454
|
it "should implement the current scope based on an association" do
|
448
455
|
User.create
|
449
456
|
company = Company.create
|
450
457
|
user = company.users.create
|
451
458
|
company.users.search.all.should == [user]
|
452
459
|
end
|
453
|
-
|
460
|
+
|
454
461
|
it "should implement the current scope based on a named scope" do
|
455
462
|
User.named_scope(:four_year_olds, :conditions => {:age => 4})
|
456
463
|
(3..5).each { |age| User.create(:age => age) }
|
457
464
|
User.four_year_olds.search.all.should == User.find_all_by_age(4)
|
458
465
|
end
|
459
|
-
|
466
|
+
|
460
467
|
it "should respond to count" do
|
461
468
|
User.create(:username => "bjohnson")
|
462
469
|
search1 = User.search(:username => "bjohnson")
|
@@ -464,7 +471,7 @@ describe Searchlogic::Search do
|
|
464
471
|
search1.count.should == 1
|
465
472
|
search2.count.should == 0
|
466
473
|
end
|
467
|
-
|
474
|
+
|
468
475
|
it "should respond to empty?" do
|
469
476
|
User.create(:username => "bjohnson")
|
470
477
|
search1 = User.search(:username => "bjohnson")
|
@@ -481,9 +488,10 @@ describe Searchlogic::Search do
|
|
481
488
|
search.paged(0, 0).count.should == 0
|
482
489
|
end
|
483
490
|
end
|
484
|
-
|
491
|
+
|
485
492
|
context "yaml" do
|
486
493
|
it "should load yaml" do
|
494
|
+
pending
|
487
495
|
time = Time.now
|
488
496
|
search = User.search(:name_like => "Ben", :created_at_after => time)
|
489
497
|
search.current_scope = {:conditions => "1=1"}
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,50 +1,47 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchlogic
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.5.7
|
4
5
|
prerelease:
|
5
|
-
version: 2.5.6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Ben Johnson of Binary Logic
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-05-17 00:00:00 -04:00
|
12
|
+
date: 2011-08-14 00:00:00.000000000 -04:00
|
14
13
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: activerecord
|
18
|
-
requirement: &
|
17
|
+
requirement: &70173063739320 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
|
-
requirements:
|
19
|
+
requirements:
|
21
20
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.3.12
|
24
23
|
type: :runtime
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
27
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *70173063739320
|
26
|
+
- !ruby/object:Gem::Dependency
|
28
27
|
name: activerecord
|
29
|
-
requirement: &
|
28
|
+
requirement: &70173063738640 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
|
-
requirements:
|
30
|
+
requirements:
|
32
31
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 2.3.
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.12
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *70173063738640
|
38
37
|
description: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
|
39
38
|
email: bjohnson@binarylogic.com
|
40
39
|
executables: []
|
41
|
-
|
42
40
|
extensions: []
|
43
|
-
|
44
|
-
extra_rdoc_files:
|
41
|
+
extra_rdoc_files:
|
45
42
|
- LICENSE
|
46
43
|
- README.rdoc
|
47
|
-
files:
|
44
|
+
files:
|
48
45
|
- Gemfile
|
49
46
|
- Gemfile.lock
|
50
47
|
- LICENSE
|
@@ -93,44 +90,29 @@ files:
|
|
93
90
|
has_rdoc: true
|
94
91
|
homepage: http://github.com/binarylogic/searchlogic
|
95
92
|
licenses: []
|
96
|
-
|
97
93
|
post_install_message:
|
98
94
|
rdoc_options: []
|
99
|
-
|
100
|
-
require_paths:
|
95
|
+
require_paths:
|
101
96
|
- lib
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
98
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
segments:
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
segments:
|
109
104
|
- 0
|
110
|
-
|
111
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
hash: -218814993959786403
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
107
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version:
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
117
112
|
requirements: []
|
118
|
-
|
119
113
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.
|
114
|
+
rubygems_version: 1.6.2
|
121
115
|
signing_key:
|
122
116
|
specification_version: 3
|
123
117
|
summary: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
|
124
|
-
test_files:
|
125
|
-
- spec/searchlogic/active_record/association_proxy_spec.rb
|
126
|
-
- spec/searchlogic/active_record/consistency_spec.rb
|
127
|
-
- spec/searchlogic/core_ext/object_spec.rb
|
128
|
-
- spec/searchlogic/core_ext/proc_spec.rb
|
129
|
-
- spec/searchlogic/named_scopes/alias_scope_spec.rb
|
130
|
-
- spec/searchlogic/named_scopes/association_conditions_spec.rb
|
131
|
-
- spec/searchlogic/named_scopes/association_ordering_spec.rb
|
132
|
-
- spec/searchlogic/named_scopes/column_conditions_spec.rb
|
133
|
-
- spec/searchlogic/named_scopes/or_conditions_spec.rb
|
134
|
-
- spec/searchlogic/named_scopes/ordering_spec.rb
|
135
|
-
- spec/searchlogic/search_spec.rb
|
136
|
-
- spec/spec_helper.rb
|
118
|
+
test_files: []
|