small refactor of admin mail. don't call deliver in the method

This commit is contained in:
maxwell 2010-12-14 16:24:01 -08:00
parent aef5abf631
commit d24be269f2
2 changed files with 3 additions and 4 deletions

View file

@ -9,10 +9,10 @@ class Notifier < ActionMailer::Base
recipients.each do |rec|
mail = single_admin(string, rec)
mails << mail
mail.deliver
end
mails
end
def single_admin(string, recipient)
@recipient = recipient
@string = string.html_safe

View file

@ -13,7 +13,7 @@ describe Notifier do
it 'mails a user' do
mails = Notifier.admin("Welcome to bureaucracy!", [user])
mails.length.should == 1
mail = Notifier.deliveries.first
mail = mails.first
mail.to.should == [user.email]
mail.body.encoded.should match /Welcome to bureaucracy!/
mail.body.encoded.should match /#{user.username}/
@ -23,8 +23,7 @@ describe Notifier do
5.times do
users << make_user
end
Notifier.admin("Welcome to bureaucracy!", users)
mails = Notifier.deliveries
mails = Notifier.admin("Welcome to bureaucracy!", users)
mails.length.should == 5
mails.each{|mail|
this_user = users.detect{|u| mail.to == [u.email]}