diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-06 09:36:02 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-06 09:36:02 -0800 |
commit | 516ae526b34333073df7a9835952d5d499197fdd (patch) | |
tree | b26c83a2c6e3cad34a670e527407aa1f6d0dc2aa | |
parent | 3446b72ede5232f6cc3b87bf2a9af7cb4ac7f500 (diff) | |
download | rails-516ae526b34333073df7a9835952d5d499197fdd.tar.gz rails-516ae526b34333073df7a9835952d5d499197fdd.tar.bz2 rails-516ae526b34333073df7a9835952d5d499197fdd.zip |
adding a test for the dot visitor
-rw-r--r-- | Manifest.txt | 1 | ||||
-rw-r--r-- | lib/arel/nodes/node.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/dot.rb | 11 | ||||
-rw-r--r-- | test/visitors/test_dot.rb | 27 |
4 files changed, 38 insertions, 3 deletions
diff --git a/Manifest.txt b/Manifest.txt index b67d3b24e8..095d3c276e 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -107,6 +107,7 @@ test/test_select_manager.rb test/test_table.rb test/test_update_manager.rb test/visitors/test_depth_first.rb +test/visitors/test_dot.rb test/visitors/test_join_sql.rb test/visitors/test_mysql.rb test/visitors/test_oracle.rb diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb index 4e182d2850..404ad22ece 100644 --- a/lib/arel/nodes/node.rb +++ b/lib/arel/nodes/node.rb @@ -7,7 +7,7 @@ module Arel # Factory method to create a Nodes::Not node that has the recipient of # the caller as a child. def not - Nodes::Not.new self + Nodes::Not.new Nodes::Grouping.new self end ### diff --git a/lib/arel/visitors/dot.rb b/lib/arel/visitors/dot.rb index 2ce8b6814f..c515cbe220 100644 --- a/lib/arel/visitors/dot.rb +++ b/lib/arel/visitors/dot.rb @@ -84,9 +84,16 @@ module Arel visit_edge o, "attribute" end - def visit_Arel_Nodes_Offset o - visit_edge o, "value" + def unary o + visit_edge o, "expr" end + alias :visit_Arel_Nodes_Group :unary + alias :visit_Arel_Nodes_Grouping :unary + alias :visit_Arel_Nodes_Having :unary + alias :visit_Arel_Nodes_Not :unary + alias :visit_Arel_Nodes_Offset :unary + alias :visit_Arel_Nodes_On :unary + alias :visit_Arel_Nodes_UnqualifiedColumn :unary def visit_Arel_Nodes_InsertStatement o visit_edge o, "relation" diff --git a/test/visitors/test_dot.rb b/test/visitors/test_dot.rb new file mode 100644 index 0000000000..19a554ce42 --- /dev/null +++ b/test/visitors/test_dot.rb @@ -0,0 +1,27 @@ +require 'helper' + +module Arel + module Visitors + class TestDot < MiniTest::Unit::TestCase + def setup + @visitor = Visitors::Dot.new + end + + # unary ops + [ + Arel::Nodes::Not, + Arel::Nodes::Group, + Arel::Nodes::On, + Arel::Nodes::Grouping, + Arel::Nodes::Offset, + Arel::Nodes::Having, + Arel::Nodes::UnqualifiedColumn, + ].each do |klass| + define_method("test_#{klass.name.gsub('::', '_')}") do + op = klass.new(:a) + @visitor.accept op + end + end + end + end +end |