diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-05-26 12:41:52 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-05-26 12:41:52 -0300 |
commit | c9bbea6115be520dbd47bd30108c5622289deb26 (patch) | |
tree | ec418e01954c1bd2dcfebc7fbc8220fb04b50baf /spec/arel/algebra/unit/relations/join_spec.rb | |
parent | ae1e0ac5e98a7e5a2894d0a431f8c34af6575cae (diff) | |
parent | 86364591af807ed3fa4a7304f53e6f3458cb4961 (diff) | |
download | rails-c9bbea6115be520dbd47bd30108c5622289deb26.tar.gz rails-c9bbea6115be520dbd47bd30108c5622289deb26.tar.bz2 rails-c9bbea6115be520dbd47bd30108c5622289deb26.zip |
Merge commit 'brynary/master'
Conflicts:
lib/arel.rb
lib/arel/session.rb
Diffstat (limited to 'spec/arel/algebra/unit/relations/join_spec.rb')
-rw-r--r-- | spec/arel/algebra/unit/relations/join_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/arel/algebra/unit/relations/join_spec.rb b/spec/arel/algebra/unit/relations/join_spec.rb new file mode 100644 index 0000000000..f5a8bd32aa --- /dev/null +++ b/spec/arel/algebra/unit/relations/join_spec.rb @@ -0,0 +1,26 @@ +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 + + 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 + + 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 +end |