From 880081549d600a3d592241aadc8b2c6653a3d716 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 6 Jan 2008 20:53:47 +0000 Subject: Use a decorator module for Files instantiated by Hash.from_xml. Add test coverage. Closes #10726 [Cheah Chu Yeow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8579 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/hash_ext_test.rb | 34 +++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 65f14d696f..706e218abc 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -533,9 +533,9 @@ class HashToXmlTest < Test::Unit::TestCase def test_single_record_from_xml_with_attributes_other_than_type topic_xml = <<-EOT - - - + + + EOT @@ -599,6 +599,34 @@ class HashToXmlTest < Test::Unit::TestCase assert_equal expected_blog_hash, Hash.from_xml(blog_xml) end + def test_file_from_xml + blog_xml = <<-XML + + + + + XML + hash = Hash.from_xml(blog_xml) + assert hash.has_key?('blog') + assert hash['blog'].has_key?('logo') + + file = hash['blog']['logo'] + assert_equal 'logo.png', file.original_filename + assert_equal 'image/png', file.content_type + end + + def test_file_from_xml_with_defaults + blog_xml = <<-XML + + + + + XML + file = Hash.from_xml(blog_xml)['blog']['logo'] + assert_equal 'untitled', file.original_filename + assert_equal 'application/octet-stream', file.content_type + end + def test_xsd_like_types_from_xml bacon_xml = <<-EOT -- cgit v1.2.3