Skip to content

Commit

Permalink
Fix typo dettach -> detach
Browse files Browse the repository at this point in the history
  • Loading branch information
begedin committed May 15, 2019
1 parent b1ee33c commit 436b837
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/stripe/payment_methods/payment_method.ex
Expand Up @@ -85,11 +85,11 @@ defmodule Stripe.PaymentMethod do
end

@doc """
Dettach payment_method from customer
Detach payment_method from customer
"""
@spec dettach(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
@spec detach(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{:payment_method => Stripe.id() | t()}
def dettach(%{payment_method: _} = params, opts \\ []) do
def detach(%{payment_method: _} = params, opts \\ []) do
endpoint = plural_endpoint(params) <> "/detach"

new_request(opts)
Expand Down
21 changes: 7 additions & 14 deletions test/stripe/payment_methods/payment_method_test.exs
Expand Up @@ -3,8 +3,7 @@ defmodule Stripe.PaymentMethodTest do

describe "list/2" do
test "lists all cards" do
assert {:ok, %Stripe.List{data: cards}} =
Stripe.PaymentMethod.list(%{customer: "cus_123", type: "card"})
assert {:ok, %Stripe.List{data: cards}} = Stripe.PaymentMethod.list(%{customer: "cus_123", type: "card"})

assert_stripe_requested(:get, "/v1/payment_methods?customer=cus_123&type=card")
assert is_list(cards)
Expand All @@ -27,9 +26,7 @@ defmodule Stripe.PaymentMethodTest do
assert {:ok, %Stripe.PaymentMethod{}} =
Stripe.PaymentMethod.attach(%{customer: "cus_123", payment_method: "pm_123"})

assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach",
body: %{customer: "cus_123"}
)
assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach", body: %{customer: "cus_123"})
end

test "attaches payment method to customer with customer provided as struct" do
Expand All @@ -39,9 +36,7 @@ defmodule Stripe.PaymentMethodTest do
payment_method: "pm_123"
})

assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach",
body: %{customer: "cus_123"}
)
assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach", body: %{customer: "cus_123"})
end

test "attaches payment method to customer with payment method provided as struct" do
Expand All @@ -51,23 +46,21 @@ defmodule Stripe.PaymentMethodTest do
payment_method: %Stripe.PaymentMethod{id: "pm_123"}
})

assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach",
body: %{customer: "cus_123"}
)
assert_stripe_requested(:post, "/v1/payment_methods/pm_123/attach", body: %{customer: "cus_123"})
end
end

describe "dettach/2" do
describe "detach/2" do
test "detaches payment method from customer" do
assert {:ok, %Stripe.PaymentMethod{}} =
Stripe.PaymentMethod.dettach(%{customer: "cus_123", payment_method: "pm_123"})
Stripe.PaymentMethod.detach(%{customer: "cus_123", payment_method: "pm_123"})

assert_stripe_requested(:post, "/v1/payment_methods/pm_123/detach")
end

test "detaches payment method from customer with payment method provided as struct" do
assert {:ok, %Stripe.PaymentMethod{}} =
Stripe.PaymentMethod.dettach(%{
Stripe.PaymentMethod.detach(%{
customer: "cus_123",
payment_method: %Stripe.PaymentMethod{id: "pm_123"}
})
Expand Down

0 comments on commit 436b837

Please sign in to comment.