From a61a85683a0214eb96937cec3b3fef82d2f164ec Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 26 Dec 2014 17:06:43 -0700 Subject: Inform Arel that we don't need type casting in tests Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1 --- activerecord/test/cases/relation_test.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index c34516308e..0819b6b11a 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -64,20 +64,21 @@ module ActiveRecord def test_has_values relation = Relation.new(Post, Post.arel_table, Post.predicate_builder) - relation.where! relation.table[:id].eq(10) + relation.where! relation.table[:id].eq(Arel::Nodes::Quoted.new(10)) assert_equal({:id => 10}, relation.where_values_hash) end def test_values_wrong_table relation = Relation.new(Post, Post.arel_table, Post.predicate_builder) - relation.where! Comment.arel_table[:id].eq(10) + relation.where! Comment.arel_table[:id].eq(Arel::Nodes::Quoted.new(10)) assert_equal({}, relation.where_values_hash) end def test_tree_is_not_traversed relation = Relation.new(Post, Post.arel_table, Post.predicate_builder) - left = relation.table[:id].eq(10) - right = relation.table[:id].eq(10) + # FIXME: Remove the Arel::Nodes::Quoted in Rails 5.1 + left = relation.table[:id].eq(Arel::Nodes::Quoted.new(10)) + right = relation.table[:id].eq(Arel::Nodes::Quoted.new(10)) combine = left.and right relation.where! combine assert_equal({}, relation.where_values_hash) @@ -102,7 +103,8 @@ module ActiveRecord def test_create_with_value_with_wheres relation = Relation.new(Post, Post.arel_table, Post.predicate_builder) - relation.where! relation.table[:id].eq(10) + # FIXME: Remove the Arel::Nodes::Quoted in Rails 5.1 + relation.where! relation.table[:id].eq(Arel::Nodes::Quoted.new(10)) relation.create_with_value = {:hello => 'world'} assert_equal({:hello => 'world', :id => 10}, relation.scope_for_create) end @@ -112,7 +114,8 @@ module ActiveRecord relation = Relation.new(Post, Post.arel_table, Post.predicate_builder) assert_equal({}, relation.scope_for_create) - relation.where! relation.table[:id].eq(10) + # FIXME: Remove the Arel::Nodes::Quoted in Rails 5.1 + relation.where! relation.table[:id].eq(Arel::Nodes::Quoted.new(10)) assert_equal({}, relation.scope_for_create) relation.create_with_value = {:hello => 'world'} -- cgit v1.2.3