mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge branch '2-0-stable'
* 2-0-stable: adding a test for the dot visitor
This commit is contained in:
commit
e4ea62bdec
4 changed files with 38 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -9,7 +9,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
|
||||
|
||||
###
|
||||
|
|
|
@ -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"
|
||||
|
|
27
test/visitors/test_dot.rb
Normal file
27
test/visitors/test_dot.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue