From d34e741a18d8ec096dd50f723ef6c4b71ffef148 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Wed, 29 Jun 2011 12:04:49 -0700 Subject: [PATCH] Test for reminder email --- .../hydrant_mailer/reminder_email.text.erb | 6 +++--- test/functional/hydrant_mailer_test.rb | 4 ---- test/functional/passwords_controller_test.rb | 6 ------ test/functional/reminders_controller_test.rb | 20 ++++++++++++++++--- 4 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 test/functional/hydrant_mailer_test.rb diff --git a/app/views/hydrant_mailer/reminder_email.text.erb b/app/views/hydrant_mailer/reminder_email.text.erb index 60f566a..bbabcbb 100644 --- a/app/views/hydrant_mailer/reminder_email.text.erb +++ b/app/views/hydrant_mailer/reminder_email.text.erb @@ -1,7 +1,7 @@ -<%= @hydrant.user.name.split.first %>, +Hello <%= @hydrant.user.name.split.first %>, -Did you remember to shovel out <%= @hydrant.name %>, the fire hydrant you adopted at <%= @hydrant.street_address %>? If not, please shovel your hydrant as soon as possible! +Did you remember to shovel <%= ['out', @hydrant.name, 'the'].compact.join(' ') %> fire hydrant you adopted at <%= @hydrant.street_address %>? If not, please shovel your hydrant as soon as possible! -If you've already shoveled out <%= @hydrant.name %>, thank you for serving your city! +If you've already shoveled, thank you for serving your city! Mayor Tom Menino diff --git a/test/functional/hydrant_mailer_test.rb b/test/functional/hydrant_mailer_test.rb deleted file mode 100644 index 74bf567..0000000 --- a/test/functional/hydrant_mailer_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class HydrantMailerTest < ActionMailer::TestCase -end diff --git a/test/functional/passwords_controller_test.rb b/test/functional/passwords_controller_test.rb index 3c2d74b..754bf75 100644 --- a/test/functional/passwords_controller_test.rb +++ b/test/functional/passwords_controller_test.rb @@ -12,15 +12,9 @@ class PasswordsControllerTest < ActionController::TestCase post :create, :user => {:email => @user.email} assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size assert_response :success - email = ActionMailer::Base.deliveries.last assert_equal [@user.email], email.to assert_equal "Reset password instructions", email.subject - assert_match /Hello #{@user.email}!/, email.encoded - assert_match /Someone has requested a link to change your password, and you can do this through the link below./, email.encoded - assert_match /Change my password/, email.encoded - assert_match /If you didn't request this, please ignore this email./, email.encoded - assert_match /Your password won't change until you access the link above and create a new one./, email.encoded end test 'should not send password reset instructions if email address is not found' do diff --git a/test/functional/reminders_controller_test.rb b/test/functional/reminders_controller_test.rb index dc13904..08dcecc 100644 --- a/test/functional/reminders_controller_test.rb +++ b/test/functional/reminders_controller_test.rb @@ -1,7 +1,21 @@ require 'test_helper' class RemindersControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end + setup do + @hydrant = hydrants(:hydrant_1) + @dan = users(:dan) + @erik = users(:erik) + @hydrant.user = @dan + @hydrant.save! + end + + test 'should send a reminder email' do + num_deliveries = ActionMailer::Base.deliveries.size + post :create, :format => :json, :reminder => {:hydrant_id => @hydrant.id, :from_user_id => @erik.id, :to_user_id => @dan.id} + assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size + assert_response :success + email = ActionMailer::Base.deliveries.last + assert_equal [@dan.email], email.to + assert_equal "Remember to Shovel", email.subject + end end