diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-12-12 15:29:54 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-12-12 15:29:54 +0000 |
commit | 55d4dbb8df9b4e6e46d461352f97e35ba69b417e (patch) | |
tree | 399c3929848e39f21f5770a9e11e5138407ea745 /activeresource/test/connection_test.rb | |
parent | 2f5ee5a812bee922b198c7efbe3ffff29d072ffd (diff) | |
download | rails-55d4dbb8df9b4e6e46d461352f97e35ba69b417e.tar.gz rails-55d4dbb8df9b4e6e46d461352f97e35ba69b417e.tar.bz2 rails-55d4dbb8df9b4e6e46d461352f97e35ba69b417e.zip |
Fix issues with ActiveResource collection handling. Closes #6291. [bmilekic]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5714 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test/connection_test.rb')
-rw-r--r-- | activeresource/test/connection_test.rb | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb index 0a42e17417..99f0b8de89 100644 --- a/activeresource/test/connection_test.rb +++ b/activeresource/test/connection_test.rb @@ -6,10 +6,19 @@ class ConnectionTest < Test::Unit::TestCase def setup @conn = ActiveResource::Connection.new('http://localhost') - @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') - @david = { :id => 2, :name => 'David' }.to_xml(:root => 'person') + @matz = { :id => 1, :name => 'Matz' } + @david = { :id => 2, :name => 'David' } + @people = [ @matz, @david ].to_xml(:root => 'people') + @people_single = [ @matz ].to_xml(:root => 'people-single-elements') + @people_empty = [ ].to_xml(:root => 'people-empty-elements') + @matz = @matz.to_xml(:root => 'person') + @david = @david.to_xml(:root => 'person') + @default_request_headers = { 'Content-Type' => 'application/xml' } ActiveResource::HttpMock.respond_to do |mock| + mock.get "/people.xml", {}, @people + mock.get "/people_single_elements.xml", {}, @people_single + mock.get "/people_empty_elements.xml", {}, @people_empty mock.get "/people/1.xml", {}, @matz mock.put "/people/1.xml", {}, nil, 204 mock.delete "/people/1.xml", {}, nil, 200 @@ -67,7 +76,23 @@ class ConnectionTest < Test::Unit::TestCase def test_get matz = @conn.get("/people/1.xml") - assert_equal "Matz", matz["person"]["name"] + assert_equal "Matz", matz["name"] + end + + def test_get_collection + people = @conn.get("/people.xml") + assert_equal "Matz", people[0]["name"] + assert_equal "David", people[1]["name"] + end + + def test_get_collection_single + people = @conn.get("/people_single_elements.xml") + assert_equal "Matz", people[0]["name"] + end + + def test_get_collection_empty + people = @conn.get("/people_empty_elements.xml") + assert_equal people, nil end def test_post |