accent/test/emails/create_comment_email_test.exs
Simon Prévost bca59c4caa Initial commit 💥
2018-04-05 16:47:36 -04:00

33 lines
1.6 KiB
Elixir
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

defmodule AccentTest.CreateCommentEmail do
use ExUnit.Case
use Bamboo.Test
test "create" do
project = %Accent.Project{id: "ec44dc76-9c55-4f64-bb9b-4cf5ff0123ac", name: "My project name"}
revision = %Accent.Revision{id: "ec44dc76-9c55-4f64-bb9b-4cf5ff0123ab", project: project}
translation = %Accent.Translation{id: "dc44dc76-9c55-4f64-bb9b-4cf5ff0123ab", key: "My key", corrected_text: "FOO", revision: revision}
user = %Accent.User{email: "test@test.com"}
comment = %Accent.Comment{text: "This is a comment", translation: translation, user: user}
emails = ["new@test.com", "foo@bar.test"]
email = Accent.CreateCommentEmail.create(emails, comment)
assert email.to == emails
assert email.from == {"Accent", "accent-test@example.com"}
assert email.subject == ~s(Accent New comment on "#{project.name}")
assert email.headers == %{"X-SMTPAPI" => ~s({"category": ["test", "accent-api-test"]})}
assert email.html_body =~ user.email
assert email.html_body =~ comment.text
assert email.html_body =~ "The Accent Team"
assert email.html_body =~ ~s(href="http://example.com">http://example.com</a>)
assert email.html_body =~ ~s(href="http://example.com/app/projects/#{project.id}/translations/#{translation.id}/conversation">here</a>)
assert email.text_body =~ user.email
assert email.text_body =~ comment.text
assert email.text_body =~ "The Accent Team"
assert email.text_body =~ "(http://example.com)"
assert email.text_body =~ "(http://example.com/app/projects/#{project.id}/translations/#{translation.id}/conversation)"
end
end