Sha256: b1e2d152b137ac00ea905ae6d1c493fdd5f04b2831a9c614fccda0533750fd9a
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
require File.dirname(__FILE__) + '/helper' context "Joins" do specify "simple == on an association" do sql = User.select { |m| m.account.email == 'chris@ozmm.org' } sql.to_hash.should == { :conditions => "accounts.email = 'chris@ozmm.org'", :includes => [:account] } end specify "simple mixed == on an association" do sql = User.select { |m| m.name == 'chris' && m.account.email == 'chris@ozmm.org' } sql.to_hash.should == { :conditions => "(users.`name` = 'chris' AND accounts.email = 'chris@ozmm.org')", :includes => [:account] } end specify "multiple associations" do sql = User.select { |m| m.ideas.title == 'New Freezer' || m.invites.email == 'pj@hyett.com' } sql.to_hash.should == { :conditions => "(ideas.title = 'New Freezer' OR invites.email = 'pj@hyett.com')", :includes => [:ideas, :invites] } end specify "non-existant associations" do sql = User.select { |m| m.liquor.brand == 'Jack' } should.raise { sql.to_hash } end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cheat-1.3.3 | lib/ambition/test/join_test.rb |
cheat-1.3.2 | lib/ambition/test/join_test.rb |
cheat-1.3.1 | lib/ambition/test/join_test.rb |
cheat-1.3.0 | lib/ambition/test/join_test.rb |