From 10c4b42c35f61145ac6ebb8d36f504344eef47cd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 18:21:56 -0400 Subject: Fix bug in Order equality where Descending.new(attribute) was == Ascending.new(attribute) --- spec/arel/algebra/unit/primitives/attribute_spec.rb | 4 ++-- spec/arel/algebra/unit/relations/order_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/arel/algebra/unit/primitives/attribute_spec.rb b/spec/arel/algebra/unit/primitives/attribute_spec.rb index afcf1237e0..2ca63ba48e 100644 --- a/spec/arel/algebra/unit/primitives/attribute_spec.rb +++ b/spec/arel/algebra/unit/primitives/attribute_spec.rb @@ -169,13 +169,13 @@ module Arel describe Attribute::Orderings do describe '#asc' do it 'manufactures an ascending ordering' do - pending + @attribute.asc.should == Ascending.new(@attribute) end end describe '#desc' do it 'manufactures a descending ordering' do - pending + @attribute.desc.should == Descending.new(@attribute) end end end diff --git a/spec/arel/algebra/unit/relations/order_spec.rb b/spec/arel/algebra/unit/relations/order_spec.rb index 4f163894c8..8b3c932fb9 100644 --- a/spec/arel/algebra/unit/relations/order_spec.rb +++ b/spec/arel/algebra/unit/relations/order_spec.rb @@ -6,6 +6,16 @@ module Arel @relation = Table.new(:users) @attribute = @relation[:id] end + + describe "#==" do + it "returns true when the Orders are for the same attribute and direction" do + Ascending.new(@attribute).should == Ascending.new(@attribute) + end + + it "returns false when the Orders are for a diferent direction" do + Ascending.new(@attribute).should_not == Descending.new(@attribute) + end + end end end -- cgit v1.2.3