-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for expense_email method in MaintainerMailer
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,51 @@ class MaintainerMailerTest < ActionMailer::TestCase | |
assert_includes email.html_part.body.to_s, "font-family: system-ui" | ||
assert_includes email.html_part.body.to_s, "color: #1D1D28" | ||
end | ||
|
||
test "expense_email" do | ||
data = {"draftKey" => "123"} | ||
project_allocation = create(:project_allocation) | ||
invitation = Invitation.create!(email: "[email protected]", project_allocation: project_allocation, data: data, member_invitation_id: 123) | ||
maintainer_email = "[email protected]" | ||
package = "example-project" | ||
funders = "Sentry" | ||
amount = "$500.00" | ||
invite_token = "123456" | ||
decline_deadline = (Time.now + 14.days).strftime("%B %d, %Y") | ||
fund = create(:fund) | ||
|
||
# Send the email | ||
email = MaintainerMailer.expense_email( | ||
invitation, | ||
maintainer_email, | ||
package, | ||
funders, | ||
amount, | ||
invite_token, | ||
decline_deadline, | ||
fund | ||
) | ||
|
||
# Assert email properties | ||
assert_emails 1 do | ||
email.deliver_now | ||
end | ||
|
||
assert_equal ["[email protected]"], email.to | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal "Payment details for your work maintaining #{package}", email.subject | ||
|
||
# Assert email body contains expected content | ||
assert_includes email.html_part.body.to_s, "Sentry" | ||
assert_includes email.html_part.body.to_s, invite_token | ||
assert_includes email.html_part.body.to_s, decline_deadline | ||
assert_includes email.html_part.body.to_s, 'src="https://funds.ecosyste.ms' | ||
|
||
assert_includes email.text_part.body.to_s, "Sentry" | ||
assert_includes email.text_part.body.to_s, invite_token | ||
assert_includes email.text_part.body.to_s, decline_deadline | ||
|
||
assert_includes email.html_part.body.to_s, "font-family: system-ui" | ||
assert_includes email.html_part.body.to_s, "color: #1D1D28" | ||
end | ||
end |