DEV: deduplicate inline styles in emails (#30015)

In order to limit issues with duplicate inline CSS definitions, this will now deduplicate inline CSS styles with the "last-to-be-defined-wins" strategy.

Also removes unecessary whitespaces in inline styles.

Context - https://meta.discourse.org/t/resolve-final-styles-in-email-notifications/310219

Co-authored-by: Thomas Kalka <thomas.kalka@gmail.com>
This commit is contained in:
Régis Hanol
2024-11-30 16:38:45 +01:00
committed by GitHub
parent 20d46c9583
commit 7d58793759
4 changed files with 48 additions and 10 deletions

View File

@ -591,7 +591,7 @@ RSpec.describe Email::Sender do
reply.rebake!
Email::Sender.new(message, :valid_type).send
expected = <<~HTML
<a href=\"#{Discourse.base_url}#{category.url}\" data-type=\"category\" data-slug=\"dev\" data-id=\"#{category.id}\" style=\"text-decoration: none; font-weight: bold; color: #006699;\"><span>#dev</span>
<a href=\"#{Discourse.base_url}#{category.url}\" data-type=\"category\" data-slug=\"dev\" data-id=\"#{category.id}\" style=\"text-decoration:none;font-weight:bold;color:#006699\"><span>#dev</span>
HTML
expect(message.html_part.body.to_s).to include(expected.chomp)
end