-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from danschultzer/pow-invitation
Pow invitation
- Loading branch information
Showing
13 changed files
with
166 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ defmodule PowAssent.Ecto.SchemaTest do | |
|
||
alias PowAssent.Test.Ecto.{Repo, Users.User} | ||
alias PowAssent.Test.EmailConfirmation.Users.User, as: UserConfirmEmail | ||
alias PowAssent.Test.Invitation.Users.User, as: InvitationUser | ||
|
||
test "user_schema/1" do | ||
user = %User{} | ||
|
@@ -65,6 +66,17 @@ defmodule PowAssent.Ecto.SchemaTest do | |
changeset = User.user_identity_changeset(%User{}, @user_identity, %{email: "[email protected]"}, nil) | ||
refute changeset.changes[:email_confirmed_at] | ||
end | ||
|
||
test "sets :invitation_accepted_at when is invited user" do | ||
changeset = InvitationUser.user_identity_changeset(%InvitationUser{}, @user_identity, %{}, %{email: "[email protected]"}) | ||
refute changeset.changes[:invitation_accepted_at] | ||
|
||
changeset = InvitationUser.user_identity_changeset(%InvitationUser{invitation_token: "token", invitation_accepted_at: DateTime.utc_now()}, @user_identity, %{}, %{email: "[email protected]"}) | ||
refute changeset.changes[:invitation_accepted_at] | ||
|
||
changeset = InvitationUser.user_identity_changeset(%InvitationUser{invitation_token: "token"}, @user_identity, %{}, %{email: "[email protected]"}) | ||
assert changeset.changes[:invitation_accepted_at] | ||
end | ||
end | ||
|
||
defmodule OverrideAssocUser do | ||
|
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
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
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,33 @@ | ||
defmodule PowAssent.Test.Invitation.Phoenix.Endpoint do | ||
@moduledoc false | ||
use Phoenix.Endpoint, otp_app: :pow_assent | ||
|
||
plug Plug.RequestId | ||
plug Plug.Logger | ||
|
||
plug Plug.Parsers, | ||
parsers: [:urlencoded, :multipart, :json], | ||
pass: ["*/*"], | ||
json_decoder: Phoenix.json_library() | ||
|
||
plug Plug.MethodOverride | ||
plug Plug.Head | ||
|
||
plug Plug.Session, | ||
store: :cookie, | ||
key: "_binaryid_key", | ||
signing_salt: "secret" | ||
|
||
plug Pow.Plug.Session, | ||
user: PowAssent.Test.Invitation.Users.User, | ||
routes_backend: PowAssent.Test.Phoenix.Routes, | ||
messages_backend: PowAssent.Test.Phoenix.Messages, | ||
mailer_backend: PowAssent.Test.Phoenix.MailerMock, | ||
repo: PowAssent.Test.Invitation.RepoMock, | ||
otp_app: :pow_assent, | ||
pow_assent: [ | ||
user_identities_context: PowAssent.Test.UserIdentitiesMock | ||
] | ||
|
||
plug PowAssent.Test.Phoenix.Router | ||
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,9 @@ | ||
defmodule PowAssent.Test.Invitation.RepoMock do | ||
@moduledoc false | ||
|
||
alias PowAssent.Test.Invitation.Users.User | ||
|
||
@user %User{id: 1, email: "[email protected]"} | ||
|
||
def get_by(User, [invitation_token: "token"]), do: %{@user | invitation_token: "token"} | ||
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,19 @@ | ||
defmodule PowAssent.Test.Invitation.Users.User do | ||
@moduledoc false | ||
use Ecto.Schema | ||
use Pow.Ecto.Schema | ||
use Pow.Extension.Ecto.Schema, | ||
extensions: [PowInvitation] | ||
use PowAssent.Ecto.Schema | ||
|
||
schema "users" do | ||
has_many :user_identities, | ||
PowAssent.Test.Invitation.UserIdentities.UserIdentity, | ||
on_delete: :delete_all, | ||
foreign_key: :user_id | ||
|
||
pow_user_fields() | ||
|
||
timestamps() | ||
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,10 @@ | ||
defmodule PowAssent.Test.Invitation.UserIdentities.UserIdentity do | ||
@moduledoc false | ||
use Ecto.Schema | ||
use PowAssent.Ecto.UserIdentities.Schema, | ||
user: PowAssent.Test.Invitation.Users.User | ||
|
||
schema "user_identities" do | ||
pow_assent_user_identity_fields() | ||
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