actionmailer_inline_css 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,6 @@
1
1
  Gemfile.lock
2
+ *.swp
3
+ *.swo
4
+ .bundle
5
+ bin
2
6
  pkg/*
data/Gemfile CHANGED
@@ -5,6 +5,8 @@ gem 'rake'
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
+ gem "webmock"
9
+
8
10
  unless ENV['TRAVIS']
9
11
  gem 'ruby-debug', :platform => :mri_18
10
12
  gem 'ruby-debug19', :platform => :mri_19, :require => 'ruby-debug'
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "actionmailer_inline_css"
3
- s.version = "1.3.1"
3
+ s.version = "1.4.0"
4
4
  s.date = Time.now.strftime('%Y-%m-%d')
5
5
  s.summary = "Always send HTML e-mails with inline CSS, using the 'premailer' gem"
6
6
  s.email = "nathan.f77@gmail.com"
@@ -5,7 +5,9 @@ module ActionMailer
5
5
  class InlineCssHook
6
6
  def self.delivering_email(message)
7
7
  if html_part = (message.html_part || (message.content_type =~ /text\/html/ && message))
8
- premailer = ::Premailer.new(html_part.body.to_s, :with_html_string => true)
8
+ premailer = ::Premailer.new(html_part.body.to_s,
9
+ :with_html_string => true,
10
+ :base_url => message.header[:host].to_s)
9
11
  existing_text_part = message.text_part && message.text_part.body.to_s
10
12
  # Reset the body
11
13
  message.body = nil
@@ -23,4 +25,3 @@ module ActionMailer
23
25
  end
24
26
  end
25
27
  end
26
-
@@ -37,6 +37,7 @@ require 'mocha'
37
37
 
38
38
  require 'action_mailer'
39
39
  require 'action_mailer/test_case'
40
+ require 'webmock/test_unit'
40
41
  require 'actionmailer_inline_css'
41
42
 
42
43
  silence_warnings do
@@ -26,7 +26,22 @@ TEST_HTML_UTF8 = %Q{
26
26
  </body>
27
27
  </html>}
28
28
 
29
+ TEST_HTML_WITH_HOST = %Q{
30
+ <html>
31
+ <head>
32
+ <style>
33
+ #test { color: #123456; }
34
+ </style>
35
+ </head>
36
+ <body>
37
+ <img src="/images/test.png" />
38
+ </body>
39
+ </html>
40
+ }
41
+
29
42
  class HelperMailer < ActionMailer::Base
43
+ default :host => "http://www.example.com/"
44
+
30
45
  def use_inline_css_hook_with_only_html_part
31
46
  mail_with_defaults do |format|
32
47
  format.html { render(:inline => TEST_HTML) }
@@ -46,6 +61,12 @@ class HelperMailer < ActionMailer::Base
46
61
  end
47
62
  end
48
63
 
64
+ def inline_css_hook_with_base_url
65
+ mail_with_defaults do |format|
66
+ format.html { render(:inline => TEST_HTML_WITH_HOST) }
67
+ end
68
+ end
69
+
49
70
  protected
50
71
 
51
72
  def mail_with_defaults(&block)
@@ -75,5 +96,11 @@ class InlineCssHookTest < ActionMailer::TestCase
75
96
  assert_match 'ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ', mail.html_part.body.encoded
76
97
  assert_match 'ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ', mail.text_part.body.encoded
77
98
  end
99
+
100
+ def test_inline_css_hook_with_base_url
101
+ mail = HelperMailer.inline_css_hook_with_base_url.deliver
102
+ assert_match '<img src="http://www.example.com/images/test.png">',
103
+ mail.html_part.body.encoded
104
+ end
78
105
  end
79
106
 
@@ -3,6 +3,8 @@ require 'abstract_unit'
3
3
  ENV["RAILS_ASSET_ID"] = "123456"
4
4
 
5
5
  class HelperMailer < ActionMailer::Base
6
+ default :host => "http://www.example.com/"
7
+
6
8
  def use_stylesheet_link_tag
7
9
  mail_with_defaults do |format|
8
10
  format.html { render(:inline => %Q{
@@ -28,9 +30,10 @@ end
28
30
 
29
31
  class PremailerStylesheetLinkTagTest < ActionMailer::TestCase
30
32
  def test_premailer_stylesheet_link_tag
31
- css_file = "div.test { color: #119911; }"
32
- File.stubs(:exist?).returns(true)
33
- File.stubs(:read).returns(css_file)
33
+ stub_request(:get, /example\.com\/*/).to_return do
34
+ css = "div.test { color: #119911; }"
35
+ { :status => 200, :body => css }
36
+ end
34
37
 
35
38
  mail = HelperMailer.use_stylesheet_link_tag.deliver
36
39
  assert_match "<div class=\"test\" style=\"color: #119911;\">", mail.html_part.body.encoded
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer_inline_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-30 00:00:00.000000000Z
12
+ date: 2011-10-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionmailer
16
- requirement: &85500100 !ruby/object:Gem::Requirement
16
+ requirement: &21313620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *85500100
24
+ version_requirements: *21313620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: premailer
27
- requirement: &85499400 !ruby/object:Gem::Requirement
27
+ requirement: &21312220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.7.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *85499400
35
+ version_requirements: *21312220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &85498930 !ruby/object:Gem::Requirement
38
+ requirement: &21310540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.4.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *85498930
46
+ version_requirements: *21310540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &85478310 !ruby/object:Gem::Requirement
49
+ requirement: &21308720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.10.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *85478310
57
+ version_requirements: *21308720
58
58
  description: Module for ActionMailer to improve the rendering of HTML emails by using
59
59
  the 'premailer' gem, which inlines CSS and makes relative links absolute.
60
60
  email: nathan.f77@gmail.com
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 62806209
92
+ hash: 12308258948575913
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
@@ -98,10 +98,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: 62806209
101
+ hash: 12308258948575913
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 1.8.10
104
+ rubygems_version: 1.8.8
105
105
  signing_key:
106
106
  specification_version: 3
107
107
  summary: Always send HTML e-mails with inline CSS, using the 'premailer' gem