Skip to content

Commit

Permalink
Allow for blank BCC's
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Hoover <dave.hoover@gmail.com>
  • Loading branch information
thomas authored and redsquirrel committed Jul 28, 2009
1 parent c3da6e1 commit 5d27b42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mad_mimi_mailer.rb
Expand Up @@ -43,7 +43,7 @@ def call_api!(mail, method)
'promotion_name' => method.to_s.sub(/^mimi_/, ''),
'recipients' => serialize(mail.recipients),
'subject' => mail.subject,
'bcc' => serialize(mail.bcc),
'bcc' => mail.bcc.present? ? serialize(mail.bcc) : '',
'from' => mail.from,
'body' => mail.body.to_yaml
)
Expand Down
25 changes: 25 additions & 0 deletions test/mad_mimi_mailer_test.rb
Expand Up @@ -17,6 +17,13 @@ def mimi_hello(greeting)
bcc ["Gregg Pollack <gregg@example.com>", "David Clymer <david@example>"]
body :message => greeting
end

def mimi_hello_sans_bcc(greeting)
subject greeting
recipients "tyler@obtiva.com"
from "dave@obtiva.com"
body :message => greeting
end
end

class TestMadMimiMailer < Test::Unit::TestCase
Expand All @@ -39,6 +46,24 @@ def test_happy_path
MadMimiMailer.deliver_mimi_hello("welcome to mad mimi")
end

def test_blank_bcc
mock_request = mock("request")
mock_request.expects(:set_form_data).with(
'username' => "testy@mctestin.com",
'api_key' => "w00tb4r",
'promotion_name' => "hello_sans_bcc",
'recipients' => "tyler@obtiva.com",
'bcc' => "",
'subject' => "welcome to mad mimi",
'from' => "dave@obtiva.com",
'body' => "--- \n:message: welcome to mad mimi\n"
)
response = Net::HTTPSuccess.new("1.2", '200', 'OK')
MadMimiMailer.expects(:post_request).yields(mock_request).returns(response)

MadMimiMailer.deliver_mimi_hello_sans_bcc("welcome to mad mimi")
end

def test_bad_promotion_name
mock_request = mock("request")
mock_request.stubs(:set_form_data)
Expand Down

0 comments on commit 5d27b42

Please sign in to comment.