Sha256: 3f2c3d0d18fe6758c1ebef96619da14f5067e95a8a7b093ef53071833169cb43
Contents?: true
Size: 1.29 KB
Versions: 6
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").to_sql.squeeze.should == User.ascend_by_username.to_sql.squeeze 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.scope(:ascend_by_custom, :order => "username ASC, name DESC") User.order("ascend_by_custom").to_sql.squeeze.should == User.ascend_by_custom.to_sql.squeeze end it "should have priorty to columns over conflicting association columns" do Company.ascend_by_users_count end end
Version data entries
6 entries across 6 versions & 1 rubygems