aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-06-27 09:28:06 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-06-27 09:28:06 -0700
commitd193a52dedc060e62c63fbc0c57a16ba8795f599 (patch)
tree5b31f2e9ca4cc3e35e7e85790d87b55f524ada4f /test/nodes
parent0d39cbe523206c90f4a3eaf9279f882510f375c5 (diff)
parent0c8723af70b8518c1a9ae43e650afb433e078470 (diff)
downloadrails-d193a52dedc060e62c63fbc0c57a16ba8795f599.tar.gz
rails-d193a52dedc060e62c63fbc0c57a16ba8795f599.tar.bz2
rails-d193a52dedc060e62c63fbc0c57a16ba8795f599.zip
Merge branch 'master' into Khronos/master
* master: visitors can define their own cache strategy for dispatch. fixes #57 Break Ordering into Ascending/Descending nodes, allow reversal remove unnecessary guarding agains literal LIMIT and OFFSET support for MS SQL Include Arel::Predicates to Arel::Nodes::Function so you can do table[:id].count.eq(2) updating spec zomg prep release make sure thread runs do not cache sql literal values no longer use this instance variable
Diffstat (limited to 'test/nodes')
-rw-r--r--test/nodes/test_ascending.rb34
-rw-r--r--test/nodes/test_count.rb9
-rw-r--r--test/nodes/test_descending.rb34
-rw-r--r--test/nodes/test_infix_operation.rb4
4 files changed, 79 insertions, 2 deletions
diff --git a/test/nodes/test_ascending.rb b/test/nodes/test_ascending.rb
new file mode 100644
index 0000000000..0e2c4810c6
--- /dev/null
+++ b/test/nodes/test_ascending.rb
@@ -0,0 +1,34 @@
+require 'helper'
+
+module Arel
+ module Nodes
+ class TestAscending < MiniTest::Unit::TestCase
+ def test_construct
+ ascending = Ascending.new 'zomg'
+ assert_equal 'zomg', ascending.expr
+ end
+
+ def test_reverse
+ ascending = Ascending.new 'zomg'
+ descending = ascending.reverse
+ assert_kind_of Descending, descending
+ assert_equal ascending.expr, descending.expr
+ end
+
+ def test_direction
+ ascending = Ascending.new 'zomg'
+ assert_equal :asc, ascending.direction
+ end
+
+ def test_ascending?
+ ascending = Ascending.new 'zomg'
+ assert ascending.ascending?
+ end
+
+ def test_descending?
+ ascending = Ascending.new 'zomg'
+ assert !ascending.descending?
+ end
+ end
+ end
+end
diff --git a/test/nodes/test_count.rb b/test/nodes/test_count.rb
index afa423e8f5..be53b86855 100644
--- a/test/nodes/test_count.rb
+++ b/test/nodes/test_count.rb
@@ -15,4 +15,13 @@ describe Arel::Nodes::Count do
}
end
end
+
+ describe "eq" do
+ it "should compare the count" do
+ table = Arel::Table.new :users
+ table[:id].count.eq(2).to_sql.must_be_like %{
+ COUNT("users"."id") = 2
+ }
+ end
+ end
end
diff --git a/test/nodes/test_descending.rb b/test/nodes/test_descending.rb
new file mode 100644
index 0000000000..424f8298cd
--- /dev/null
+++ b/test/nodes/test_descending.rb
@@ -0,0 +1,34 @@
+require 'helper'
+
+module Arel
+ module Nodes
+ class TestDescending < MiniTest::Unit::TestCase
+ def test_construct
+ descending = Descending.new 'zomg'
+ assert_equal 'zomg', descending.expr
+ end
+
+ def test_reverse
+ descending = Descending.new 'zomg'
+ ascending = descending.reverse
+ assert_kind_of Ascending, ascending
+ assert_equal descending.expr, ascending.expr
+ end
+
+ def test_direction
+ descending = Descending.new 'zomg'
+ assert_equal :desc, descending.direction
+ end
+
+ def test_ascending?
+ descending = Descending.new 'zomg'
+ assert !descending.ascending?
+ end
+
+ def test_descending?
+ descending = Descending.new 'zomg'
+ assert descending.descending?
+ end
+ end
+ end
+end
diff --git a/test/nodes/test_infix_operation.rb b/test/nodes/test_infix_operation.rb
index db3216eeee..3d2eb0d9c6 100644
--- a/test/nodes/test_infix_operation.rb
+++ b/test/nodes/test_infix_operation.rb
@@ -21,9 +21,9 @@ module Arel
def test_opertaion_ordering
operation = InfixOperation.new :+, 1, 2
ordering = operation.desc
- assert_kind_of Ordering, ordering
+ assert_kind_of Descending, ordering
assert_equal operation, ordering.expr
- assert_equal :desc, ordering.direction
+ assert ordering.descending?
end
end
end