diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-12-26 17:06:43 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-12-26 17:06:43 -0700 |
commit | a61a85683a0214eb96937cec3b3fef82d2f164ec (patch) | |
tree | 669dcbea4a0d89f8ac7defc7e02ca6f31484a4cd /activerecord/test | |
parent | 3eb16cea7eeecaa8815baabc75dfec3cdad684c2 (diff) | |
download | rails-a61a85683a0214eb96937cec3b3fef82d2f164ec.tar.gz rails-a61a85683a0214eb96937cec3b3fef82d2f164ec.tar.bz2 rails-a61a85683a0214eb96937cec3b3fef82d2f164ec.zip |
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
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 15 |
1 files changed, 9 insertions, 6 deletions
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'} |