searchlogic 2.4.14 → 2.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,4 @@
2
2
  :major: 2
3
3
  :build:
4
4
  :minor: 4
5
- :patch: 14
5
+ :patch: 15
@@ -1,5 +1,6 @@
1
1
  require "searchlogic/core_ext/proc"
2
2
  require "searchlogic/core_ext/object"
3
+ require "searchlogic/active_record/association_proxy"
3
4
  require "searchlogic/active_record/consistency"
4
5
  require "searchlogic/active_record/named_scope_tools"
5
6
  require "searchlogic/named_scopes/conditions"
@@ -14,6 +15,12 @@ Proc.send(:include, Searchlogic::CoreExt::Proc)
14
15
  Object.send(:include, Searchlogic::CoreExt::Object)
15
16
 
16
17
  module ActiveRecord # :nodoc: all
18
+ module Associations
19
+ class AssociationProxy
20
+ include Searchlogic::ActiveRecord::AssociationProxy
21
+ end
22
+ end
23
+
17
24
  class Base
18
25
  class << self; include Searchlogic::ActiveRecord::Consistency; end
19
26
  end
@@ -0,0 +1,19 @@
1
+ module Searchlogic
2
+ module ActiveRecord
3
+ module AssociationProxy
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ alias_method_chain :send, :searchlogic
7
+ end
8
+ end
9
+
10
+ def send_with_searchlogic(method, *args)
11
+ if !proxy_respond_to?(method) && proxy_reflection.klass.condition?(method)
12
+ proxy_reflection.klass.send(method, *args)
13
+ else
14
+ send_without_searchlogic(method, *args)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -20,7 +20,7 @@ module Searchlogic
20
20
 
