Sha256: 03be6dee31544bc09f9ff9d8266b8c1bb66419017804cf6f3b34b374c2ae1a60

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe Searchlogic::NamedScopes::Ordering do
  it "should have ascending" do
    %w(bjohnson thunt).each { |username| User.create(:username => username) }
    User.ascend_by_username.all.should == User.all(:order => "username ASC")
  end
  
  it "should have descending" do
    %w(bjohnson thunt).each { |username| User.create(:username => username) }
    User.descend_by_username.all.should == User.all(:order => "username DESC")
  end
  
  it "should have order" do
    User.order("ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
  end

  it "should have order by custom scope" do
    User.column_names.should_not include("custom")
    %w(bjohnson thunt fisons).each { |username| User.create(:username => username) }
    User.named_scope(:ascend_by_custom, :order => "username ASC, name DESC")
    User.order("ascend_by_custom").proxy_options.should == User.ascend_by_custom.proxy_options
  end
  
  it "should have priorty to columns over conflicting association columns" do
    Company.ascend_by_users_count
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
searchlogic-2.5.2 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.5.1 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.5.0 spec/searchlogic/named_scopes/ordering_spec.rb