diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 16:23:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 16:23:15 -0700 |
commit | 24000a51a7e61c065817e3910bd579e8bdf6f82f (patch) | |
tree | a4068323a2d8717e982c138ffe0708eb6dba9eef /spec/arel/attributes | |
parent | cb6d13877c8d85bd7ba7f7286dfc8b5ae98a50b3 (diff) | |
download | rails-24000a51a7e61c065817e3910bd579e8bdf6f82f.tar.gz rails-24000a51a7e61c065817e3910bd579e8bdf6f82f.tar.bz2 rails-24000a51a7e61c065817e3910bd579e8bdf6f82f.zip |
average node is added
Diffstat (limited to 'spec/arel/attributes')
-rw-r--r-- | spec/arel/attributes/attribute_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
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) |