Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7 from capita/processing_options

Fix processing_options
  • Loading branch information...
commit 85a74d70c84161700de65828ec24d1960406c185 2 parents 93b1e8b + a5a2e1f
@josevalim josevalim authored
View
4 lib/markerb.rb
@@ -4,7 +4,7 @@
module Markerb
mattr_accessor :processing_options, :renderer
- @@processing_options = []
+ @@processing_options = {}
@@renderer = Redcarpet::Render::HTML
class Handler
@@ -15,7 +15,7 @@ def erb_handler
def call(template)
compiled_source = erb_handler.call(template)
if template.formats.include?(:html)
- "Redcarpet::Markdown.new(Markerb.renderer, *Markerb.processing_options).render(begin;#{compiled_source};end)"
+ "Redcarpet::Markdown.new(Markerb.renderer, Markerb.processing_options).render(begin;#{compiled_source};end)"
else
compiled_source
end
View
23 test/markerb_test.rb
@@ -12,6 +12,12 @@ def contact(recipient, format_type)
end
end
+ def link(format_type)
+ mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
+ 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|
@@ -35,6 +41,16 @@ def normal_text(text)
class MarkerbTest < ActiveSupport::TestCase
+ setup do
+ @original_renderer = Markerb.renderer
+ @original_processing_options = Markerb.processing_options
+ end
+
+ teardown do
+ Markerb.renderer = @original_renderer
+ Markerb.processing_options = @original_processing_options
+ end
+
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
@@ -72,4 +88,11 @@ class MarkerbTest < ActiveSupport::TestCase
assert_equal "text/html", email.mime_type
assert_equal "<p>TEST Dual templates <strong>TEST rocks</strong>TEST !</p>", email.body.encoded.strip
end
+
+ test 'with custom markdown processing options' do
+ Markerb.processing_options = {:autolink => true}
+ email = Notifier.link(:html)
+ assert_equal "text/html", email.mime_type
+ assert_equal '<p>Hello from <a href="http://www.fcstpauli.com">http://www.fcstpauli.com</a></p>', email.body.encoded.strip
+ end
end
View
1  test/views/notifier/link.markerb
@@ -0,0 +1 @@
+Hello from http://www.fcstpauli.com
Please sign in to comment.
Something went wrong with that request. Please try again.