aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-04-22 11:34:55 +0200
committerJon Leighton <j@jonathanleighton.com>2012-04-25 15:45:06 +0100
commitef1d1e1492e3c48884f7653103bc9313dd04cfad (patch)
tree63ec275d561d8e9f6a2f5b44e18b5c676591bbbe /activerecord/test/cases
parente8cdb3d5e73c1be3d551f55602de7f5c34d43c42 (diff)
downloadrails-ef1d1e1492e3c48884f7653103bc9313dd04cfad.tar.gz
rails-ef1d1e1492e3c48884f7653103bc9313dd04cfad.tar.bz2
rails-ef1d1e1492e3c48884f7653103bc9313dd04cfad.zip
fix interpolation for hash merging
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relation_test.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb
index d1fb3e01d2..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
@@ -162,6 +162,15 @@ module ActiveRecord
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
@@ -227,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