ability to email without footer

This commit is contained in:
Kyle Drake 2015-03-11 12:19:40 -04:00
parent 6da092aee7
commit 5450ab4e83
2 changed files with 20 additions and 3 deletions

View file

@ -19,8 +19,21 @@ describe EmailWorker do
mail.to.first.must_equal 'to@example.com'
mail.subject.must_equal 'Hello World'
body = mail.body.to_s
puts body
body.must_match /testing/
body.must_match /unsubscribe/
end
end
it 'sends an email without a footer' do
worker = EmailWorker.new
worker.perform({
'no_footer' => true,
'from' => 'from@example.com',
'to' => 'to@example.com',
'subject' => 'Hello World',
'body' => 'testing'
})
body = Mail::TestMailer.deliveries.first.body.to_s
body.must_match /testing/
body.wont_match /unsubscribe/
end
end

View file

@ -5,7 +5,11 @@ class EmailWorker
def perform(args={})
unsubscribe_token = Site.email_unsubscribe_token args['to']
footer = "\n\n---\nYou are receiving this email because you have a Neocities site. If you would like to subscribe from Neocities emails, just visit this url:\nhttps://neocities.org/settings/unsubscribe_email?email=#{Rack::Utils.escape args['to']}&token=#{unsubscribe_token}"
if args['no_footer']
footer = ''
else
footer = "\n\n---\nYou are receiving this email because you have a Neocities site. If you would like to subscribe from Neocities emails, just visit this url:\nhttps://neocities.org/settings/unsubscribe_email?email=#{Rack::Utils.escape args['to']}&token=#{unsubscribe_token}"
end
Mail.deliver do
# TODO this is not doing UTF-8 properly.