Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip_placeholders support #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.gem
*.gem
.rvmrc
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions lib/mad_mimi_mailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion mad_mimi_mailer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi there, {welcome} to mad mimi [[peek_image]]
File renamed without changes.
29 changes: 29 additions & 0 deletions test/mad_mimi_mailable_test.rb → test/test_mad_mimi_mailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def hola(greeting)
from "[email protected]"
body :message => greeting
end

end

class ChocolateErbMailer < ActionMailer::Base
Expand All @@ -26,6 +27,14 @@ def sugary_hola(greeting)
from "[email protected]"
body :message => greeting
end

def sugary_skip_hola(greeting)
subject greeting
recipients "[email protected]"
from "[email protected]"
body :message => greeting
skip_placeholders true
end
end

class MadMimiMailableTest < Test::Unit::TestCase
Expand Down Expand Up @@ -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' => "[email protected]",
'api_key' => "w00tb4r",
'promotion_name' => "skip_hola",
'recipients' => "[email protected]",
'subject' => "{welcome to mad mimi}",
'bcc' => nil,
'from' => "[email protected]",
'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
File renamed without changes.