add entry requests, invite new users
This commit is contained in:
@@ -35,4 +35,50 @@ class InvitationMailerTest < ActionMailer::TestCase
|
||||
assert_equal "text/plain", mail.text_part.content_type.split(";").first
|
||||
assert_equal "text/html", mail.html_part.content_type.split(";").first
|
||||
end
|
||||
|
||||
test "invite with approved_entry includes entry details" do
|
||||
user = users(:requester_user)
|
||||
user.update!(
|
||||
invitation_token: SecureRandom.urlsafe_base64(32),
|
||||
invitation_sent_at: Time.current
|
||||
)
|
||||
entry = entries(:requested_entry)
|
||||
mail = InvitationMailer.invite(user, approved_entry: entry)
|
||||
|
||||
assert_equal "Your entry request has been approved - Join Sanasto Wiki", mail.subject
|
||||
assert_equal [ user.email ], mail.to
|
||||
|
||||
# Check that entry details are included
|
||||
assert_match entry.fi, mail.body.encoded
|
||||
assert_match entry.en, mail.body.encoded
|
||||
assert_match entry.category.to_s.humanize, mail.body.encoded
|
||||
assert_match "approved", mail.body.encoded.downcase
|
||||
end
|
||||
|
||||
test "invite with approved_entry shows correct message" do
|
||||
user = users(:requester_user)
|
||||
user.update!(
|
||||
invitation_token: SecureRandom.urlsafe_base64(32),
|
||||
invitation_sent_at: Time.current
|
||||
)
|
||||
entry = entries(:requested_entry)
|
||||
mail = InvitationMailer.invite(user, approved_entry: entry)
|
||||
|
||||
# HTML part should contain the entry box
|
||||
assert_match "Your Approved Entry", mail.html_part.body.encoded
|
||||
assert_match "entry-box", mail.html_part.body.encoded
|
||||
|
||||
# Text part should contain entry details
|
||||
assert_match "YOUR APPROVED ENTRY", mail.text_part.body.encoded
|
||||
assert_match "Category:", mail.text_part.body.encoded
|
||||
end
|
||||
|
||||
test "invite without approved_entry uses standard message" do
|
||||
user = users(:pending_invitation)
|
||||
mail = InvitationMailer.invite(user)
|
||||
|
||||
assert_equal "You've been invited to join Sanasto Wiki", mail.subject
|
||||
assert_match "you can contribute to this work", mail.body.encoded.downcase
|
||||
assert_no_match "approved", mail.body.encoded.downcase
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user