aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/relation_test.rb')
-rw-r--r--activerecord/test/cases/relation_test.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb
index 9ef703fd9b..8a7a2441d4 100644
--- a/activerecord/test/cases/relation_test.rb
+++ b/activerecord/test/cases/relation_test.rb
@@ -130,9 +130,9 @@ module ActiveRecord
test 'merging a hash into a relation' do
relation = Relation.new :a, :b
- relation = relation.merge where: ['lol'], readonly: true
+ relation = relation.merge where: :lol, readonly: true
- assert_equal ['lol'], relation.where_values
+ assert_equal [:lol], relation.where_values
assert_equal true, relation.readonly_value
end
@@ -156,6 +156,21 @@ module ActiveRecord
relation = Relation.new(:a, :b, where: [:foo])
assert_equal [:foo], relation.where_values
end
+
+ test 'merging a single where value' do
+ relation = Relation.new(:a, :b)
+ relation.merge!(where: :foo)
+ assert_equal [:foo], relation.where_values
+ end
+
+ test 'merging a hash interpolates conditions' do
+ klass = stub
+ klass.stubs(:sanitize_sql).with(['foo = ?', 'bar']).returns('foo = bar')
+
+ relation = Relation.new(klass, :b)
+ relation.merge!(where: ['foo = ?', 'bar'])
+ assert_equal ['foo = bar'], relation.where_values
+ end
end
class RelationMutationTest < ActiveSupport::TestCase
@@ -221,8 +236,8 @@ module ActiveRecord
end
test 'merge!' do
- assert relation.merge!(where: ['foo']).equal?(relation)
- assert_equal ['foo'], relation.where_values
+ assert relation.merge!(where: :foo).equal?(relation)
+ assert_equal [:foo], relation.where_values
end
end
end