Skip to content

Commit 2064534

Browse files
authored
Merge pull request #693 from code-corps/update-stripity-stripe
Update stripity_stripe. Update stripe fixtures to account for changes.
2 parents f753cd9 + 17d18da commit 2064534

File tree

12 files changed

+25
-20
lines changed

12 files changed

+25
-20
lines changed

lib/code_corps/stripe_testing/account.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule CodeCorps.StripeTesting.Account do
66
end
77

88
def retrieve("account_with_multiple_external_accounts") do
9-
{:ok, load_fixture(Stripe.Account, "account_with_multiple_external_accounts")}
9+
{:ok, load_fixture("account_with_multiple_external_accounts")}
1010
end
1111

1212
def retrieve(id) do
@@ -25,7 +25,7 @@ defmodule CodeCorps.StripeTesting.Account do
2525
|> add_nestings
2626

2727

28-
Stripe.Account |> Stripe.Converter.stripe_map_to_struct(transformed_attributes)
28+
Stripe.Converter.stripe_map_to_struct(transformed_attributes)
2929
end
3030

3131
defp account_fixture do
@@ -47,6 +47,7 @@ defmodule CodeCorps.StripeTesting.Account do
4747
"url" => "/v1/accounts/acct_123/external_accounts"
4848
},
4949
"id" => "acct_123",
50+
"object" => "account",
5051
"managed" => true,
5152
"metadata" => %{},
5253
"statement_descriptor" => "CODECORPS.ORG",

lib/code_corps/stripe_testing/charge.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ defmodule CodeCorps.StripeTesting.Charge do
22
import CodeCorps.StripeTesting.Helpers
33

44
def retrieve(id, _opts) do
5-
{:ok, load_fixture(Stripe.Charge, id)}
5+
{:ok, load_fixture(id)}
66
end
77
end

lib/code_corps/stripe_testing/helpers.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
defmodule CodeCorps.StripeTesting.Helpers do
2+
@moduledoc """
3+
Used to load JSON fitures which simulate Stripe API responses into
4+
stripity_stripe structs
5+
"""
26
@fixture_path "./lib/code_corps/stripe_testing/fixtures/"
37

48
@doc """
59
Load a stripe response fixture through stripity_stripe, into a
610
stripity_stripe struct
711
"""
8-
@spec load_fixture(module, String.t) :: struct
9-
def load_fixture(module, id) do
12+
@spec load_fixture(String.t) :: struct
13+
def load_fixture(id) do
1014
fixture_map = id |> build_file_path |> File.read! |> Poison.decode!
11-
Stripe.Converter.stripe_map_to_struct(module, fixture_map)
15+
Stripe.Converter.stripe_map_to_struct(fixture_map)
1216
end
1317

1418
defp build_file_path(id), do: id |> append_extension |> join_with_path

lib/code_corps/stripe_testing/invoice.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ defmodule CodeCorps.StripeTesting.Invoice do
22
import CodeCorps.StripeTesting.Helpers
33

