1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/spec/relations/projection_relation_spec.rb
2008-01-05 15:24:46 -08:00

36 lines
No EOL
1.3 KiB
Ruby

require File.join(File.dirname(__FILE__), '..', 'spec_helper')
describe ProjectionRelation do
before do
@relation1 = TableRelation.new(:foo)
@relation2 = TableRelation.new(:bar)
@attribute1 = @relation1[:id]
@attribute2 = @relation2[:id]
end
describe '==' do
it "obtains if the relations and attributes are identical" do
ProjectionRelation.new(@relation1, @attribute1, @attribute2).should == ProjectionRelation.new(@relation1, @attribute1, @attribute2)
ProjectionRelation.new(@relation1, @attribute1).should_not == ProjectionRelation.new(@relation2, @attribute1)
ProjectionRelation.new(@relation1, @attribute1).should_not == ProjectionRelation.new(@relation1, @attribute2)
end
end
describe '#qualify' do
it "manufactures a projection relation with qualified attributes and qualified relation" do
ProjectionRelation.new(@relation1, @attribute1).qualify. \
should == ProjectionRelation.new(@relation1.qualify, @attribute1.qualify)
end
end
describe '#to_sql' do
it "manufactures sql with a limited select clause" do
ProjectionRelation.new(@relation1, @attribute1).to_sql.to_s.should == SelectBuilder.new do
select do
column :foo, :id
end
from :foo
end.to_s
end
end
end