diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-04 20:36:17 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-04 20:36:17 -0800 |
commit | 7523c8690deda1b24def03eb049f61baf2f1b466 (patch) | |
tree | cd13473111ff4ced8841a5286ab27b0c2f689457 /spec/active_relation/relations/join_spec.rb | |
parent | b6c0de24fadc6b9e124a36aa35718edc027130de (diff) | |
download | rails-7523c8690deda1b24def03eb049f61baf2f1b466.tar.gz rails-7523c8690deda1b24def03eb049f61baf2f1b466.tar.bz2 rails-7523c8690deda1b24def03eb049f61baf2f1b466.zip |
cleaning up code and adding test coverage for attribute and expression.
Diffstat (limited to 'spec/active_relation/relations/join_spec.rb')
-rw-r--r-- | spec/active_relation/relations/join_spec.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/spec/active_relation/relations/join_spec.rb b/spec/active_relation/relations/join_spec.rb index 52915b62c7..2df349dcd3 100644 --- a/spec/active_relation/relations/join_spec.rb +++ b/spec/active_relation/relations/join_spec.rb @@ -77,12 +77,11 @@ module ActiveRelation before do @relation = Table.new(:users) photos = Table.new(:photos) - aggregate_relation = photos.aggregate(photos[:user_id], photos[:id].count).group(photos[:user_id]) - @aggregate_relation = aggregate_relation.rename(photos[:id].count, :cnt).as(:photo_count) + @aggregate_relation = photos.aggregate(photos[:user_id], photos[:id].count).group(photos[:user_id]).rename(photos[:id].count, :cnt).as(:photo_count) @predicate = Equality.new(@aggregate_relation[:user_id], @relation[:id]) end - describe 'with the expression on the right' do + describe 'with the aggregation on the right' do it 'manufactures sql joining the left table to a derived table' do Join.new("INNER JOIN", @relation, @aggregate_relation, @predicate).to_sql.should be_like(""" SELECT `users`.`name`, `users`.`id`, `photo_count`.`user_id`, `photo_count`.`cnt` @@ -93,7 +92,7 @@ module ActiveRelation end end - describe 'with the expression on the left' do + describe 'with the aggregation on the left' do it 'manufactures sql joining the right table to a derived table' do Join.new("INNER JOIN", @aggregate_relation, @relation, @predicate).to_sql.should be_like(""" SELECT `photo_count`.`user_id`, `photo_count`.`cnt`, `users`.`name`, `users`.`id` @@ -104,8 +103,7 @@ module ActiveRelation end end - it "keeps selects on the expression within the derived table" do - pending + it "keeps selects on the aggregation within the derived table" do Join.new("INNER JOIN", @relation, @aggregate_relation.select(@aggregate_relation[:user_id].equals(1)), @predicate).to_sql.should be_like(""" SELECT `users`.`name`, `users`.`id`, `photo_count`.`user_id`, `photo_count`.`cnt` FROM `users` |