Permalink
Browse files

Merge pull request #50 from ernie/operation_ordering.

InfixOperations should support ordering
  • Loading branch information...
2 parents a6f56d8 + 13a2031 commit a3d9c393b4707a03734dcf6831fb9636fabac045 @tenderlove tenderlove committed May 2, 2011
Showing with 31 additions and 0 deletions.
  1. +1 −0 lib/arel/nodes/infix_operation.rb
  2. +30 −0 test/nodes/test_infix_operation.rb
@@ -4,6 +4,7 @@ module Nodes
class InfixOperation < Binary
include Arel::Expressions
include Arel::Predications
+ include Arel::OrderPredications
include Arel::AliasPredication
include Arel::Math
@@ -0,0 +1,30 @@
+require 'helper'
+
+module Arel
+ module Nodes
+ class TestInfixOperation < MiniTest::Unit::TestCase
+ def test_construct
+ operation = InfixOperation.new :+, 1, 2
+ assert_equal :+, operation.operator
+ assert_equal 1, operation.left
+ assert_equal 2, operation.right
+ end
+
+ def test_operation_alias
+ operation = InfixOperation.new :+, 1, 2
+ aliaz = operation.as('zomg')
+ assert_kind_of As, aliaz
+ assert_equal operation, aliaz.left
+ assert_equal 'zomg', aliaz.right
+ end
+
+ def test_opertaion_ordering
+ operation = InfixOperation.new :+, 1, 2
+ ordering = operation.desc
+ assert_kind_of Ordering, ordering
+ assert_equal operation, ordering.expr
+ assert_equal :desc, ordering.direction
+ end
+ end
+ end
+end

0 comments on commit a3d9c39

Please sign in to comment.