From 7b122f9a336c8c780dcc5a29074f17f3ec493dc6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 Sep 2010 15:08:00 -0700 Subject: adding maximum nodes --- spec/arel/attributes/attribute_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec/arel/attributes') 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) -- cgit v1.2.3