diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 14:36:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 14:36:10 -0700 |
commit | 7b8944cb7662509d7ba6869ff571518ac7f848ea (patch) | |
tree | be57ff9ce3a937428a5c61cb8cada24006fe8874 /spec/arel | |
parent | ab55d3bfc18348e9f43e4604e02c4c3db7a3e23c (diff) | |
download | rails-7b8944cb7662509d7ba6869ff571518ac7f848ea.tar.gz rails-7b8944cb7662509d7ba6869ff571518ac7f848ea.tar.bz2 rails-7b8944cb7662509d7ba6869ff571518ac7f848ea.zip |
adding a sum node
Diffstat (limited to 'spec/arel')
-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 d6f07f8d99..018f23ea9f 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 '#sum' do + it 'should create a SUM node' do + relation = Table.new(:users) + relation[:id].sum.should be_kind_of Nodes::Sum + end + + # FIXME: backwards compat. Is this really necessary? + it 'should set the alias to "sum_id"' do + relation = Table.new(:users) + mgr = relation.project relation[:id].sum + mgr.to_sql.should be_like %{ + SELECT SUM("users"."id") AS sum_id + FROM "users" + } + end + end + describe '#count' do it 'should return a count node' do relation = Table.new(:users) |