From 5450ab4e83705385a5620bb79b5f74d6a19d460a Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 11 Mar 2015 12:19:40 -0400 Subject: [PATCH] ability to email without footer --- tests/workers/email_worker_tests.rb | 17 +++++++++++++++-- workers/email_worker.rb | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/workers/email_worker_tests.rb b/tests/workers/email_worker_tests.rb index 05345ba3..fd77f76d 100644 --- a/tests/workers/email_worker_tests.rb +++ b/tests/workers/email_worker_tests.rb @@ -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 \ No newline at end of file + + 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 diff --git a/workers/email_worker.rb b/workers/email_worker.rb index 386f5c6c..b48bb351 100644 --- a/workers/email_worker.rb +++ b/workers/email_worker.rb @@ -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.