aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors
diff options
context:
space:
mode:
authorDaniel Cadenas <dcadenas@gmail.com>2011-05-31 00:40:11 -0300
committerDaniel Cadenas <dcadenas@gmail.com>2011-08-03 20:50:03 -0300
commit11f929b5c485adab60ea2d8b515ef2abcf5400f4 (patch)
tree911f4e22c86b8098d218939fbfadb992a0eaaa1d /test/visitors
parentc9517c1b62e7d8acd5a45f72b148942ff2f549a7 (diff)
downloadrails-11f929b5c485adab60ea2d8b515ef2abcf5400f4.tar.gz
rails-11f929b5c485adab60ea2d8b515ef2abcf5400f4.tar.bz2
rails-11f929b5c485adab60ea2d8b515ef2abcf5400f4.zip
Add nodes for boolean constants
This is useful for dynamically created predicates e.g: expr1 = table.create_false expr2 = table.create_false expr1 = create_a_predicate() if some_condition expr2 = create_another_predicate() if some_other_condition table.where(expr1.and(expr2))
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_to_sql.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index b52722ddd6..3b58c71cd8 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -325,6 +325,22 @@ module Arel
end
end
+ describe 'Constants' do
+ it "should handle true" do
+ test = Table.new(:users).create_true
+ @visitor.accept(test).must_be_like %{
+ TRUE
+ }
+ end
+
+ it "should handle false" do
+ test = Table.new(:users).create_false
+ @visitor.accept(test).must_be_like %{
+ FALSE
+ }
+ end
+ end
+
describe 'TableAlias' do
it "should use the underlying table for checking columns" do
test = Table.new(:users).alias('zomgusers')[:id].eq '3'