44
def retrieve(id, _opts) do
5-
{:ok, load_fixture(Stripe.Invoice, id)}
5+
{:ok, load_fixture(id)}
66
end
77
end

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"segment": {:hex, :segment, "0.1.1", "47bf9191590e7a533c105d1e21518e0d6da47c91e8d98ebb649c624db5dfc359", [:mix], [{:httpoison, "~> 0.8", [hex: :httpoison, optional: false]}, {:poison, "~> 1.3 or ~> 2.0", [hex: :poison, optional: false]}]},
6161
"sentry": {:hex, :sentry, "2.1.0", "51e7ca261b519294ac73b30763893c4a7ad2005205514aefa5bf37ccb83e44ea", [:mix], [{:hackney, "~> 1.6.1", [hex: :hackney, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: true]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}, {:uuid, "~> 1.0", [hex: :uuid, optional: false]}]},
6262
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:make, :rebar], []},
63-
"stripity_stripe": {:git, "https://github.com/code-corps/stripity_stripe.git", "fab5b573f327f760d51949488bab30c2eae346b5", [branch: "2.0"]},
63+
"stripity_stripe": {:git, "https://github.com/code-corps/stripity_stripe.git", "6a394e8254551b4da112236e529cd829926534d1", [branch: "2.0"]},
6464
"sweet_xml": {:hex, :sweet_xml, "0.6.4", "5d613e63033b1d6362898f3f1d65f70a352b32d4b32e1367bb20b8c2e30ba79d", [:mix], []},
6565
"timber": {:hex, :timber, "0.4.7", "df3fcd79bcb4eb4b53874d906ef5f3a212937b4bc7b7c5b244745202cc389443", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, optional: true]}, {:phoenix, "~> 1.2", [hex: :phoenix, optional: true]}, {:plug, "~> 1.2", [hex: :plug, optional: true]}, {:poison, "~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}]},
6666
"timex": {:hex, :timex, "3.0.8", "71d5ebafcdc557c6c866cdc196c5054f587e7cd1118ad8937e2293d51fc85608", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},

test/lib/code_corps/emails/receipt_email_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule CodeCorps.Emails.ReceiptEmailTest do
55
alias CodeCorps.Emails.ReceiptEmail
66

77
test "receipt email works" do
8-
invoice_fixture = CodeCorps.StripeTesting.Helpers.load_fixture(Stripe.Invoice, "invoice")
8+
invoice_fixture = CodeCorps.StripeTesting.Helpers.load_fixture("invoice")
99

1010
user = insert(:user, email: "jimmy@mail.com", first_name: "Jimmy")
1111

test/lib/code_corps/stripe_service/adapters/stripe_connect_account_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule CodeCorps.StripeService.Adapters.StripeConnectAccountTest do
66
defp test_account() do
77
# If a `Stripe.Account` has multiple `Stripe.ExternalAccount` records, we want
88
# the adapter to deal with that by only taking one, so we load the appropriate fixture
9-
CodeCorps.StripeTesting.Helpers.load_fixture(Stripe.Account, "account_with_multiple_external_accounts")
9+
CodeCorps.StripeTesting.Helpers.load_fixture("account_with_multiple_external_accounts")
1010
end
1111

1212
@local_map %{

test/lib/code_corps/stripe_service/adapters/stripe_connect_charge_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule CodeCorps.StripeService.Adapters.StripeConnectChargeTest do
66
describe "to_params/2" do
77
test "adds customer and user id if those records exist" do
88
# load a predefined fixture to use for adapter testing
9-
fixture = CodeCorps.StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
9+
fixture = CodeCorps.StripeTesting.Helpers.load_fixture("charge")
1010

1111
account = insert(:stripe_connect_account)
1212

test/lib/code_corps/stripe_service/events/connect_charge_succeeded_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ defmodule CodeCorps.StripeService.Events.ConnectChargeSucceededTest do
1414
test "handling event creates charge and sends receipt" do
1515
account = insert(:stripe_connect_account)
1616

17-
charge_fixture = StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
17+
charge_fixture = StripeTesting.Helpers.load_fixture("charge")
1818

1919
insert(:stripe_connect_customer, id_from_stripe: charge_fixture.customer)
2020

21-
invoice_fixture = StripeTesting.Helpers.load_fixture(Stripe.Invoice, charge_fixture.invoice)
21+
invoice_fixture = StripeTesting.Helpers.load_fixture(charge_fixture.invoice)
2222
insert(:stripe_connect_subscription, id_from_stripe: invoice_fixture.subscription)
2323

2424
project = Repo.one(Project)

test/lib/code_corps/stripe_service/stripe_connect_charge_service_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule CodeCorps.StripeService.StripeConnectChargeServiceTest do
99
describe "create" do
1010
test "creates a StripeConnectCharge, with proper associations" do
1111
# we load in the fixture we will be using, so we have access to the data it contains
12-
fixture = StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
12+
fixture = StripeTesting.Helpers.load_fixture("charge")
1313
customer = insert(:stripe_connect_customer, id_from_stripe: fixture.customer)
1414

1515
# service expects a Stripe.Charge id, so we pass in an id for a predefined fixture we have

test/lib/code_corps/stripe_service/stripe_invoice_service_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule CodeCorps.StripeService.StripeInvoiceServiceTest do
88

99
describe "create" do
1010
test "creates a StripeInvoice" do
11-
invoice_fixture = CodeCorps.StripeTesting.Helpers.load_fixture(Stripe.Invoice, "invoice")
11+
invoice_fixture = CodeCorps.StripeTesting.Helpers.load_fixture("invoice")
1212

1313
subscription = insert(:stripe_connect_subscription, id_from_stripe: invoice_fixture.subscription)
1414
connect_customer = insert(:stripe_connect_customer, id_from_stripe: invoice_fixture.customer)

test/lib/code_corps/stripe_service/webhook_processing/event_handler_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ defmodule CodeCorps.StripeService.WebhookProcessing.EventHandlerTest do
8282
test "handles charge.succeeded as processed when everything is in order" do
8383
connect_account = insert(:stripe_connect_account)
8484

85-
charge_fixture = StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
85+
charge_fixture = StripeTesting.Helpers.load_fixture("charge")
8686
insert(:stripe_connect_customer, id_from_stripe: charge_fixture.customer)
8787

88-
invoice_fixture = StripeTesting.Helpers.load_fixture(Stripe.Invoice, charge_fixture.invoice)
88+
invoice_fixture = StripeTesting.Helpers.load_fixture(charge_fixture.invoice)
8989
insert(:stripe_connect_subscription, id_from_stripe: invoice_fixture.subscription)
9090

9191
project = Repo.one(Project)
@@ -101,7 +101,7 @@ defmodule CodeCorps.StripeService.WebhookProcessing.EventHandlerTest do
101101

102102
test "handles charge.succeeded as errored when something goes wrong with email" do
103103
connect_account = insert(:stripe_connect_account)
104-
charge_fixture = StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
104+
charge_fixture = StripeTesting.Helpers.load_fixture("charge")
105105

106106
insert(:stripe_connect_customer, id_from_stripe: charge_fixture.customer)
107107

@@ -114,7 +114,7 @@ defmodule CodeCorps.StripeService.WebhookProcessing.EventHandlerTest do
114114
end
115115

116116
test "handles charge.succeeded as errored when something goes wrong with creating a charge" do
117-
charge_fixture = StripeTesting.Helpers.load_fixture(Stripe.Charge, "charge")
117+
charge_fixture = StripeTesting.Helpers.load_fixture("charge")
118118

119119
event = build_event("charge.succeeded", "charge", charge_fixture, "bad_account")
120120
{:ok, event} = EventHandler.handle(event, ConnectEventHandler, "bad_account")
@@ -185,7 +185,7 @@ defmodule CodeCorps.StripeService.WebhookProcessing.EventHandlerTest do
185185
end
186186

187187
test "handles invoice.payment_succeeded" do
188-
fixture = StripeTesting.Helpers.load_fixture(Stripe.Invoice, "invoice")
188+
fixture = StripeTesting.Helpers.load_fixture("invoice")
189189

190190
insert(:stripe_connect_subscription, id_from_stripe: fixture.subscription)
191191

0 commit comments

Comments
 (0)