aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 20:18:52 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 20:18:52 -0800
commita83efc5d5d94d50589a80bdd27ddf5b83ed39810 (patch)
treed85ad7f670b2c4a7e8af62d96d8f95ecfebfbafa /spec/active_relation
parent45d2557ae097da1e5dd3dc532444233b4fed0b31 (diff)
downloadrails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.tar.gz
rails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.tar.bz2
rails-a83efc5d5d94d50589a80bdd27ddf5b83ed39810.zip
added aggregations
Diffstat (limited to 'spec/active_relation')
-rw-r--r--spec/active_relation/relations/attribute_spec.rb40
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/active_relation/relations/attribute_spec.rb b/spec/active_relation/relations/attribute_spec.rb
index 28fb0c3754..2a6deca22a 100644
--- a/spec/active_relation/relations/attribute_spec.rb
+++ b/spec/active_relation/relations/attribute_spec.rb
@@ -56,7 +56,7 @@ describe ActiveRelation::Primitives::Attribute do
end
end
- describe 'greater_than' do
+ describe '#greater_than' do
it "manufactures a greater-than predicate" do
@attribute1.greater_than(@attribute2).should == ActiveRelation::Predicates::GreaterThan.new(@attribute1, @attribute2)
end
@@ -74,4 +74,42 @@ describe ActiveRelation::Primitives::Attribute do
end
end
end
+
+ describe 'aggregations' do
+ before do
+ @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name)
+ end
+
+ describe '#count' do
+ it "manufactures a count aggregation" do
+ @attribute1.count.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "COUNT")
+ end
+ end
+
+ describe '#sum' do
+ it "manufactures a sum aggregation" do
+ @attribute1.sum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "SUM")
+ end
+ end
+
+ describe '#maximum' do
+ it "manufactures a maximum aggregation" do
+ @attribute1.maximum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MAX")
+ end
+ end
+
+ describe '#minimum' do
+ it "manufactures a minimum aggregation" do
+ @attribute1.minimum.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "MIN")
+ end
+ end
+
+ describe '#average' do
+ it "manufactures an average aggregation" do
+ @attribute1.average.should == ActiveRelation::Primitives::Aggregation.new(@attribute1, "AVG")
+ end
+ end
+
+
+ end
end