diff --git a/lib/stripe/stripe_object.rb b/lib/stripe/stripe_object.rb index 6611f6e1..bdec6316 100644 --- a/lib/stripe/stripe_object.rb +++ b/lib/stripe/stripe_object.rb @@ -21,6 +21,7 @@ module Stripe end def self.construct_from(values, opts={}) + values = Stripe::Util.symbolize_names(values) self.new(values[:id]).refresh_from(values, opts) end diff --git a/test/stripe/stripe_object_test.rb b/test/stripe/stripe_object_test.rb index bb7bc91b..aab578f1 100644 --- a/test/stripe/stripe_object_test.rb +++ b/test/stripe/stripe_object_test.rb @@ -9,6 +9,12 @@ module Stripe assert !obj.respond_to?(:baz) end + should "marshal be insensitive to strings vs. symbols when constructin" do + obj = Stripe::StripeObject.construct_from({ :id => 1, 'name' => 'Stripe' }) + assert_equal 1, obj[:id] + assert_equal 'Stripe', obj[:name] + end + should "marshal a stripe object correctly" do obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }, {:api_key => 'apikey'}) m = Marshal.load(Marshal.dump(obj))