Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added two tests and refactored the other one

  • Loading branch information...
commit e9638b94479959ac01844623cc02eeca65c9b933 1 parent 5df0f16
Rodrigo Flores authored
Showing with 25 additions and 5 deletions.
  1. +25 −5 test/markerb_test.rb
View
30 test/markerb_test.rb
@@ -5,18 +5,38 @@ class Notifier < ActionMailer::Base
layout false
- def contact(recipient)
+ def contact(recipient, format_type)
@recipient = recipient
mail(:to => @recipient, :from => "john.doe@example.com") do |format|
- format.text
- format.html
+ format.send(format_type)
+ end
+ end
+
+ def multiple_format_contact(recipient)
+ @recipient = recipient
+ mail(:to => @recipient, :from => "john.doe@example.com", :template => "contact") do |format|
+ format.text { render 'contact' }
+ format.html { render 'contact' }
end
end
end
class MarkerbTest < ActiveSupport::TestCase
- test 'dual template with .markerb' do
- email = Notifier.contact("you@example.com")
+
+ test "plain text should be sent as a plain text" do
+ email = Notifier.contact("you@example.com", :text)
+ assert_equal "text/plain", email.mime_type
+ assert_equal "Dual templates **rocks**!", email.body.encoded.strip
+ end
+
+ test "html should be sent as html" do
+ email = Notifier.contact("you@example.com", :html)
+ assert_equal "text/html", email.mime_type
+ assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", email.body.encoded.strip
+ end
+
+ test 'dealing with multipart e-mails' do
+ email = Notifier.multiple_format_contact("you@example.com")
assert_equal 2, email.parts.size
assert_equal "multipart/alternative", email.mime_type
assert_equal "text/plain", email.parts[0].mime_type
Please sign in to comment.
Something went wrong with that request. Please try again.