From 83555a539891d18c37e788ebd5bdc819d4cfe7f5 Mon Sep 17 00:00:00 2001 From: Sidu Ponnappa Date: Wed, 25 May 2011 17:25:32 +0530 Subject: Issue #636 - Parsing an xml file with multiple records and extra attributes (besides type) fails --- activesupport/test/core_ext/hash_ext_test.rb | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'activesupport/test/core_ext/hash_ext_test.rb') diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 0b3f18faec..1813ba2a4d 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -670,6 +670,55 @@ class HashToXmlTest < Test::Unit::TestCase assert_match %r{1999-02-01T19:00:00-05:00}, xml end + def test_multiple_records_from_xml_with_attributes_other_than_type_ignores_them_without_exploding + topics_xml = <<-EOT + + + The First Topic + David + 1 + false + 0 + 2592000000 + 2003-07-16 + 2003-07-16T09:28:00+0000 + Have a nice day + david@loudthinking.com + + + + The Second Topic + Jason + 1 + false + 0 + 2592000000 + 2003-07-16 + 2003-07-16T09:28:00+0000 + Have a nice day + david@loudthinking.com + + + + EOT + + expected_topic_hash = { + :title => "The First Topic", + :author_name => "David", + :id => 1, + :approved => false, + :replies_count => 0, + :replies_close_in => 2592000000, + :written_on => Date.new(2003, 7, 16), + :viewed_at => Time.utc(2003, 7, 16, 9, 28), + :content => "Have a nice day", + :author_email_address => "david@loudthinking.com", + :parent_id => nil + }.stringify_keys + + assert_equal expected_topic_hash, Hash.from_xml(topics_xml)["topics"].first + end + def test_single_record_from_xml topic_xml = <<-EOT -- cgit v1.2.3