searchlogic 2.4.15 → 2.4.16
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 +5 -0
- data/searchlogic.gemspec +1 -1
- data/spec/searchlogic/search_spec.rb +17 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/searchlogic/search.rb
CHANGED
@@ -97,6 +97,11 @@ module Searchlogic
|
|
97
97
|
self
|
98
98
|
end
|
99
99
|
|
100
|
+
# Returns the column we are currently ordering by
|
101
|
+
def ordering_by
|
102
|
+
order && order.gsub(/^(ascend|descend)_by_/, '')
|
103
|
+
end
|
104
|
+
|
100
105
|
private
|
101
106
|
def method_missing(name, *args, &block)
|
102
107
|
condition_name = condition_name(name)
|
data/searchlogic.gemspec
CHANGED
@@ -335,6 +335,23 @@ describe Searchlogic::Search do
|
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
+
context "#ordering_by" do
|
339
|
+
it "should return nil if we aren't ordering" do
|
340
|
+
search = User.search
|
341
|
+
search.ordering_by.should be_nil
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should return the column name for ascending" do
|
345
|
+
search = User.search(:order => "ascend_by_first_name")
|
346
|
+
search.ordering_by.should == "first_name"
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should return the column name for descending" do
|
350
|
+
search = User.search(:order => "descend_by_first_name")
|
351
|
+
search.ordering_by.should == "first_name"
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
338
355
|
context "#method_missing" do
|
339
356
|
context "setting" do
|
340
357
|
it "should call named scopes for conditions" do
|