Skip to content

Commit

Permalink
chore(rails 5): selectively reverting encoding
Browse files Browse the repository at this point in the history
premailer-rails made changes after 1.9.4 that broke Planning Center's
usage within pco-communication. Encoding would flip-flop between
ASCII-8BIT and UTF-8, and when this was attempting to go over the wire
it could not be decoded by Planning Center People.

This commit acts as a minimal patch, that removes the parts we don't
need so emails continue working as expected in Planning Center
applications using pco-communication on Rails 5.

There is an integration test for this inside Planning Center Giving. I
tried to write a test that could be generic and live in this fork of the
gem, but ultimately the entire system had to be exercised by hitting
`people.pco.dev` to encounter the error.

My hope is that by consolidating this patch to one commit, we can stay
up-to-date with premailer-rails as the project evolves, with minimal
maintenance.

Original work to get this problem solved was by @zhubert. Thanks Zack!

Moving to ministrycentered/premailer-rails and basing off of 1.9.7 by
@danott
  • Loading branch information
zhubert authored and shanebonham committed Oct 28, 2019
1 parent a03113c commit 79b642c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/premailer/rails/customized_premailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(html)
doc = load_html(html)
options = @options.merge(css_string: CSSHelper.css_for_doc(doc))

super(doc.to_s, options)
super(html, options)
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions lib/premailer/rails/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ def generate_html_part
part = html_part
html = premailer.to_inline_css
Mail::Part.new do
content_transfer_encoding part.content_transfer_encoding
content_type "text/html; charset=#{part.charset}"
body html
body_encoding part.body.encoding
end
end

Expand All @@ -85,10 +83,8 @@ def generate_text_part
part = html_part
text = premailer.to_plain_text
Mail::Part.new do
content_transfer_encoding part.content_transfer_encoding
content_type "text/plain; charset=#{part.charset}"
body text
body_encoding part.body.encoding
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/integration/hook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def html_string
before { message.content_transfer_encoding = 'quoted-printable' }

it 'should maintain the value' do
skip "Planning Center fork opts out of this for compatability with pco-communication"
expect(processed_message.parts.first.content_transfer_encoding).to \
eq 'quoted-printable'
expect(processed_message.parts.last.content_transfer_encoding).to \
Expand Down

0 comments on commit 79b642c

Please sign in to comment.