Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from guiocavalcanti/issue-4

Two-phase conversion to avoid requests deadlocks. Closes #4
  • Loading branch information...
commit 205c170d79e1ff03a91e272895df521cc87717ef 2 parents f7c0d5c + 081306d
@ndbroadbent ndbroadbent authored
View
10 lib/action_mailer/inline_css_hook.rb
@@ -5,9 +5,15 @@ module ActionMailer
class InlineCssHook
def self.delivering_email(message)
if html_part = (message.html_part || (message.content_type =~ /text\/html/ && message))
+ # Generate an email with all CSS inlined (access CSS a FS path)
premailer = ::Premailer.new(html_part.body.to_s,
- :with_html_string => true,
- :base_url => message.header[:host].to_s)
+ :with_html_string => true)
+
+ # Prepend host to remaning URIs.
+ # Two-phase conversion to avoid request deadlock from dev. server (Issue #4)
+ premailer = ::Premailer.new(premailer.to_inline_css,
+ :with_html_string => true,
+ :base_url => message.header[:host].to_s)
existing_text_part = message.text_part && message.text_part.body.to_s
# Reset the body
message.body = nil
View
7 test/premailer_stylesheet_link_tag_test.rb
@@ -30,10 +30,9 @@ def mail_with_defaults(&block)
class PremailerStylesheetLinkTagTest < ActionMailer::TestCase
def test_premailer_stylesheet_link_tag
- stub_request(:get, /example\.com\/*/).to_return do
- css = "div.test { color: #119911; }"
- { :status => 200, :body => css }
- end
+ css_file = "div.test { color: #119911; }"
+ File.stubs(:exist?).returns(true)
+ File.stubs(:read).returns(css_file)
mail = HelperMailer.use_stylesheet_link_tag.deliver
assert_match "<div class=\"test\" style=\"color: #119911;\">", mail.html_part.body.encoded
Please sign in to comment.
Something went wrong with that request. Please try again.