diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 15:08:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-08 15:08:00 -0700 |
commit | 7b122f9a336c8c780dcc5a29074f17f3ec493dc6 (patch) | |
tree | f1d76bf30258e0413d9ac032493225f3c4fdaddb /spec/arel/attributes | |
parent | 301dfa5a3888a41ea36324a390241538249e9a53 (diff) | |
download | rails-7b122f9a336c8c780dcc5a29074f17f3ec493dc6.tar.gz rails-7b122f9a336c8c780dcc5a29074f17f3ec493dc6.tar.bz2 rails-7b122f9a336c8c780dcc5a29074f17f3ec493dc6.zip |
adding maximum nodes
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 018f23ea9f..449cc38dad 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 '#maximum' do + it 'should create a MAX node' do + relation = Table.new(:users) + relation[:id].maximum.should be_kind_of Nodes::Max + end + + # FIXME: backwards compat. Is this really necessary? + it 'should set the alias to "max_id"' do + relation = Table.new(:users) + mgr = relation.project relation[:id].maximum + mgr.to_sql.should be_like %{ + SELECT MAX("users"."id") AS max_id + FROM "users" + } + end + end + describe '#sum' do it 'should create a SUM node' do relation = Table.new(:users) |