diff options
author | José Valim <jose.valim@gmail.com> | 2011-09-01 10:08:37 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-09-01 10:08:37 -0700 |
commit | 47f465df5d8aa03c29d3cf83a8a20e793401e8f4 (patch) | |
tree | a071bc72ffcd34d897758845a4f660450548c39a | |
parent | da516e8f544c591bbebbfd8461c60e31ecc76d22 (diff) | |
parent | 28d605ff7fe1de0ae9b3bcdb48ac6209859c7ecf (diff) | |
download | rails-47f465df5d8aa03c29d3cf83a8a20e793401e8f4.tar.gz rails-47f465df5d8aa03c29d3cf83a8a20e793401e8f4.tar.bz2 rails-47f465df5d8aa03c29d3cf83a8a20e793401e8f4.zip |
Merge pull request #2585 from marcgg/fix-ruby19-splitoptions
In some case ActiveResource fails to handle serialized attributes with Ruby 1.9 and crashes
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 2 | ||||
-rw-r--r-- | activeresource/test/cases/base/load_test.rb | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 693bd0592e..990d9a38dd 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -955,7 +955,7 @@ module ActiveResource prefix_options, query_options = {}, {} (options || {}).each do |key, value| - next if key.blank? + next if key.blank? || !key.respond_to?(:to_sym) (prefix_parameters.include?(key.to_sym) ? prefix_options : query_options)[key.to_sym] = value end diff --git a/activeresource/test/cases/base/load_test.rb b/activeresource/test/cases/base/load_test.rb index 0d030148d0..0bbd3ab5f5 100644 --- a/activeresource/test/cases/base/load_test.rb +++ b/activeresource/test/cases/base/load_test.rb @@ -51,9 +51,28 @@ class BaseLoadTest < Test::Unit::TestCase :votes => [ true, false, true ], :places => [ "Columbia City", "Unknown" ]}}} + + # List of books formated as [{timestamp_of_publication => name}, ...] + @books = {:books => [ + {1009839600 => "Ruby in a Nutshell"}, + {1199142000 => "The Ruby Programming Language"} + ]} + + @books_date = {:books => [ + {Time.at(1009839600) => "Ruby in a Nutshell"}, + {Time.at(1199142000) => "The Ruby Programming Language"} + ]} @person = Person.new end + def test_load_hash_with_integers_as_keys + assert_nothing_raised{person = @person.load(@books)} + end + + def test_load_hash_with_dates_as_keys + assert_nothing_raised{person = @person.load(@books_date)} + end + def test_load_expects_hash assert_raise(ArgumentError) { @person.load nil } assert_raise(ArgumentError) { @person.load '<person id="1"/>' } |