mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #2585 from marcgg/fix-ruby19-splitoptions
In some case ActiveResource fails to handle serialized attributes with Ruby 1.9 and crashes
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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"/>' }
|
||||
|
||||
Reference in New Issue
Block a user