| | 444 | |
|---|
| | 445 | def test_unspecified_collection_types |
|---|
| | 446 | # Tests and data to prove that we've fixed the "undefined method 'collect!' for Hash" problem |
|---|
| | 447 | @people_xml = <<XML |
|---|
| | 448 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| | 449 | <people> |
|---|
| | 450 | <person> |
|---|
| | 451 | <name>Matz</name> |
|---|
| | 452 | <id type="integer">1</id> |
|---|
| | 453 | </person> |
|---|
| | 454 | <person> |
|---|
| | 455 | <name>David</name> |
|---|
| | 456 | <id type="integer">2</id> |
|---|
| | 457 | </person> |
|---|
| | 458 | </people> |
|---|
| | 459 | XML |
|---|
| | 460 | |
|---|
| | 461 | @people_david_xml = <<XML |
|---|
| | 462 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| | 463 | <people> |
|---|
| | 464 | <person> |
|---|
| | 465 | <name>David</name> |
|---|
| | 466 | <id type="integer">2</id> |
|---|
| | 467 | </person> |
|---|
| | 468 | </people> |
|---|
| | 469 | XML |
|---|
| | 470 | |
|---|
| | 471 | ActiveResource::HttpMock.respond_to { |m| |
|---|
| | 472 | m.get "/firms/1/people.xml", {}, @people_xml |
|---|
| | 473 | m.get "/partners/1/people.xml", {}, @people_david_xml |
|---|
| | 474 | } |
|---|
| | 475 | |
|---|
| | 476 | people = Person.find(:all, :from => "/firms/1/people.xml") |
|---|
| | 477 | |
|---|
| | 478 | assert_equal 2, people.size |
|---|
| | 479 | assert_kind_of Person, people.first |
|---|
| | 480 | assert_equal "Matz", people.first.name |
|---|
| | 481 | assert_equal "David", people.last.name |
|---|
| | 482 | |
|---|
| | 483 | people = Person.find(:all, :from => "/partners/1/people.xml") |
|---|
| | 484 | assert_equal 1, people.size |
|---|
| | 485 | assert_equal "David", people.first.name |
|---|
| | 486 | end |
|---|