-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stripe external account model, migration, and test
- Loading branch information
1 parent
ea785e5
commit 7898517
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
priv/repo/migrations/20161214005935_create_stripe_external_account.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule CodeCorps.Repo.Migrations.CreateStripeExternalAccount do | ||
use Ecto.Migration | ||
|
||
def change do | ||
create table(:stripe_external_accounts) do | ||
add :id_from_stripe, :string, null: false | ||
add :account_id_from_stripe, :string, null: false | ||
add :account_holder_name, :string | ||
add :account_holder_type, :string | ||
add :bank_name, :string | ||
add :country, :string | ||
add :currency, :string | ||
add :default_for_currency, :string | ||
add :fingerprint, :string | ||
add :last4, :string | ||
add :routing_number, :string | ||
add :status, :string | ||
|
||
timestamps() | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule CodeCorps.StripeExternalAccountTest do | ||
use CodeCorps.ModelCase | ||
|
||
alias CodeCorps.StripeExternalAccount | ||
|
||
@valid_attrs %{account_id_from_stripe: "some content", id_from_stripe: "some content"} | ||
@invalid_attrs %{} | ||
|
||
test "changeset with valid attributes" do | ||
changeset = StripeExternalAccount.changeset(%StripeExternalAccount{}, @valid_attrs) | ||
assert changeset.valid? | ||
end | ||
|
||
test "changeset with invalid attributes" do | ||
changeset = StripeExternalAccount.changeset(%StripeExternalAccount{}, @invalid_attrs) | ||
refute changeset.valid? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule CodeCorps.StripeExternalAccount do | ||
use CodeCorps.Web, :model | ||
|
||
schema "stripe_external_accounts" do | ||
field :id_from_stripe, :string, null: false | ||
field :account_id_from_stripe, :string, null: false | ||
field :account_holder_name, :string | ||
field :account_holder_type, :string | ||
field :bank_name, :string | ||
field :country, :string | ||
field :currency, :string | ||
field :default_for_currency, :string | ||
field :fingerprint, :string | ||
field :last4, :string | ||
field :routing_number, :string | ||
field :status, :string | ||
|
||
timestamps() | ||
end | ||
|
||
@doc """ | ||
Builds a changeset based on the `struct` and `params`. | ||
""" | ||
def changeset(struct, params \\ %{}) do | ||
struct | ||
|> cast(params, [:id_from_stripe, :account_id_from_stripe, :account_holder_name, :account_holder_type, :bank_name, :country, :currency, :default_for_currency, :fingerprint, :last4, :routing_number, :status]) | ||
|> validate_required([:id_from_stripe, :account_id_from_stripe]) | ||
end | ||
end |