Merge pull request #472 from IndieBarry/ybk-fix-method-not-defined

Create accessor methods in update_attributes
This commit is contained in:
Brandur 2016-10-24 09:12:24 -07:00 committed by GitHub
commit 2d4cdd95ac
2 changed files with 8 additions and 1 deletions

View File

@ -84,8 +84,8 @@ module Stripe
# Default to true. TODO: Convert to optional arguments after we're off
# 1.9 which will make this quite a bit more clear.
dirty = method_options.fetch(:dirty, true)
values.each do |k, v|
add_accessors([k], values) unless metaclass.method_defined?(k.to_sym)
@values[k] = Util.convert_to_stripe_object(v, opts)
dirty_value!(@values[k]) if dirty
@unsaved_values.add(k)

View File

@ -90,6 +90,13 @@ module Stripe
assert_equal Stripe::StripeObject, obj.metadata.class
end
should "create accessors when #update_attributes is called" do
obj = Stripe::StripeObject.construct_from({})
assert_equal false, obj.send(:metaclass).method_defined?(:foo)
obj.update_attributes(:foo => 'bar')
assert_equal true, obj.send(:metaclass).method_defined?(:foo)
end
should "warn that #refresh_from is deprecated" do
old_stderr = $stderr
$stderr = StringIO.new