提交 a61a8568 编写于 作者: S Sean Griffin

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
上级 3eb16cea
......@@ -64,20 +64,21 @@ def test_empty_where_values_hash
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 @@ def test_create_with_value
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 @@ def test_scope_for_create_is_cached
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'}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册