Test for reminder email

This commit is contained in:
Erik Michaels-Ober 2011-06-29 12:04:49 -07:00
parent bc7e1840ba
commit d34e741a18
4 changed files with 20 additions and 16 deletions

View File

@ -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 Mayor Tom Menino

View File

@ -1,4 +0,0 @@
require 'test_helper'
class HydrantMailerTest < ActionMailer::TestCase
end

View File

@ -12,15 +12,9 @@ class PasswordsControllerTest < ActionController::TestCase
post :create, :user => {:email => @user.email} post :create, :user => {:email => @user.email}
assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success assert_response :success
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
assert_equal [@user.email], email.to assert_equal [@user.email], email.to
assert_equal "Reset password instructions", email.subject 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 end
test 'should not send password reset instructions if email address is not found' do test 'should not send password reset instructions if email address is not found' do

View File

@ -1,7 +1,21 @@
require 'test_helper' require 'test_helper'
class RemindersControllerTest < ActionController::TestCase class RemindersControllerTest < ActionController::TestCase
# test "the truth" do setup do
# assert true @hydrant = hydrants(:hydrant_1)
# end @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 end