diff options
Diffstat (limited to 'spec')
-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) |