Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wheels::Mailer enhancements/optimizations for use in a mail queue.
- Loading branch information
1 parent
7e9daff
commit d7f68e6
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ def deliver(mail) | |
mail.mail_server = @server | ||
mail.send!.should == mail | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "rubygems" | ||
require "test/unit" | ||
require Pathname(__FILE__).dirname.parent + "lib/wheels" | ||
require "wheels/xml_view" | ||
|
||
module Rack | ||
class Request | ||
def params | ||
@params ||= {} | ||
end | ||
end | ||
end | ||
|
||
def upload(filename) | ||
input = <<-EOF | ||
--AaB03x\r | ||
Content-Disposition: form-data; name="file"; filename="#{filename}"\r | ||
Content-Type: image/jpeg\r | ||
\r | ||
#{File.read(Pathname(__FILE__).dirname + "samples" + filename)}\r | ||
\r | ||
--AaB03x\r | ||
Content-Disposition: form-data; name="video[caption]"\r | ||
\r | ||
test\r | ||
--AaB03x\r | ||
Content-Disposition: form-data; name="video[transcoder][1]"\r | ||
\r | ||
on\r | ||
--AaB03x\r | ||
Content-Disposition: form-data; name="video[transcoder][4]"\r | ||
\r | ||
on\r | ||
--AaB03x\r | ||
Content-Disposition: form-data; name="video[transcoder][5]"\r | ||
\r | ||
on\r | ||
--AaB03x--\r | ||
\r | ||
EOF | ||
Rack::Request.new Rack::MockRequest.env_for("/", | ||
"CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x", | ||
"CONTENT_LENGTH" => input.size, | ||
:input => input) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "helper" | ||
require "wheels/mailer" | ||
|
||
class MailerTest < Test::Unit::TestCase | ||
|
||
def test_tokenize_urls_with_plain_text | ||
mailer = Wheels::Mailer.new | ||
url = "http://test.com" | ||
mailer.text = url | ||
mailer.tokenize_urls!("http://m.wieck.com") | ||
|
||
assert_equal("http://m.wieck.com/m/#{mailer.envelope_id}?r=#{CGI.escape([url].pack("m"))}", mailer.text) | ||
end | ||
|
||
def test_tokenize_urls_with_html | ||
mailer = Wheels::Mailer.new | ||
url = "http://test.com" | ||
mailer.rawhtml = "<a href=\"#{url}\">Link</a>" | ||
mailer.tokenize_urls!("http://m.wieck.com") | ||
|
||
assert_equal("<a href=\"http://m.wieck.com/m/#{mailer.envelope_id}?r=#{CGI.escape([url].pack("m"))}\">Link</a>", mailer.html) | ||
end | ||
|
||
def test_tokenize_urls_with_https | ||
mailer = Wheels::Mailer.new | ||
url = "https://test.com" | ||
mailer.text = url | ||
mailer.tokenize_urls!("http://m.wieck.com") | ||
|
||
assert_equal("http://m.wieck.com/m/#{mailer.envelope_id}?r=#{CGI.escape([url].pack("m"))}", mailer.text) | ||
end | ||
|
||
end |