From 24000a51a7e61c065817e3910bd579e8bdf6f82f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 Sep 2010 16:23:15 -0700 Subject: average node is added --- spec/arel/attributes/attribute_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec') diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/arel/attributes/attribute_spec.rb index 449cc38dad..fb6954dc7e 100644 --- a/spec/arel/attributes/attribute_spec.rb +++ b/spec/arel/attributes/attribute_spec.rb @@ -3,6 +3,23 @@ require 'spec_helper' module Arel module Attributes describe 'attribute' do + describe '#average' do + it 'should create a AVG node' do + relation = Table.new(:users) + relation[:id].average.should be_kind_of Nodes::Avg + end + + # FIXME: backwards compat. Is this really necessary? + it 'should set the alias to "avg_id"' do + relation = Table.new(:users) + mgr = relation.project relation[:id].average + mgr.to_sql.should be_like %{ + SELECT AVG("users"."id") AS avg_id + FROM "users" + } + end + end + describe '#maximum' do it 'should create a MAX node' do relation = Table.new(:users) -- cgit v1.2.3