aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-04-24 16:05:20 +0000
committerRick Olson <technoweenie@gmail.com>2007-04-24 16:05:20 +0000
commit208d12d15d809391abee90242effd53e3f7e9821 (patch)
treeb6131fc81fa19801464333fd181802c058dc8f92 /activeresource/test
parentfe218684d50400d9e6564d3247d48b4e07f1024a (diff)
downloadrails-208d12d15d809391abee90242effd53e3f7e9821.tar.gz
rails-208d12d15d809391abee90242effd53e3f7e9821.tar.bz2
rails-208d12d15d809391abee90242effd53e3f7e9821.zip
Remove explicit prefix_options parameter for ActiveResource::Base#initialize. Allow ActiveResource::Base.delete with custom prefix. Add ActiveResource::Base#dup [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6568 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/test')
-rw-r--r--activeresource/test/base_test.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index a0e38c991d..2c0a094b3a 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -112,6 +112,10 @@ class BaseTest < Test::Unit::TestCase
assert_equal '/people/1/addresses/1.xml?type%5B%5D=work&type%5B%5D=play+time', StreetAddress.element_path(1, :person_id => 1, :type => ['work', 'play time'])
end
+ def test_custom_element_path_with_prefix_and_parameters
+ assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, {:person_id => 1}, {:type => 'work'})
+ end
+
def test_custom_collection_path
assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1)
end
@@ -120,6 +124,10 @@ class BaseTest < Test::Unit::TestCase
assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work')
end
+ def test_custom_collection_path_with_prefix_and_parameters
+ assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path({:person_id => 1}, {:type => 'work'})
+ end
+
def test_custom_element_name
assert_equal 'address', StreetAddress.element_name
end
@@ -207,7 +215,7 @@ class BaseTest < Test::Unit::TestCase
end
def test_create_with_custom_prefix
- matzs_house = StreetAddress.new({}, { :person_id => 1 })
+ matzs_house = StreetAddress.new(:person_id => 1)
matzs_house.save
assert_equal '5', matzs_house.id
end
@@ -272,11 +280,23 @@ class BaseTest < Test::Unit::TestCase
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/people/1/addresses/1.xml", {}, nil, 404
end
- assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :person_id => 1).destroy }
+ assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :person_id => 1) }
end
def test_delete
assert Person.delete(1)
+ ActiveResource::HttpMock.respond_to do |mock|
+ mock.get "/people/1.xml", {}, nil, 404
+ end
+ assert_raises(ActiveResource::ResourceNotFound) { Person.find(1) }
+ end
+
+ def test_delete_with_custom_prefix
+ assert StreetAddress.delete(1, :person_id => 1)
+ ActiveResource::HttpMock.respond_to do |mock|
+ mock.get "/people/1/addresses/1.xml", {}, nil, 404
+ end
+ assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :person_id => 1) }
end
def test_exists
@@ -297,8 +317,8 @@ class BaseTest < Test::Unit::TestCase
# Nested instance method.
assert StreetAddress.find(1, :person_id => 1).exists?
- assert !StreetAddress.new({:id => 1}, {:person_id => 2}).exists?
- assert !StreetAddress.new({:id => 2}, {:person_id => 1}).exists?
+ assert !StreetAddress.new({:id => 1, :person_id => 2}).exists?
+ assert !StreetAddress.new({:id => 2, :person_id => 1}).exists?
end
def test_to_xml