Skip to content

Commit

Permalink
Add test for send_invitation
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelbej committed Sep 3, 2024
1 parent fa5692c commit 396a792
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ config :ask, Verboice,
app_id: "AN_APP_ID"
]

config :ask, Ask.Mailer, adapter: Ask.Swoosh.Adapters.Test
config :ask, Ask.Mailer, adapter: Swoosh.Adapters.Test

config :ask, AskWeb.Email,
smtp_from_address: {:system, "SMTP_FROM_ADDRESS", "Test name <test@email>"}
Expand Down
22 changes: 22 additions & 0 deletions test/ask_web/controllers/invite_controller_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule AskWeb.InviteControllerTest do
import Ecto.Query
import Swoosh.TestAssertions

use AskWeb.ConnCase
use Ask.TestHelpers
Expand Down Expand Up @@ -1069,4 +1070,25 @@ defmodule AskWeb.InviteControllerTest do
)
end
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]"

conn = get(
conn,
send_invitation_path(conn, :send_invitation, %{
"code" => code,
"level" => level,
"email" => email,
"project_id" => project.id
})
)

assert_email_sent(subject: "#{user.name} has invited you to collaborate on #{project.name}.")

assert json_response(conn, 200)
end
end

0 comments on commit 396a792

Please sign in to comment.