aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activeresource/CHANGELOG2
-rw-r--r--activeresource/lib/active_resource/base.rb2
-rw-r--r--activeresource/test/base_test.rb10
3 files changed, 12 insertions, 2 deletions
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG
index fcef27535e..35321a2f4f 100644
--- a/activeresource/CHANGELOG
+++ b/activeresource/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [alloy]
+
* Recognize and raise an exception on 405 Method Not Allowed responses. #7692 [Josh Peek]
* Handle string and symbol param keys when splitting params into prefix params and query params.
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index a0e92dba72..3048aa5b89 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -161,7 +161,7 @@ module ActiveResource
else
prefix_options, query_options = split_options(options[:params])
path = collection_path(prefix_options, query_options)
- instantiate_collection(connection.get(path, headers) || [])
+ instantiate_collection( (connection.get(path, headers) || []), prefix_options )
end
end
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index db02cc2716..bf73732c8f 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -313,7 +313,7 @@ class BaseTest < Test::Unit::TestCase
assert_equal true, matz.save
end
- def test_update_with_custom_prefix
+ def test_update_with_custom_prefix_with_specific_id
addy = StreetAddress.find(1, :params => { :person_id => 1 })
addy.street = "54321 Street"
assert_kind_of StreetAddress, addy
@@ -321,6 +321,14 @@ class BaseTest < Test::Unit::TestCase
addy.save
end
+ def test_update_with_custom_prefix_without_specific_id
+ addy = StreetAddress.find(:first, :params => { :person_id => 1 })
+ addy.street = "54321 Lane"
+ assert_kind_of StreetAddress, addy
+ assert_equal "54321 Lane", addy.street
+ addy.save
+ end
+
def test_update_conflict
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/people/2.xml", {}, @david