-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return error when inviting an existing collaborator to a project
- Loading branch information
Showing
2 changed files
with
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1071,7 +1071,7 @@ defmodule AskWeb.InviteControllerTest do | |
end | ||
end | ||
|
||
test "send invite to existing user", %{conn: conn, user: user} do | ||
test "send invite to new user", %{conn: conn, user: user} do | ||
project = create_project_for_user(user) | ||
code = "ABC1234" | ||
level = "reader" | ||
|
@@ -1091,4 +1091,28 @@ defmodule AskWeb.InviteControllerTest do | |
|
||
assert json_response(conn, 200) | ||
end | ||
|
||
test "send invite to existing user", %{conn: conn, user: user} do | ||
project = create_project_for_user(user) | ||
code = "ABC1234" | ||
level = "reader" | ||
email = "[email protected]" | ||
|
||
user2 = insert(:user, email: email) | ||
insert(:project_membership, user_id: user2.id, project_id: project.id, level: "editor") | ||
|
||
conn = get( | ||
conn, | ||
send_invitation_path(conn, :send_invitation, %{ | ||
"code" => code, | ||
"level" => level, | ||
"email" => user2.email, | ||
"project_id" => project.id | ||
}) | ||
) | ||
|
||
assert_email_sent(subject: "#{user.name} has added you as a collaborator on #{project.name}.") | ||
|
||
assert json_response(conn, 422) | ||
end | ||
end |