Ticket #7307: xml_serialization_ignores_undefined_methods_200701221649.diff
| File xml_serialization_ignores_undefined_methods_200701221649.diff, 1.1 kB (added by jwilger, 2 years ago) |
|---|
-
test/xml_serialization_test.rb
old new 53 53 assert_no_match %r{<age}, @xml 54 54 assert_match %r{<created-at}, @xml 55 55 end 56 57 def test_should_not_try_to_serialize_methods_that_are_not_defined 58 assert_nothing_raised( NoMethodError ) do 59 Contact.new.to_xml( :methods => [ :i_do_not_exist ] ) 60 end 61 end 56 62 end 57 63 58 64 class DefaultXmlSerializationTest < Test::Unit::TestCase -
lib/active_record/xml_serialization.rb
old new 160 160 end 161 161 162 162 def serializable_method_attributes 163 Array(options[:methods]).collect { |name| MethodAttribute.new(name.to_s, @record) } 163 valid_methods = Array(options[:methods]).reject { |name| !@record.respond_to? name } 164 valid_methods.collect { |name| MethodAttribute.new(name.to_s, @record) } 164 165 end 165 166 166 167