Sha256: d7a44056656f794cb33937aaeff7d1b6e51f229bb8f95cff926d4ef928f6adf7
Contents?: true
Size: 1.54 KB
Versions: 12
Compression:
Stored size: 1.54 KB
Contents
require File.dirname(__FILE__) + '/helper' context "ActiveRecord Adapter" do context "Chaining" do specify "should join selects with AND" do sql = User.select { |m| m.name == 'jon' } sql = sql.select { |m| m.age == 22 } sql.to_s.should == "SELECT * FROM users WHERE users.name = 'jon' AND users.age = 22" end specify "should join sort_bys with a comma" do sql = User.select { |m| m.name == 'jon' } sql = sql.sort_by { |m| m.name } sql = sql.sort_by { |m| m.age } sql.to_s.should == "SELECT * FROM users WHERE users.name = 'jon' ORDER BY users.name, users.age" end specify "should join selects and sorts intelligently" do sql = User.select { |m| m.name == 'jon' } sql = sql.select { |m| m.age == 22 } sql = sql.sort_by { |m| -m.name } sql = sql.sort_by { |m| m.age } sql.to_s.should == "SELECT * FROM users WHERE users.name = 'jon' AND users.age = 22 ORDER BY users.name DESC, users.age" end specify "should join lots of selects and sorts intelligently" do sql = User.select { |m| m.name == 'jon' } sql = sql.select { |m| m.age == 22 } sql = sql.sort_by { |m| m.name } sql = sql.select { |m| m.power == true } sql = sql.sort_by { |m| m.email } sql = sql.select { |m| m.admin == true && m.email == 'chris@ozmm.org' } sql.to_s.should == "SELECT * FROM users WHERE users.name = 'jon' AND users.age = 22 AND users.power = 1 AND (users.admin = 1 AND users.email = 'chris@ozmm.org') ORDER BY users.name, users.email" end end end
Version data entries
12 entries across 12 versions & 2 rubygems