From a15424b92c182bcc4d2b693dc0001a44c9b0802f Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 26 Sep 2011 12:40:03 +0100 Subject: Make serializable_hash take attr values directly from attributes hash. Previously, it would use send() to get the attribute. In Active Resource, this would rely on hitting method missing. If a method with the same name was defined further up the ancestor chain, that method would wrongly be called. This change fixes test_to_xml_with_private_method_name_as_attribute in activeresource/test/cases/base_test.rb, which was broken after 51bef9d8fb0b4da7a104425ab8545e9331387743, because that change made to_xml use serializable_hash. --- activeresource/test/cases/base_test.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'activeresource/test/cases') diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index d4063fa299..7b42f64a35 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -1004,9 +1004,17 @@ class BaseTest < Test::Unit::TestCase def test_to_xml_with_private_method_name_as_attribute Person.format = :xml - assert_nothing_raised(ArgumentError) { - Customer.new(:test => true).to_xml - } + + customer = Customer.new(:foo => "foo") + customer.singleton_class.class_eval do + def foo + "bar" + end + private :foo + end + + assert !customer.to_xml.include?("bar") + assert customer.to_xml.include?("foo") ensure Person.format = :json end -- cgit v1.2.3