searchlogic 2.3.7 → 2.3.8
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.
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/lib/searchlogic/named_scopes/conditions.rb +4 -2
- data/searchlogic.gemspec +1 -1
- data/spec/named_scopes/conditions_spec.rb +7 -6
- metadata +1 -1
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
gem.rubyforge_project = "searchlogic"
|
14
14
|
gem.add_dependency "activerecord", ">= 2.0.0"
|
15
15
|
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
16
17
|
Jeweler::RubyforgeTasks.new
|
17
18
|
rescue LoadError
|
18
19
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
data/VERSION.yml
CHANGED
@@ -72,7 +72,8 @@ module Searchlogic
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def boolean_condition?(name)
|
75
|
-
columns_hash
|
75
|
+
column = columns_hash[name.to_s] || columns_hash[name.to_s.gsub(/^not_/, "")]
|
76
|
+
column && column.type == :boolean
|
76
77
|
end
|
77
78
|
|
78
79
|
def method_missing(name, *args, &block)
|
@@ -80,7 +81,8 @@ module Searchlogic
|
|
80
81
|
create_condition(details[:column], details[:condition], args)
|
81
82
|
send(name, *args)
|
82
83
|
elsif boolean_condition?(name)
|
83
|
-
|
84
|
+
column = name.to_s.gsub(/^not_/, "")
|
85
|
+
named_scope name, :conditions => {column => (name.to_s =~ /^not_/).nil?}
|
84
86
|
send(name)
|
85
87
|
else
|
86
88
|
super
|
data/searchlogic.gemspec
CHANGED
@@ -19,12 +19,6 @@ describe "Conditions" do
|
|
19
19
|
User.age_equals([5, 7]).all.should == User.find_all_by_age([5, 7])
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should have equals for boolean columns" do
|
23
|
-
female = User.create(:male => false)
|
24
|
-
male = User.create(:male => true)
|
25
|
-
User.male.should == [male]
|
26
|
-
end
|
27
|
-
|
28
22
|
it "should have does not equal" do
|
29
23
|
(5..7).each { |age| User.create(:age => age) }
|
30
24
|
User.age_does_not_equal(6).all.should == User.find_all_by_age([5,7])
|
@@ -84,6 +78,13 @@ describe "Conditions" do
|
|
84
78
|
end
|
85
79
|
|
86
80
|
context "boolean conditions" do
|
81
|
+
it "should have scopes for boolean columns" do
|
82
|
+
female = User.create(:male => false)
|
83
|
+
male = User.create(:male => true)
|
84
|
+
User.male.all.should == [male]
|
85
|
+
User.not_male.all.should == [female]
|
86
|
+
end
|
87
|
+
|
87
88
|
it "should have null" do
|
88
89
|
["bjohnson", nil].each { |username| User.create(:username => username) }
|
89
90
|
User.username_null.all.should == User.find_all_by_username(nil)
|