2012-07-13 06:19:17 -04:00
|
|
|
require 'helper'
|
|
|
|
require 'ostruct'
|
|
|
|
|
|
|
|
module Arel
|
|
|
|
module Nodes
|
|
|
|
describe 'table alias' do
|
|
|
|
it 'has an #engine which delegates to the relation' do
|
2012-08-18 22:33:25 -04:00
|
|
|
engine = 'vroom'
|
|
|
|
relation = Table.new(:users, engine)
|
2012-07-13 06:19:17 -04:00
|
|
|
|
|
|
|
node = TableAlias.new relation, :foo
|
|
|
|
node.engine.must_equal engine
|
|
|
|
end
|
2012-08-18 22:33:25 -04:00
|
|
|
|
|
|
|
describe 'equality' do
|
|
|
|
it 'is equal with equal ivars' do
|
|
|
|
relation1 = Table.new(:users, 'vroom')
|
|
|
|
node1 = TableAlias.new relation1, :foo
|
|
|
|
relation2 = Table.new(:users, 'vroom')
|
|
|
|
node2 = TableAlias.new relation2, :foo
|
|
|
|
array = [node1, node2]
|
|
|
|
assert_equal 1, array.uniq.size
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is not equal with different ivars' do
|
|
|
|
relation1 = Table.new(:users, 'vroom')
|
|
|
|
node1 = TableAlias.new relation1, :foo
|
|
|
|
relation2 = Table.new(:users, 'vroom')
|
|
|
|
node2 = TableAlias.new relation2, :bar
|
|
|
|
array = [node1, node2]
|
|
|
|
assert_equal 2, array.uniq.size
|
|
|
|
end
|
|
|
|
end
|
2012-07-13 06:19:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|