diff options
Diffstat (limited to 'activeresource')
-rw-r--r-- | activeresource/CHANGELOG | 4 | ||||
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 5 | ||||
-rw-r--r-- | activeresource/test/base_test.rb | 4 |
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 |