binarylogic-searchlogic 2.1.11 → 2.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == 2.1.12 released 2009-07-28
2
+
3
+ * Fixed bug when dealing with scopes that return nil.
4
+
1
5
  == 2.1.11 released 2009-07-28
2
6
 
3
7
  * Reworked how alias conditions are created on the fly, uses scope(:find) instead of proxy_options to create the scope. This allows using association alias named scopes.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 11
2
+ :patch: 12
3
3
  :major: 2
4
4
  :minor: 1
@@ -131,7 +131,8 @@ module Searchlogic
131
131
 
132
132
  eval <<-"end_eval"
133
133
  searchlogic_lambda(:#{arg_type}) { |#{proc_args.join(",")}|
134
- options = association.klass.send(association_condition, #{proc_args.join(",")}).scope(:find)
134
+ scope = association.klass.send(association_condition, #{proc_args.join(",")})
135
+ options = scope ? scope.scope(:find) : {}
135
136
  options.delete(:readonly)
136
137
  options[:joins] = options[:joins].blank? ? association.name : {association.name => options[:joins]}
137
138
  options
data/searchlogic.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{searchlogic}
5
- s.version = "2.1.11"
5
+ s.version = "2.1.12"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Johnson of Binary Logic"]
@@ -17,6 +17,10 @@ describe "Association Conditions" do
17
17
  Company.users_username_has("bjohnson").proxy_options.should == User.username_has("bjohnson").proxy_options.merge(:joins => :users)
18
18
  end
19
19
 
20
+ it "should not raise errors for scopes that don't return anything" do
21
+ Company.users_blank_scope("bjohnson").proxy_options.should == {:joins => :users}
22
+ end
23
+
20
24
  it "should ignore polymorphic associations" do
21
25
  lambda { Fee.owner_created_at_gt(Time.now) }.should raise_error(NoMethodError)
22
26
  end
data/spec/search_spec.rb CHANGED
@@ -115,6 +115,12 @@ describe "Search" do
115
115
  search.users_uname.should == "bjohnson"
116
116
  end
117
117
 
118
+ it "should allow setting pre-existing association alias conditions" do
119
+ search = Company.search
120
+ search.users_username_has = "bjohnson"
121
+ search.users_username_has.should == "bjohnson"
122
+ end
123
+
118
124
  it "should allow using custom conditions" do
119
125
  User.named_scope(:four_year_olds, { :conditions => { :age => 4 } })
120
126
  search = User.search
data/spec/spec_helper.rb CHANGED
@@ -73,6 +73,7 @@ Spec::Runner.configure do |config|
73
73
  has_many :orders, :dependent => :destroy
74
74
  named_scope :uname, lambda { |value| {:conditions => ["users.username = ?", value]} }
75
75
  alias_scope :username_has, lambda { |value| username_like(value) }
76
+ alias_scope :blank_scope, lambda { |value| }
76
77
  end
77
78
 
78
79
  class Order < ActiveRecord::Base
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binarylogic-searchlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.11
4
+ version: 2.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic