aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-05-09 03:51:06 +0000
committerRick Olson <technoweenie@gmail.com>2007-05-09 03:51:06 +0000
commit08736788c906d2b05fe6c45e6922e594149c9b12 (patch)
tree40430c567a1662a958ee78aa230b5c1431dc4fdb /activeresource
parent2b6ad48ea3c80e693b3c92f90432c790c8ee1510 (diff)
downloadrails-08736788c906d2b05fe6c45e6922e594149c9b12.tar.gz
rails-08736788c906d2b05fe6c45e6922e594149c9b12.tar.bz2
rails-08736788c906d2b05fe6c45e6922e594149c9b12.zip
Handle string and symbol param keys when splitting params into prefix params and query params.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6703 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource')
-rw-r--r--activeresource/CHANGELOG4
-rw-r--r--activeresource/lib/active_resource/base.rb5
-rw-r--r--activeresource/test/base_test.rb4
3 files changed, 11 insertions, 2 deletions
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG
index bb23e0d2ac..cd1cb557c9 100644
--- a/activeresource/CHANGELOG
+++ b/activeresource/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Handle string and symbol param keys when splitting params into prefix params and query params.
+
+ Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 })
+
* Added find-one with symbol [DHH]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml
* BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [DHH]. Changes:
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 0f147acad9..a0e92dba72 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -215,7 +215,8 @@ module ActiveResource
prefix_options, query_options = {}, {}
(options || {}).each do |key, value|
- (prefix_parameters.include?(key) ? prefix_options : query_options)[key] = value
+ next if key.blank?
+ (prefix_parameters.include?(key.to_sym) ? prefix_options : query_options)[key.to_sym] = value
end
[ prefix_options, query_options ]
@@ -360,7 +361,7 @@ module ActiveResource
def load_attributes_from_response(response)
if response['Content-size'] != "0" && response.body.strip.size > 0
load(connection.xml_from_response(response))
- end
+ end
end
# Takes a response from a typical create post and pulls the ID out
diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb
index e9bf5d70b3..db02cc2716 100644
--- a/activeresource/test/base_test.rb
+++ b/activeresource/test/base_test.rb
@@ -109,10 +109,12 @@ class BaseTest < Test::Unit::TestCase
def test_custom_element_path
assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1)
+ assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1)
end
def test_custom_element_path_with_parameters
assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :person_id => 1, :type => 'work')
+ assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, 'person_id' => 1, :type => 'work')
assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :type => 'work', :person_id => 1)
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
@@ -123,10 +125,12 @@ class BaseTest < Test::Unit::TestCase
def test_custom_collection_path
assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1)
+ assert_equal '/people/1/addresses.xml', StreetAddress.collection_path('person_id' => 1)
end
def test_custom_collection_path_with_parameters
assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work')
+ 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