21
21
  WILDCARD_CONDITIONS = {
22
22
  :like => [:contains, :includes],
23
- :not_like => [],
23
+ :not_like => [:does_not_include],
24
24
  :begins_with => [:bw],
25
25
  :not_begin_with => [:does_not_begin_with],
26
26
  :ends_with => [:ew],
@@ -50,7 +50,7 @@ module Searchlogic
50
50
  end
51
51
 
52
52
  CONDITIONS[:equals_any] = CONDITIONS[:equals_any] + [:in]
53
- CONDITIONS[:does_not_equal_any] = CONDITIONS[:equals_any] + [:not_in]
53
+ CONDITIONS[:does_not_equal_any] = CONDITIONS[:does_not_equal_any] + [:not_in]
54
54
 
55
55
  BOOLEAN_CONDITIONS.each { |condition, aliases| CONDITIONS[condition] = aliases }
56
56
 
@@ -89,6 +89,7 @@ module Searchlogic
89
89
  end
90
90
  end
91
91
 
92
+
92
93
  def condition_details(method_name)
93
94
  column_name_matcher = column_names.join("|")
94
95
  conditions_matcher = (PRIMARY_CONDITIONS + ALIAS_CONDITIONS).join("|")
@@ -157,27 +158,35 @@ module Searchlogic
157
158
  def scope_options(condition, column_type, sql, options = {})
158
159
  case condition.to_s
159
160
  when /_(any|all)$/
160
- searchlogic_lambda(column_type, :skip_conversion => options[:skip_conversion]) { |*values|
161
- return {} if values.empty?
162
- values.flatten!
163
- values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
164
-
165
- join = $1 == "any" ? " OR " : " AND "
166
- scope_sql = values.collect { |value| sql.is_a?(Proc) ? sql.call(value) : sql }.join(join)
167
-
168
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
169
- }
161
+ any_or_all_scope_options(column_type, sql, options)
170
162
  else
171
- searchlogic_lambda(column_type, :skip_conversion => options[:skip_conversion]) { |*values|
172
- values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
173
-
174
- scope_sql = sql.is_a?(Proc) ? sql.call(*values) : sql
175
-
176
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
177
- }
163
+ general_scope_options(column_type, sql, options)
178
164
  end
179
165
  end
180
166
 
167
+ def any_or_all_scope_options(column_type, sql, options)
168
+ searchlogic_lambda(column_type, :skip_conversion => options[:skip_conversion]) { |*values|
169
+ return {} if values.empty?
170
+ values.flatten!
171
+ values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
172
+
173
+ join = $1 == "any" ? " OR " : " AND "
174
+ scope_sql = values.collect { |value| sql.is_a?(Proc) ? sql.call(value) : sql }.join(join)
175
+
176
+ {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
177
+ }
178
+ end
179
+
180
+ def general_scope_options(column_type, sql, options)
181
+ searchlogic_lambda(column_type, :skip_conversion => options[:skip_conversion]) { |*values|
182
+ values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
183
+
184
+ scope_sql = sql.is_a?(Proc) ? sql.call(*values) : sql
185
+
186
+ {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
187
+ }
188
+ end
189
+
181
190
  def value_with_modifier(value, modifier)
182
191
  case modifier
183
192
  when :like
@@ -62,6 +62,21 @@ module Searchlogic
62
62
 
63
63
  # Accepts a hash of conditions.
64
64
  def conditions=(values)
65
+ values.each do |condition, value|
66
+ # if a condition name ends with "(1i)", assume it's date / datetime
67
+ if condition =~ /(.*)\(1i\)$/
68
+ date_scope_name = $1
69
+ date_parts = (1..6).to_a.map do |idx|
70
+ values.delete("#{ date_scope_name }(#{ idx }i)")
71
+ end.reject{|s| s.blank? }.map{|s| s.to_i }
72
+
73
+ # did we get enough info to build a time?
74
+ if date_parts.length >= 3
75
+ values[date_scope_name] = Time.zone.local(*date_parts)
76
+ end
77
+ end
78
+ end
79
+
65
80
  values.each do |condition, value|
66
81
  mass_conditions[condition.to_sym] = value
67
82
  value.delete_if { |v| ignore_value?(v) } if value.is_a?(Array)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{searchlogic}
8
- s.version = "2.4.14"
8
+ s.version = "2.4.15"
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-04-04}
12
+ s.date = %q{2010-04-15}
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 = [
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "VERSION.yml",
25
25
  "init.rb",
26
26
  "lib/searchlogic.rb",
27
+ "lib/searchlogic/active_record/association_proxy.rb",
27
28
  "lib/searchlogic/active_record/consistency.rb",
28
29
  "lib/searchlogic/active_record/named_scope_tools.rb",
29
30
  "lib/searchlogic/core_ext/object.rb",
@@ -38,16 +39,17 @@ Gem::Specification.new do |s|
38
39
  "lib/searchlogic/search.rb",
39
40
  "rails/init.rb",
40
41
  "searchlogic.gemspec",
41
- "spec/active_record/consistency_spec.rb",
42
- "spec/core_ext/object_spec.rb",
43
- "spec/core_ext/proc_spec.rb",
44
- "spec/named_scopes/alias_scope_spec.rb",
45
- "spec/named_scopes/association_conditions_spec.rb",
46
- "spec/named_scopes/association_ordering_spec.rb",
47
- "spec/named_scopes/conditions_spec.rb",
48
- "spec/named_scopes/or_conditions_spec.rb",
49
- "spec/named_scopes/ordering_spec.rb",
50
- "spec/search_spec.rb",
42
+ "spec/searchlogic/active_record/association_proxy_spec.rb",
43
+ "spec/searchlogic/active_record/consistency_spec.rb",
44
+ "spec/searchlogic/core_ext/object_spec.rb",
45
+ "spec/searchlogic/core_ext/proc_spec.rb",
46
+ "spec/searchlogic/named_scopes/alias_scope_spec.rb",
47
+ "spec/searchlogic/named_scopes/association_conditions_spec.rb",
48
+ "spec/searchlogic/named_scopes/association_ordering_spec.rb",
49
+ "spec/searchlogic/named_scopes/conditions_spec.rb",
50
+ "spec/searchlogic/named_scopes/or_conditions_spec.rb",
51
+ "spec/searchlogic/named_scopes/ordering_spec.rb",
52
+ "spec/searchlogic/search_spec.rb",
51
53
  "spec/spec_helper.rb"
52
54
  ]
53
55
  s.homepage = %q{http://github.com/binarylogic/searchlogic}
@@ -57,16 +59,17 @@ Gem::Specification.new do |s|
57
59
  s.rubygems_version = %q{1.3.6}
58
60
  s.summary = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
59
61
  s.test_files = [
60
- "spec/active_record/consistency_spec.rb",
61
- "spec/core_ext/object_spec.rb",
62
- "spec/core_ext/proc_spec.rb",
63
- "spec/named_scopes/alias_scope_spec.rb",
64
- "spec/named_scopes/association_conditions_spec.rb",
65
- "spec/named_scopes/association_ordering_spec.rb",
66
- "spec/named_scopes/conditions_spec.rb",
67
- "spec/named_scopes/or_conditions_spec.rb",
68
- "spec/named_scopes/ordering_spec.rb",
69
- "spec/search_spec.rb",
62
+ "spec/searchlogic/active_record/association_proxy_spec.rb",
63
+ "spec/searchlogic/active_record/consistency_spec.rb",
64
+ "spec/searchlogic/core_ext/object_spec.rb",
65
+ "spec/searchlogic/core_ext/proc_spec.rb",
66
+ "spec/searchlogic/named_scopes/alias_scope_spec.rb",
67
+ "spec/searchlogic/named_scopes/association_conditions_spec.rb",
68
+ "spec/searchlogic/named_scopes/association_ordering_spec.rb",
69
+ "spec/searchlogic/named_scopes/conditions_spec.rb",
70
+ "spec/searchlogic/named_scopes/or_conditions_spec.rb",
71
+ "spec/searchlogic/named_scopes/ordering_spec.rb",
72
+ "spec/searchlogic/search_spec.rb",
70
73
  "spec/spec_helper.rb"
71
74
  ]
72
75
 
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe "Searchlogic::ActiveRecord::AssociationProxy" do
4
+ it "should call location conditions" do
5
+ company = Company.create
6
+ user = company.users.create(:username => "bjohnson")
7
+ company.users.send(:username_like, "bjohnson").should == [user]
8
+ end
9
+
10
+ it "should call ordering conditions" do
11
+ company = Company.create
12
+ user = company.users.create(:username => "bjohnson")
13
+ company.users.send(:ascend_by_username).should == [user]
14
+ end
15
+
16
+ it "should call 'or' conditions" do
17
+ company = Company.create
18
+ user = company.users.create(:username => "bjohnson")
19
+ company.users.send(:username_or_some_type_id_like, "bjohnson").should == [user]
20
+ end
21
+
22
+ end
23
+
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Consistency" do
3
+ describe Searchlogic::ActiveRecord::Consistency do
4
4
  it "should merge joins with consistent conditions" do
5
5
  user_group = UserGroup.create
6
6
  user_group.users.user_groups_name_like("name").user_groups_id_gt(10).scope(:find)[:joins].should == [
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Object" do
3
+ describe Searchlogic::CoreExt::Object do
4
4
  it "should accept and pass the argument to the searchlogic_options" do
5
5
  proc = searchlogic_lambda(:integer, :test => :value) {}
6
6
  proc.searchlogic_options[:type].should == :integer
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Proc" do
3
+ describe Searchlogic::CoreExt::Proc do
4
4
  it "should have a searchlogic_options accessor" do
5
5
  p = Proc.new {}
6
6
  p.searchlogic_options[:type] = :integer
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "AliasScope" do
3
+ describe Searchlogic::NamedScopes::AliasScope do
4
4
  before(:each) do
5
5
  User.alias_scope :username_has, lambda { |value| User.username_like(value) }
6
6
  end
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Association Conditions" do
3
+ describe Searchlogic::NamedScopes::AssociationConditions do
4
4
  it "should create a named scope" do
5
5
  Company.users_username_like("bjohnson").proxy_options.should == User.username_like("bjohnson").proxy_options.merge(:joins => :users)
6
6
  end
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Association Ordering" do
3
+ describe Searchlogic::NamedScopes::Ordering do
4
4
  it "should allow ascending" do
5
5
  Company.ascend_by_users_username.proxy_options.should == User.ascend_by_username.proxy_options.merge(:joins => :users)
6
6
  end
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Conditions" do
3
+ describe Searchlogic::NamedScopes::Conditions do
4
4
  it "should be dynamically created and then cached" do
5
5
  User.should_not respond_to(:age_less_than)
6
6
  User.age_less_than(5)
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Or conditions" do
3
+ describe Searchlogic::NamedScopes::OrConditions do
4
4
  it "should define a scope by the exact same name as requested by the code" do
5
5
  User.name_or_username_like('Test')
6
6
  User.respond_to?(:name_or_username_like).should be_true
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
- describe "Ordering" do
3
+ describe Searchlogic::NamedScopes::Ordering do
4
4
  it "should be dynamically created and then cached" do
5
5
  User.should_not respond_to(:ascend_by_username)
6
6
  User.ascend_by_username
@@ -1,24 +1,26 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
- describe "Search" do
4
- context "implementation" do
5
- it "should create a search proxy" do
6
- User.search(:username => "joe").should be_kind_of(Searchlogic::Search)
7
- end
3
+ describe Searchlogic::Search do
4
+ describe "Implementation" do
5
+ context "#searchlogic" do
6
+ it "should create a search proxy" do
7
+ User.search(:username => "joe").should be_kind_of(Searchlogic::Search)
8
+ end
8
9
 
9
- it "should create a search proxy using the same class" do
10
- User.search.klass.should == User
11
- end
10
+ it "should create a search proxy using the same class" do
11
+ User.search.klass.should == User
12
+ end
12
13
 
13
- it "should pass on the current scope to the proxy" do
14
- company = Company.create
15
- user = company.users.create
16
- search = company.users.search
17
- search.current_scope.should == company.users.scope(:find)
14
+ it "should pass on the current scope to the proxy" do
15
+ company = Company.create
16
+ user = company.users.create
17
+ search = company.users.search
18
+ search.current_scope.should == company.users.scope(:find)
19
+ end
18
20
  end
19
21
  end
20
22
 
21
- context "initialization" do
23
+ context "#initialize" do
22
24
  it "should require a class" do
23
25
  lambda { Searchlogic::Search.new }.should raise_error(ArgumentError)
24
26
  end
@@ -29,35 +31,30 @@ describe "Search" do
29
31
  end
30
32
  end
31
33
 
32
- it "should clone properly" do
33
- company = Company.create
34
- user1 = company.users.create(:age => 5)
35
- user2 = company.users.create(:age => 25)
36
- search1 = company.users.search(:age_gt => 10)
37
- search2 = search1.clone
38
- search2.age_gt = 1
39
- search2.all.should == User.all
40
- search1.all.should == [user2]
41
- end
42
-
43
- it "should clone properly without scope" do
44
- user1 = User.create(:age => 5)
45
- user2 = User.create(:age => 25)
46
- search1 = User.search(:age_gt => 10)
47
- search2 = search1.clone
48
- search2.age_gt = 1
49
- search2.all.should == User.all
50
- search1.all.should == [user2]
51
- end
34
+ context "#clone" do
35
+ it "should clone properly" do
36
+ company = Company.create
37
+ user1 = company.users.create(:age => 5)
38
+ user2 = company.users.create(:age => 25)
39
+ search1 = company.users.search(:age_gt => 10)
40
+ search2 = search1.clone
41
+ search2.age_gt = 1
42
+ search2.all.should == User.all
43
+ search1.all.should == [user2]
44
+ end
52
45
 
53
- it "should delete the condition" do
54
- search = User.search(:username_like => "bjohnson")
55
- search.delete("username_like")
56
- search.username_like.should be_nil
57
- search.conditions["username_like"].should be_nil
46
+ it "should clone properly without scope" do
47
+ user1 = User.create(:age => 5)
48
+ user2 = User.create(:age => 25)
49
+ search1 = User.search(:age_gt => 10)
50
+ search2 = search1.clone
51
+ search2.age_gt = 1
52
+ search2.all.should == User.all
53
+ search1.all.should == [user2]
54
+ end
58
55
  end
59
56
 
60
- context "conditions" do
57
+ context "#conditions" do
61
58
  it "should set the conditions and be accessible individually" do
62
59
  search = User.search
63
60
  search.conditions = {:username => "bjohnson"}
@@ -320,10 +317,81 @@ describe "Search" do
320
317
  search.users_orders_total_gt = "10"
321
318
  search.users_orders_total_gt.should == 10
322
319
  end
320
+
321
+ it "should support Rails' date_select and datetime_select out of the box" do
322
+ search = Company.search('created_at_after(1i)' => 2000, 'created_at_after(2i)' => 1, 'created_at_after(3i)' => 1)
323
+ search.created_at_after.should_not be_nil
324
+ search.created_at_after.should == Time.zone.local(2000, 1, 1)
325
+ end
323
326
  end
324
327
  end
325
328
 
326
- context "taking action" do
329
+ context "#delete" do
330
+ it "should delete the condition" do
331
+ search = User.search(:username_like => "bjohnson")
332
+ search.delete("username_like")
333
+ search.username_like.should be_nil
334
+ search.conditions["username_like"].should be_nil
335
+ end
336
+ end
337
+
338
+ context "#method_missing" do
339
+ context "setting" do
340
+ it "should call named scopes for conditions" do
341
+ User.search(:age_less_than => 5).proxy_options.should == User.age_less_than(5).proxy_options
342
+ end
343
+
344
+ it "should alias exact column names to use equals" do
345
+ User.search(:username => "joe").proxy_options.should == User.username_equals("joe").proxy_options
346
+ end
347
+
348
+ it "should recognize conditions with a value of true where the named scope has an arity of 0" do
349
+ User.search(:username_nil => true).proxy_options.should == User.username_nil.proxy_options
350
+ end
351
+
352
+ it "should ignore conditions with a value of false where the named scope has an arity of 0" do
353
+ User.search(:username_nil => false).proxy_options.should == {}
354
+ end
355
+
356
+ it "should not ignore conditions with a value of false where the named scope does not have an arity of 0" do
357
+ User.search(:username_is => false).proxy_options.should == User.username_is(false).proxy_options
358
+ end
359
+
360
+ it "should recognize the order condition" do
361
+ User.search(:order => "ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
362
+ end
363
+
364
+ it "should pass array values as multiple arguments with arity -1" do
365
+ User.named_scope(:multiple_args, lambda { |*args|
366
+ raise "This should not be an array, it should be 1" if args.first.is_a?(Array)
367
+ {:conditions => ["id IN (?)", args]}
368
+ })
369
+ User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
370
+ end
371
+
372
+ it "should pass array as a single value with arity >= 0" do
373
+ User.named_scope(:multiple_args, lambda { |args|
374
+ raise "This should be an array" if !args.is_a?(Array)
375
+ {:conditions => ["id IN (?)", args]}
376
+ })
377
+ User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args([1,2]).proxy_options
378
+ end
379
+
380
+ it "should not split out dates or times (big fix)" do
381
+ s = User.search
382
+ s.created_at_after = Time.now
383
+ lambda { s.count }.should_not raise_error
384
+ end
385
+
386
+ it "should not include blank values" do
387
+ s = User.search
388
+ s.conditions = {"id_equals" => ""}
389
+ s.proxy_options.should == {}
390
+ end
391
+ end
392
+ end
393
+
394
+ context "delegation" do
327
395
  it "should return all when not given any conditions" do
328
396
  3.times { User.create }
329
397
  User.search.all.length.should == 3
@@ -342,60 +410,6 @@ describe "Search" do
342
410
  User.four_year_olds.search.all.should == User.find_all_by_age(4)
343
411
  end
344
412
 
345
- it "should call named scopes for conditions" do
346
- User.search(:age_less_than => 5).proxy_options.should == User.age_less_than(5).proxy_options
347
- end
348
-
349
- it "should alias exact column names to use equals" do
350
- User.search(:username => "joe").proxy_options.should == User.username_equals("joe").proxy_options
351
- end
352
-
353
- it "should recognize conditions with a value of true where the named scope has an arity of 0" do
354
- User.search(:username_nil => true).proxy_options.should == User.username_nil.proxy_options
355
- end
356
-
357
- it "should ignore conditions with a value of false where the named scope has an arity of 0" do
358
- User.search(:username_nil => false).proxy_options.should == {}
359
- end
360
-
361
- it "should not ignore conditions with a value of false where the named scope does not have an arity of 0" do
362
- User.search(:username_is => false).proxy_options.should == User.username_is(false).proxy_options
363
- end
364
-
365
- it "should recognize the order condition" do
366
- User.search(:order => "ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
367
- end
368
-
369
- it "should pass array values as multiple arguments with arity -1" do
370
- User.named_scope(:multiple_args, lambda { |*args|
371
- raise "This should not be an array, it should be 1" if args.first.is_a?(Array)
372
- {:conditions => ["id IN (?)", args]}
373
- })
374
- User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
375
- end
376
-
377
- it "should pass array as a single value with arity >= 0" do
378
- User.named_scope(:multiple_args, lambda { |args|
379
- raise "This should be an array" if !args.is_a?(Array)
380
- {:conditions => ["id IN (?)", args]}
381
- })
382
- User.search(:multiple_args => [1,2]).proxy_options.should == User.multiple_args(1,2).proxy_options
383
- end
384
-
385
- it "should not split out dates or times (big fix)" do
386
- s = User.search
387
- s.created_at_after = Time.now
388
- lambda { s.count }.should_not raise_error
389
- end
390
-
391
- it "should not include blank values" do
392
- s = User.search
393
- s.conditions = {"id_equals" => ""}
394
- s.proxy_options.should == {}
395
- end
396
- end
397
-
398
- context "method delegation" do
399
413
  it "should respond to count" do
400
414
  User.create(:username => "bjohnson")
401
415
  search1 = User.search(:username => "bjohnson")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 4
8
- - 14
9
- version: 2.4.14
8
+ - 15
9
+ version: 2.4.15
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ben Johnson of Binary Logic
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-04 00:00:00 -04:00
17
+ date: 2010-04-15 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - VERSION.yml
49
49
  - init.rb
50
50
  - lib/searchlogic.rb
51
+ - lib/searchlogic/active_record/association_proxy.rb
51
52
  - lib/searchlogic/active_record/consistency.rb
52
53
  - lib/searchlogic/active_record/named_scope_tools.rb
53
54
  - lib/searchlogic/core_ext/object.rb
@@ -62,16 +63,17 @@ files:
62
63
  - lib/searchlogic/search.rb
63
64
  - rails/init.rb
64
65
  - searchlogic.gemspec
65
- - spec/active_record/consistency_spec.rb
66
- - spec/core_ext/object_spec.rb
67
- - spec/core_ext/proc_spec.rb
68
- - spec/named_scopes/alias_scope_spec.rb
69
- - spec/named_scopes/association_conditions_spec.rb
70
- - spec/named_scopes/association_ordering_spec.rb
71
- - spec/named_scopes/conditions_spec.rb
72
- - spec/named_scopes/or_conditions_spec.rb
73
- - spec/named_scopes/ordering_spec.rb
74
- - spec/search_spec.rb
66
+ - spec/searchlogic/active_record/association_proxy_spec.rb
67
+ - spec/searchlogic/active_record/consistency_spec.rb
68
+ - spec/searchlogic/core_ext/object_spec.rb
69
+ - spec/searchlogic/core_ext/proc_spec.rb
70
+ - spec/searchlogic/named_scopes/alias_scope_spec.rb
71
+ - spec/searchlogic/named_scopes/association_conditions_spec.rb
72
+ - spec/searchlogic/named_scopes/association_ordering_spec.rb
73
+ - spec/searchlogic/named_scopes/conditions_spec.rb
74
+ - spec/searchlogic/named_scopes/or_conditions_spec.rb
75
+ - spec/searchlogic/named_scopes/ordering_spec.rb
76
+ - spec/searchlogic/search_spec.rb
75
77
  - spec/spec_helper.rb
76
78
  has_rdoc: true
77
79
  homepage: http://github.com/binarylogic/searchlogic
@@ -104,14 +106,15 @@ signing_key:
104
106
  specification_version: 3
105
107
  summary: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
106
108
  test_files:
107
- - spec/active_record/consistency_spec.rb
108
- - spec/core_ext/object_spec.rb
109
- - spec/core_ext/proc_spec.rb
110
- - spec/named_scopes/alias_scope_spec.rb
111
- - spec/named_scopes/association_conditions_spec.rb
112
- - spec/named_scopes/association_ordering_spec.rb
113
- - spec/named_scopes/conditions_spec.rb
114
- - spec/named_scopes/or_conditions_spec.rb
115
- - spec/named_scopes/ordering_spec.rb
116
- - spec/search_spec.rb
109
+ - spec/searchlogic/active_record/association_proxy_spec.rb
110
+ - spec/searchlogic/active_record/consistency_spec.rb
111
+ - spec/searchlogic/core_ext/object_spec.rb
112
+ - spec/searchlogic/core_ext/proc_spec.rb
113
+ - spec/searchlogic/named_scopes/alias_scope_spec.rb
114
+ - spec/searchlogic/named_scopes/association_conditions_spec.rb
115
+ - spec/searchlogic/named_scopes/association_ordering_spec.rb
116
+ - spec/searchlogic/named_scopes/conditions_spec.rb
117
+ - spec/searchlogic/named_scopes/or_conditions_spec.rb
118
+ - spec/searchlogic/named_scopes/ordering_spec.rb
119
+ - spec/searchlogic/search_spec.rb
117
120
  - spec/spec_helper.rb