aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/integration/joins/with_aggregations_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/arel/integration/joins/with_aggregations_spec.rb')
-rw-r--r--spec/arel/integration/joins/with_aggregations_spec.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/arel/integration/joins/with_aggregations_spec.rb b/spec/arel/integration/joins/with_aggregations_spec.rb
index db34bb1b46..ab904d103d 100644
--- a/spec/arel/integration/joins/with_aggregations_spec.rb
+++ b/spec/arel/integration/joins/with_aggregations_spec.rb
@@ -39,8 +39,14 @@ module Arel
end
describe 'with the aggregation on both sides' do
- it '' do
- @aggregation.join(@aggregation.alias).on(@predicate).to_sql.should == ''
+ it 'it properly aliases the aggregations' do
+ aggregation2 = @aggregation.alias
+ @aggregation.join(aggregation2).on(aggregation2[:user_id].eq(@aggregation[:user_id])).to_sql.should be_like("
+ SELECT `photos_aggregation`.`user_id`, `photos_aggregation`.`cnt`, `photos_aggregation_2`.`user_id`, `photos_aggregation_2`.`cnt`
+ FROM (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) AS `photos_aggregation`
+ INNER JOIN (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) AS `photos_aggregation_2`
+ ON `photos_aggregation_2`.`user_id` = `photos_aggregation`.`user_id`
+ ")
end
end