diff --git a/.gitignore b/.gitignore index 86339a0..7250248 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.gem \ No newline at end of file +*.gem +.rvmrc \ No newline at end of file diff --git a/Rakefile b/Rakefile index e7bb800..f53a34d 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'rake/testtask' Rake::TestTask.new do |t| t.libs << "test" - t.test_files = FileList['test/*test.rb'] + t.test_files = FileList['test/test_*.rb'] t.verbose = false end diff --git a/lib/mad_mimi_mailable.rb b/lib/mad_mimi_mailable.rb index 340730a..a62815d 100644 --- a/lib/mad_mimi_mailable.rb +++ b/lib/mad_mimi_mailable.rb @@ -38,6 +38,14 @@ def unconfirmed(value = nil) @unconfirmed = value end end + + def skip_placeholders(value = nil) + if value.nil? + @skip_placeholders + else + @skip_placeholders = value + end + end module ClassMethods attr_accessor :method_prefix, :use_erb @@ -85,10 +93,13 @@ def call_api!(mail, method) 'subject' => mail.subject, 'bcc' => serialize(mail.bcc || MadMimiMailer.default_parameters[:bcc]), 'from' => (mail.from || MadMimiMailer.default_parameters[:from]), + 'reply_to' => mail.reply_to, 'hidden' => serialize(mail.hidden) } params['unconfirmed'] = '1' if mail.unconfirmed + + params['skip_placeholders'] = 'true' if mail.skip_placeholders if use_erb?(mail) if mail.parts.any? diff --git a/mad_mimi_mailer.gemspec b/mad_mimi_mailer.gemspec index 811c85b..d17151d 100644 --- a/mad_mimi_mailer.gemspec +++ b/mad_mimi_mailer.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{mad_mimi_mailer} - s.version = "0.1.2.1" + s.version = "0.1.2.2" s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= s.authors = ["Dave Hoover"] diff --git a/test/templates/chocolate_erb_mailer/sugary_skip_hola.text.html.erb b/test/templates/chocolate_erb_mailer/sugary_skip_hola.text.html.erb new file mode 100644 index 0000000..554381f --- /dev/null +++ b/test/templates/chocolate_erb_mailer/sugary_skip_hola.text.html.erb @@ -0,0 +1 @@ +hi there, {welcome} to mad mimi [[peek_image]] \ No newline at end of file diff --git a/test/default_parameters_test.rb b/test/test_default_paramaters.rb similarity index 100% rename from test/default_parameters_test.rb rename to test/test_default_paramaters.rb diff --git a/test/mad_mimi_mailable_test.rb b/test/test_mad_mimi_mailable.rb similarity index 70% rename from test/mad_mimi_mailable_test.rb rename to test/test_mad_mimi_mailable.rb index e738523..a7bbefe 100644 --- a/test/mad_mimi_mailable_test.rb +++ b/test/test_mad_mimi_mailable.rb @@ -11,6 +11,7 @@ def hola(greeting) from "dave@obtiva.com" body :message => greeting end + end class ChocolateErbMailer < ActionMailer::Base @@ -26,6 +27,14 @@ def sugary_hola(greeting) from "dave@obtiva.com" body :message => greeting end + + def sugary_skip_hola(greeting) + subject greeting + recipients "tyler@obtiva.com" + from "dave@obtiva.com" + body :message => greeting + skip_placeholders true + end end class MadMimiMailableTest < Test::Unit::TestCase @@ -72,5 +81,25 @@ def test_erb_request_with_custom_method_prefix ChocolateErbMailer.deliver_sugary_hola("welcome to mad mimi") end + + def test_erb_request_skipping_placeholders + mock_request = mock("request") + mock_request.expects(:set_form_data).with( + 'username' => "testy@mctestin.com", + 'api_key' => "w00tb4r", + 'promotion_name' => "skip_hola", + 'recipients' => "tyler@obtiva.com", + 'subject' => "{welcome to mad mimi}", + 'bcc' => nil, + 'from' => "dave@obtiva.com", + 'raw_html' => "hi there, {welcome} to mad mimi [[peek_image]]", + 'raw_plain_text' => nil, + 'hidden' => nil, + 'skip_placeholders' => 'true' + ) + ChocolateErbMailer.expects(:post_request).yields(mock_request).returns(@ok_reponse) + + ChocolateErbMailer.deliver_sugary_skip_hola("{welcome to mad mimi}") + end end diff --git a/test/mad_mimi_mailer_test.rb b/test/test_mad_mimi_mailer.rb similarity index 100% rename from test/mad_mimi_mailer_test.rb rename to test/test_mad_mimi_mailer.rb