Sha256: 984a9cdf03e08e21972faa3166347ab912c9a4e308ca21ec318aabab5d6efa5c

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

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

describe Searchlogic::NamedScopes::Ordering do
  it "should be dynamically created and then cached" do
    User.should_not respond_to(:ascend_by_username)
    User.ascend_by_username
    User.should respond_to(:ascend_by_username)
  end
  
  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

23 entries across 23 versions & 6 rubygems

Version Path
searchlogic-2.4.32 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.31 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.30 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.29 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.28 spec/searchlogic/named_scopes/ordering_spec.rb
nberger-searchlogic-2.4.29 spec/searchlogic/named_scopes/ordering_spec.rb
nberger-searchlogic-2.4.28 spec/searchlogic/named_scopes/ordering_spec.rb
obitum-searchlogic-2.4.28 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.27 spec/searchlogic/named_scopes/ordering_spec.rb
yoomee-searchlogic-2.4.27 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.26 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.25 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.24 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.23 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.22 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-heroku-2.4.19 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.21 spec/searchlogic/named_scopes/ordering_spec.rb
gravis-searchlogic-2.4.20 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.19 spec/searchlogic/named_scopes/ordering_spec.rb
searchlogic-2.4.18 spec/searchlogic/named_scopes/ordering_spec.rb