2008-05-27 00:02:23 -04:00
|
|
|
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec_helper')
|
|
|
|
|
|
|
|
module Arel
|
|
|
|
describe Join do
|
|
|
|
before do
|
|
|
|
@relation1 = Table.new(:users)
|
|
|
|
@relation2 = Table.new(:photos)
|
|
|
|
@predicate = @relation1[:id].eq(@relation2[:user_id])
|
|
|
|
end
|
2009-05-17 16:20:40 -04:00
|
|
|
|
2008-05-27 00:02:23 -04:00
|
|
|
describe 'hashing' do
|
|
|
|
it 'implements hash equality' do
|
|
|
|
InnerJoin.new(@relation1, @relation2, @predicate) \
|
|
|
|
.should hash_the_same_as(InnerJoin.new(@relation1, @relation2, @predicate))
|
|
|
|
end
|
|
|
|
end
|
2009-05-17 16:20:40 -04:00
|
|
|
|
2008-05-27 00:02:23 -04:00
|
|
|
describe '#attributes' do
|
|
|
|
it 'combines the attributes of the two relations' do
|
|
|
|
join = InnerJoin.new(@relation1, @relation2, @predicate)
|
|
|
|
join.attributes.should ==
|
|
|
|
(@relation1.attributes + @relation2.attributes).collect { |a| a.bind(join) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-05-17 16:20:40 -04:00
|
|
|
end
|