Skip to content

Commit

Permalink
add support for the unconfirmed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ethangunderson committed Mar 24, 2010
1 parent 7a264f0 commit 2de4f92
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/mad_mimi_mailer.rb
Expand Up @@ -34,6 +34,14 @@ def hidden(hidden = nil)
@hidden = hidden
end
end

def unconfirmed(value = nil)
if value.nil?
@unconfirmed
else
@unconfirmed = value
end
end

# Class methods

Expand Down Expand Up @@ -83,6 +91,8 @@ def call_api!(mail, method)
'hidden' => serialize(mail.hidden)
}

params['unconfirmed'] = '1' if mail.unconfirmed

if mail.use_erb
if mail.parts.any?
params['raw_plain_text'] = content_for(mail, "text/plain")
Expand Down
30 changes: 30 additions & 0 deletions test/mad_mimi_mailer_test.rb
Expand Up @@ -62,6 +62,15 @@ def mimi_hello_sans_bcc(greeting)
from "dave@obtiva.com"
body :message => greeting
end

def mimi_unconfirmed(greeting)
subject greeting
recipients 'egunderson@obtiva.com'
from 'mimi@obtiva.com'
promotion 'woot'
body :message => greeting
unconfirmed true
end
end

class TestMadMimiMailer < Test::Unit::TestCase
Expand Down Expand Up @@ -230,4 +239,25 @@ def test_assert_mail_sent
assert_equal 1, ActionMailer::Base.deliveries.size
assert_equal "MadMimiMailer", ActionMailer::Base.deliveries.last.class.name
end

def test_delivers_contain_unconfirmed_param_if_unconfirmed_is_set
mock_request = mock("request")
mock_request.expects(:set_form_data).with(
'username' => "testy@mctestin.com",
'api_key' => "w00tb4r",
'body' => "--- \n:message: welcome unconfirmed user\n",
'promotion_name' => "woot",
'recipients' => 'egunderson@obtiva.com',
'bcc' => nil,
'subject' => "welcome unconfirmed user",
'from' => "mimi@obtiva.com",
'hidden' => nil,
'unconfirmed' => '1'
)
response = Net::HTTPSuccess.new("1.2", '200', 'OK')
response.stubs(:body).returns("123435")
MadMimiMailer.expects(:post_request).yields(mock_request).returns(response)

MadMimiMailer.deliver_mimi_unconfirmed("welcome unconfirmed user")
end
end
1 change: 1 addition & 0 deletions test/templates/mad_mimi_mailer/mimi_unconfirmed.erb
@@ -0,0 +1 @@
hi there, <%= @message %> [[peek_image]]

0 comments on commit 2de4f92

Please sign in to comment.