aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-05-03 13:52:50 -0700
committerGitHub <noreply@github.com>2017-05-03 13:52:50 -0700
commitaed797eb57fe712d77c327143fafcfce56863d05 (patch)
tree682a5a5d25a9212d6164b749797f2228c20cbb7c
parent184c3d3ac206d246d692556c2c71aad411ee6f1e (diff)
parenta568a820d23543defe3c8a1e28c9aac97ca9daae (diff)
downloadrails-aed797eb57fe712d77c327143fafcfce56863d05.tar.gz
rails-aed797eb57fe712d77c327143fafcfce56863d05.tar.bz2
rails-aed797eb57fe712d77c327143fafcfce56863d05.zip
Merge pull request #28976 from kamipo/should_test_bound_attributes
Should test against `Relation#bound_attributes`
-rw-r--r--activerecord/test/cases/relations_test.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index e72e9f62ef..81173945a3 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1981,24 +1981,28 @@ class RelationTest < ActiveRecord::TestCase
end
def test_unscope_removes_binds
- left = Post.where(id: Arel::Nodes::BindParam.new)
- column = Post.columns_hash["id"]
- left.bind_values += [[column, 20]]
+ left = Post.where(id: 20)
+
+ binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
+ assert_equal binds, left.bound_attributes
relation = left.unscope(where: :id)
- assert_equal [], relation.bind_values
+ assert_equal [], relation.bound_attributes
end
- def test_merging_removes_rhs_bind_parameters
+ def test_merging_removes_rhs_binds
left = Post.where(id: 20)
right = Post.where(id: [1, 2, 3, 4])
+ binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
+ assert_equal binds, left.bound_attributes
+
merged = left.merge(right)
- assert_equal [], merged.bind_values
+ assert_equal [], merged.bound_attributes
end
- def test_merging_keeps_lhs_bind_parameters
- binds = [ActiveRecord::Relation::QueryAttribute.new("id", 20, Post.type_for_attribute("id"))]
+ def test_merging_keeps_lhs_binds
+ binds = [bind_attribute("id", 20, Post.type_for_attribute("id"))]
right = Post.where(id: 20)
left = Post.where(id: 10)