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| recipients.each do |rec|
mail = single_admin(string, rec) mail = single_admin(string, rec)
mails << mail mails << mail
mail.deliver
end end
mails mails
end end
def single_admin(string, recipient) def single_admin(string, recipient)
@recipient = recipient @recipient = recipient
@string = string.html_safe @string = string.html_safe

View file

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