Skip to content

Commit

Permalink
Merge pull request #746 from stripe/remi-fix-tests
Browse files Browse the repository at this point in the history
Fix tests to work on latest stripe-mock for future updates
  • Loading branch information
remi-stripe authored Mar 5, 2019
2 parents c139dc8 + 1094e89 commit df8c141
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.44.0
- STRIPE_MOCK_VERSION=0.47.0

cache:
directories:
Expand Down
9 changes: 7 additions & 2 deletions test/stripe/account_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ class AccountTest < Test::Unit::TestCase

context "#legal_entity=" do
should "disallow direct overrides" do
account = Stripe::Account.retrieve("acct_123")
account = Stripe::Account.construct_from(
id: "acct_123",
legal_entity: {
first_name: "name",
}
)

assert_raise NoMethodError do
account.legal_entity = { first_name: "Blah" }
Expand All @@ -111,7 +116,7 @@ class AccountTest < Test::Unit::TestCase
end

context "#serialize_params" do
should "serialize an a new additional_owners" do
should "serialize a new additional_owners" do
obj = Stripe::Util.convert_to_stripe_object({
object: "account",
legal_entity: Stripe::StripeObject.construct_from({
Expand Down
26 changes: 14 additions & 12 deletions test/stripe/api_resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,22 @@ class NestedTestAPIResource < Stripe::APIResource
end

should "correctly handle replaced nested objects" do
acct = Stripe::Account.construct_from(id: "myid",
legal_entity: {
last_name: "Smith",
address: {
line1: "test",
city: "San Francisco",
},
})

stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
.with(body: { legal_entity: { address: { line1: "Test2", city: "" } } })
acct = Stripe::Account.construct_from(
id: "acct_123",
company: {
name: "company_name",
address: {
line1: "test",
city: "San Francisco",
},
}
)

stub_request(:post, "#{Stripe.api_base}/v1/accounts/acct_123")
.with(body: { company: { address: { line1: "Test2", city: "" } } })
.to_return(body: JSON.generate("id" => "my_id"))

acct.legal_entity.address = { line1: "Test2" }
acct.company.address = { line1: "Test2" }
acct.save
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require ::File.expand_path("../stripe_mock", __FILE__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.44.0".freeze
MOCK_MINIMUM_VERSION = "0.47.0".freeze
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down

0 comments on commit df8c141

Please sign in to comment.