Skip to content

Commit

Permalink
Add test for expense_email method in MaintainerMailer
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jan 24, 2025
1 parent cb6e8e9 commit 9a04eea
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/mailers/maintainer_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9a04eea

Please sign in to comment.