aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/attributes/test_attribute.rb8
-rw-r--r--test/nodes/test_ascending.rb34
-rw-r--r--test/nodes/test_descending.rb34
-rw-r--r--test/nodes/test_infix_operation.rb4
-rw-r--r--test/visitors/test_depth_first.rb2
-rw-r--r--test/visitors/test_dot.rb2
6 files changed, 76 insertions, 8 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb
index 352774071a..901850ff4b 100644
--- a/test/attributes/test_attribute.rb
+++ b/test/attributes/test_attribute.rb
@@ -619,9 +619,9 @@ module Arel
end
describe '#asc' do
- it 'should create an Ordering node' do
+ it 'should create an Ascending node' do
relation = Table.new(:users)
- relation[:id].asc.must_be_kind_of Nodes::Ordering
+ relation[:id].asc.must_be_kind_of Nodes::Ascending
end
it 'should generate ASC in sql' do
@@ -635,9 +635,9 @@ module Arel
end
describe '#desc' do
- it 'should create an Ordering node' do
+ it 'should create a Descending node' do
relation = Table.new(:users)
- relation[:id].desc.must_be_kind_of Nodes::Ordering
+ relation[:id].desc.must_be_kind_of Nodes::Descending
end
it 'should generate DESC in sql' do
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_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
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index 5bbdf57697..e62ce5266f 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -28,6 +28,7 @@ module Arel
Arel::Nodes::On,
Arel::Nodes::Grouping,
Arel::Nodes::Offset,
+ Arel::Nodes::Ordering,
Arel::Nodes::Having,
Arel::Nodes::StringJoin,
Arel::Nodes::UnqualifiedColumn,
@@ -104,7 +105,6 @@ module Arel
Arel::Nodes::Values,
Arel::Nodes::As,
Arel::Nodes::DeleteStatement,
- Arel::Nodes::Ordering,
Arel::Nodes::JoinSource,
].each do |klass|
define_method("test_#{klass.name.gsub('::', '_')}") do
diff --git a/test/visitors/test_dot.rb b/test/visitors/test_dot.rb
index b311246436..362e39339c 100644
--- a/test/visitors/test_dot.rb
+++ b/test/visitors/test_dot.rb
@@ -33,6 +33,7 @@ module Arel
Arel::Nodes::On,
Arel::Nodes::Grouping,
Arel::Nodes::Offset,
+ Arel::Nodes::Ordering,
Arel::Nodes::Having,
Arel::Nodes::UnqualifiedColumn,
Arel::Nodes::Top,
@@ -63,7 +64,6 @@ module Arel
Arel::Nodes::Values,
Arel::Nodes::As,
Arel::Nodes::DeleteStatement,
- Arel::Nodes::Ordering,
Arel::Nodes::JoinSource,
].each do |klass|
define_method("test_#{klass.name.gsub('::', '_')}") do