searchlogic 2.3.10 → 2.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/searchlogic/search.rb +7 -5
- data/searchlogic.gemspec +2 -2
- data/spec/search_spec.rb +22 -8
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/searchlogic/search.rb
CHANGED
@@ -92,12 +92,12 @@ module Searchlogic
|
|
92
92
|
else
|
93
93
|
raise UnknownConditionError.new(condition_name)
|
94
94
|
end
|
95
|
-
elsif scope?(scope_name)
|
96
|
-
if args.size
|
95
|
+
elsif scope?(scope_name) && args.size <= 1
|
96
|
+
if args.size == 0
|
97
|
+
conditions[condition_name]
|
98
|
+
else
|
97
99
|
send("#{condition_name}=", *args)
|
98
100
|
self
|
99
|
-
else
|
100
|
-
conditions[condition_name]
|
101
101
|
end
|
102
102
|
else
|
103
103
|
scope = conditions.inject(klass.scoped(current_scope) || {}) do |scope, condition|
|
@@ -112,8 +112,10 @@ module Searchlogic
|
|
112
112
|
else
|
113
113
|
scope
|
114
114
|
end
|
115
|
+
elsif arity == -1
|
116
|
+
scope.send(scope_name, *(value.is_a?(Array) ? value : [value]))
|
115
117
|
else
|
116
|
-
scope.send(scope_name,
|
118
|
+
scope.send(scope_name, value)
|
117
119
|
end
|
118
120
|
end
|
119
121
|
scope.send(name, *args, &block)
|
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.3.
|
8
|
+
s.version = "2.3.11"
|
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{2010-01-
|
12
|
+
s.date = %q{2010-01-19}
|
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 = [
|
data/spec/search_spec.rb
CHANGED
@@ -340,13 +340,27 @@ describe "Search" do
|
|
340
340
|
User.search(:order => "ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
|
341
341
|
end
|
342
342
|
|
343
|
-
it "should pass array values as multiple arguments" do
|
343
|
+
it "should pass array values as multiple arguments with arity -1" do
|
344
344
|
User.named_scope(:multiple_args, lambda { |*args|
|
345
345
|
raise "This should not be an array, it should be 1" if args.first.is_a?(Array)
|
346
346
|
{:conditions => ["id IN (?)", args]}
|
347
347
|
})
|
348
348
|
User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
|
349
349
|
end
|
350
|
+
|
351
|
+
it "should pass array as a single value with arity >= 0" do
|
352
|
+
User.named_scope(:multiple_args, lambda { |args|
|
353
|
+
raise "This should be an array" if !args.is_a?(Array)
|
354
|
+
{:conditions => ["id IN (?)", args]}
|
355
|
+
})
|
356
|
+
User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should not split out dates or times (big fix)" do
|
360
|
+
s = User.search
|
361
|
+
s.created_at_after = Time.now
|
362
|
+
lambda { s.count }.should_not raise_error
|
363
|
+
end
|
350
364
|
end
|
351
365
|
|
352
366
|
context "method delegation" do
|
@@ -366,12 +380,12 @@ describe "Search" do
|
|
366
380
|
search2.empty?.should == true
|
367
381
|
end
|
368
382
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
383
|
+
it "should delegate to named scopes with arity > 1" do
|
384
|
+
User.named_scope :paged, lambda {|start, limit| { :limit => limit, :offset => start }}
|
385
|
+
User.create(:username => "bjohnson")
|
386
|
+
search = User.search(:username => "bjohnson")
|
387
|
+
search.paged(0, 1).count.should == 1
|
388
|
+
search.paged(0, 0).count.should == 0
|
389
|
+
end
|
376
390
|
end
|
377
391
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Johnson of Binary Logic
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-19 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|