Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return the result of APIResource#refresh in APIResource.retrieve #1473

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):

```sh
go get -u github.com/stripe/stripe-mock
go install github.com/stripe/stripe-mock@latest
stripe-mock
```

Expand Down
1 change: 0 additions & 1 deletion lib/stripe/api_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def self.retrieve(id, opts = {})
opts = Util.normalize_opts(opts)
instance = new(id, opts)
instance.refresh
instance
end

def request_stripe_object(method:, path:, params:, base_address: :api, opts: {})
Expand Down
17 changes: 17 additions & 0 deletions test/stripe/api_resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,23 @@ def self.object_name
end
end

class CustomStripeObject < APIResource
def self.resource_url
"/v1/custom_stripe_object"
end
end

context "custom class extending APIResource" do
should "return StripeObject instance when calling retrieve" do
stub_request(:get, "#{Stripe.api_base}/v1/custom_stripe_object/id")
.to_return(body: JSON.generate({ id: "id", object: "custom_stripe_object", result: "hello" }))

custom_stripe_object = CustomStripeObject.retrieve("id")
assert_instance_of Stripe::StripeObject, custom_stripe_object
assert_equal "hello", custom_stripe_object.result
end
end

@@fixtures = {} # rubocop:disable Style/ClassVars
setup do
if @@fixtures.empty?
Expand Down
Loading