Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: johndouthat/searchlogic
base: a56519f734
...
head fork: johndouthat/searchlogic
compare: 3b672b77cb
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
View
10 Gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -31,7 +22,6 @@ PLATFORMS
DEPENDENCIES
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
10 gemfiles/ar2.3.10.gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -32,7 +23,6 @@ PLATFORMS
DEPENDENCIES
activerecord (= 2.3.10)
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
10 gemfiles/ar2.3.11.gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -32,7 +23,6 @@ PLATFORMS
DEPENDENCIES
activerecord (= 2.3.11)
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
10 gemfiles/ar2.3.12.gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -32,7 +23,6 @@ PLATFORMS
DEPENDENCIES
activerecord (= 2.3.12)
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
10 gemfiles/ar2.3.14.gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -32,7 +23,6 @@ PLATFORMS
DEPENDENCIES
activerecord (= 2.3.14)
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
10 gemfiles/ar2.3.9.gemfile.lock
@@ -13,16 +13,7 @@ GEM
appraisal (0.4.1)
bundler
rake
- git (1.2.5)
- jeweler (1.8.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.6.5)
rake (0.9.2.2)
- rdoc (3.12)
- json (~> 1.4)
rspec (1.3.2)
sqlite3 (1.3.5)
@@ -32,7 +23,6 @@ PLATFORMS
DEPENDENCIES
activerecord (= 2.3.9)
appraisal (= 0.4.1)
- jeweler
rspec (~> 1.3.1)
searchlogic!
sqlite3
View
4 lib/searchlogic/named_scopes/alias_scope.rb
@@ -8,7 +8,7 @@ module AliasScope
# or represents a named scope procedure. Ex:
#
# class User
- # def teenager
+ # def self.teenager
# age_gte(13).age_lte(19)
# end
# end
@@ -37,7 +37,7 @@ def alias_scope(name, options = nil)
define_method name do |*args|
case options
when Symbol
- send(options)
+ send(options, *args)
else
options.call(*args)
end
View
1  searchlogic.gemspec
@@ -23,7 +23,6 @@ Gem::Specification.new do |gem|
gem.add_dependency 'activerecord', '~> 2.3.8'
- gem.add_development_dependency 'jeweler'
gem.add_development_dependency 'rspec', '~> 1.3.1'
gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'appraisal', '0.4.1'
View
7 spec/searchlogic/named_scopes/alias_scope_spec.rb
@@ -11,6 +11,13 @@
User.username_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
end
+ it "should allow alias scopes with symbols" do
+ User.alias_scope :login_has, :username_has
+ User.create(:username => "bjohnson")
+ User.create(:username => "thunt")
+ User.login_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
+ end
+
it "should allow alias scopes from the search object" do
search = User.search
search.username_has = "bjohnson"
View
7 spec/searchlogic/named_scopes/column_conditions_spec.rb
@@ -26,6 +26,9 @@
it "should have does not equal" do
(5..7).each { |age| User.create(:age => age) }
User.age_does_not_equal(6).all.should == User.find_all_by_age([5,7])
+
+ User.create!(:age => nil)
+ User.age_does_not_equal(nil).all.size.should == 3
end
it "should have less than" do
@@ -326,4 +329,8 @@
count2 = User.id_ne(10).username_not_like("root").count
count1.should == count2
end
+
+ it "should produce left outer joins" do
+ User.left_outer_joins(:orders).should == [" LEFT OUTER JOIN \"orders\" ON orders.user_id = users.id "]
+ end
end
View
10 spec/searchlogic/named_scopes/or_conditions_spec.rb
@@ -39,6 +39,12 @@
{:conditions => "((users.username LIKE '%ben') OR (users.name LIKE '%ben')) AND ((users.age IS NOT NULL) AND ((users.id > 10) AND (users.username LIKE 'ben%')))"}
end
+ it "should work with boolean conditions" do
+ User.male_or_name_eq("susan").proxy_options.should == {:conditions => %Q{("users"."male" = 't') OR (users.name = 'susan')}}
+ User.not_male_or_name_eq("susan").proxy_options.should == {:conditions => %Q{("users"."male" = 'f') OR (users.name = 'susan')}}
+ lambda { User.male_or_name_eq("susan").all }.should_not raise_error
+ end
+
it "should play nice with scopes on associations" do
lambda { User.name_or_company_name_like("ben") }.should_not raise_error(Searchlogic::NamedScopes::OrConditions::NoConditionSpecifiedError)
User.name_or_company_name_like("ben").proxy_options.should == {:joins => :company, :conditions => "(users.name LIKE '%ben%') OR (companies.name LIKE '%ben%')"}
@@ -47,6 +53,10 @@
Cart.user_company_name_or_user_company_name_like("ben").proxy_options.should == {:joins => {:user=>:company}, :conditions => "(companies.name LIKE '%ben%') OR (companies.name LIKE '%ben%')"}
end
+ it "should raise an error on missing condition" do
+ lambda { User.id_or_age(123) }.should raise_error(Searchlogic::NamedScopes::OrConditions::NoConditionSpecifiedError)
+ end
+
it "should not get confused by the 'or' in find_or_create_by_* methods" do
User.create(:name => "Fred")
User.find_or_create_by_name("Fred").should be_a_kind_of User

No commit comments for this range

Something went wrong with that request. Please try again.