aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/serializeration
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/cases/serializeration')
-rw-r--r--activemodel/test/cases/serializeration/xml_serialization_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/test/cases/serializeration/xml_serialization_test.rb b/activemodel/test/cases/serializeration/xml_serialization_test.rb
index e459f6433a..0737c4f2f9 100644
--- a/activemodel/test/cases/serializeration/xml_serialization_test.rb
+++ b/activemodel/test/cases/serializeration/xml_serialization_test.rb
@@ -82,4 +82,16 @@ class XmlSerializationTest < ActiveModel::TestCase
test "should serialize yaml" do
assert_match %r{<preferences type=\"yaml\">--- \n:gem: ruby\n</preferences>}, @contact.to_xml
end
+
+ test "should call proc on object" do
+ proc = Proc.new { |options| options[:builder].tag!('nationality', 'unknown') }
+ xml = @contact.to_xml(:procs => [ proc ])
+ assert_match %r{<nationality>unknown</nationality>}, xml
+ end
+
+ test 'should supply serializable to second proc argument' do
+ proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) }
+ xml = @contact.to_xml(:procs => [ proc ])
+ assert_match %r{<name-reverse>kcats noraa</name-reverse>}, xml
+ end
end