Sha256: 622af9bdfaa240a279c7ffcf0b7c9af208c82eebb97786bcbbde701b3f1403bd

Contents?: true

Size: 1.27 KB

Versions: 56

Compression:

Stored size: 1.27 KB

Contents

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

describe "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

56 entries across 56 versions & 6 rubygems

Version Path
binarylogic-searchlogic-2.1.13 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.2.0 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.2.1 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.2.2 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.2.3 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.0 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.1 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.2 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.3 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.4 spec/named_scopes/ordering_spec.rb
binarylogic-searchlogic-2.3.5 spec/named_scopes/ordering_spec.rb
kazjote-searchlogic-2.3.4 spec/named_scopes/ordering_spec.rb
searchlogic-donotuse-2.3.9 spec/named_scopes/ordering_spec.rb
aq1018-searchlogic-2.4.17 spec/named_scopes/ordering_spec.rb
aq1018-searchlogic-2.4.16 spec/named_scopes/ordering_spec.rb
aq1018-searchlogic-2.4.15 spec/named_scopes/ordering_spec.rb
searchlogic-2.4.14 spec/named_scopes/ordering_spec.rb
searchlogic-2.4.13 spec/named_scopes/ordering_spec.rb
searchlogic-2.4.12 spec/named_scopes/ordering_spec.rb
searchlogic-2.4.11 spec/named_scopes/ordering_spec.rb