premailer-rails 1.9.3 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb +1 -0
- data/lib/premailer/rails/css_loaders/cache_loader.rb +3 -1
- data/lib/premailer/rails/css_loaders/network_loader.rb +2 -1
- data/lib/premailer/rails/hook.rb +18 -8
- data/spec/integration/hook_spec.rb +16 -0
- data/spec/support/fixtures/message.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c72ab2474486b2defef2795a17b651f4333b3e4
|
4
|
+
data.tar.gz: 10be620db0873f11ebb75e25b0a2684f7e1b6eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deafb4ba758c0881f42dba0e2c4a3b7da335d1e146d8e2fba30b66bf37f3e899de457ce5435ad95ae2902204cef00d0dee607af89919657256da6b655d9101a8
|
7
|
+
data.tar.gz: 00039726a8423529faacdb11788c649f072f7d0a8ff120f70b6476cbea90eb6588826bb63d4f5d13dae104eef0eac9e0ff0b450b9094e8d2c9eae77f77221a5e
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.4
|
data/lib/premailer/rails/hook.rb
CHANGED
@@ -70,17 +70,27 @@ class Premailer
|
|
70
70
|
# can end up containing CSS rules.
|
71
71
|
generate_text_part if generate_text_part?
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
part = html_part
|
74
|
+
html = premailer.to_inline_css
|
75
|
+
Mail::Part.new do
|
76
|
+
content_transfer_encoding part.content_transfer_encoding
|
77
|
+
content_type "text/html; charset=#{part.charset}"
|
78
|
+
body html
|
79
|
+
body_encoding part.body.encoding
|
80
|
+
end
|
77
81
|
end
|
78
82
|
|
79
83
|
def generate_text_part
|
80
|
-
@text_part ||=
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
@text_part ||= begin
|
85
|
+
part = html_part
|
86
|
+
text = premailer.to_plain_text
|
87
|
+
Mail::Part.new do
|
88
|
+
content_transfer_encoding part.content_transfer_encoding
|
89
|
+
content_type "text/plain; charset=#{part.charset}"
|
90
|
+
body text
|
91
|
+
body_encoding part.body.encoding
|
92
|
+
end
|
93
|
+
end
|
84
94
|
end
|
85
95
|
|
86
96
|
def premailer
|
@@ -5,6 +5,10 @@ describe Premailer::Rails::Hook do
|
|
5
5
|
Premailer::Rails::Hook.perform(message)
|
6
6
|
end
|
7
7
|
|
8
|
+
def body_content(message)
|
9
|
+
Nokogiri::HTML(message.html_string).at('body').content
|
10
|
+
end
|
11
|
+
|
8
12
|
class Mail::Message
|
9
13
|
def html_string
|
10
14
|
(html_part || self).body.to_s
|
@@ -54,6 +58,18 @@ describe Premailer::Rails::Hook do
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
61
|
+
it 'does not screw up the text by maintaining the original body encoding' do
|
62
|
+
raw_msg = Fixtures::Message.latin_message
|
63
|
+
processed_msg = Fixtures::Message.latin_message
|
64
|
+
run_hook(processed_msg)
|
65
|
+
expect(body_content(processed_msg)).to eq(body_content(raw_msg))
|
66
|
+
|
67
|
+
raw_msg = Fixtures::Message.non_latin_message
|
68
|
+
processed_msg = Fixtures::Message.non_latin_message
|
69
|
+
run_hook(processed_msg)
|
70
|
+
expect(body_content(processed_msg)).to eq(body_content(raw_msg))
|
71
|
+
end
|
72
|
+
|
57
73
|
it 'generates a text part from the html' do
|
58
74
|
expect { run_hook(message) }.to change(message, :text_part)
|
59
75
|
end
|
@@ -114,6 +114,22 @@ nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
114
114
|
message
|
115
115
|
end
|
116
116
|
|
117
|
+
def latin_message
|
118
|
+
base_message.tap do |message|
|
119
|
+
message.body = HTML_PART
|
120
|
+
message.content_type 'text/html; charset=UTF-8'
|
121
|
+
message.ready_to_send!
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def non_latin_message
|
126
|
+
base_message.tap do |message|
|
127
|
+
message.body = HTML_PART_WITH_UNICODE
|
128
|
+
message.content_type 'text/html; charset=UTF-8'
|
129
|
+
message.ready_to_send!
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
117
133
|
private
|
118
134
|
|
119
135
|
def base_message
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: premailer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: premailer
|