Sha256: 3be6a62ca490cfe6f7ae006433b73c163519c64a8f3eb2dd1ce51261d0600779

Contents?: true

Size: 789 Bytes

Versions: 7

Compression:

Stored size: 789 Bytes

Contents

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

describe "BelongsToColumns" do
  before(:each) do
    @leaf = CommaHeaven::Sqler::Columns.new(Leaf, {})
    @association = Leaf.reflect_on_association(:tree)
  end
  
  it "should build correct SQL select clause" do
    column = CommaHeaven::Sqler::BelongsToColumns.new(@association, {:age => {4 => {:include => '1', :as => ''}}}, 1, @leaf)
    column.select.should == "_trees.age AS \"tree_age\""
  end

  it "should build correct SQL joins clause" do
    column = CommaHeaven::Sqler::BelongsToColumns.new(@association, {:age => {4 => {:include => '1', :as => ''}}}, 1, @leaf)
    column.joins.should == <<-EOS.gsub(/\n/, ' ').squeeze(' ').strip
LEFT JOIN "trees" AS _trees
 ON _trees.id = leafs.tree_id
EOS
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
comma-heaven-0.8.0 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.7.3 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.7.2 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.7.1 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.7.0 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.6.1 spec/sqler/belongs_to_association_spec.rb
comma-heaven-0.6.0 spec/sqler/belongs_to_association_spec.rb