From 77167f12ad0e0b4326993d51b4ec51ab582778ac Mon Sep 17 00:00:00 2001 From: scossar Date: Wed, 27 Jan 2016 19:07:21 -0800 Subject: [PATCH] move styles to Styles --- app/views/layouts/user_notifications.html.erb | 12 ++++++------ lib/email/styles.rb | 5 +++++ spec/components/email/styles_spec.rb | 11 +++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/user_notifications.html.erb b/app/views/layouts/user_notifications.html.erb index 67e2802b7..9202d99d6 100644 --- a/app/views/layouts/user_notifications.html.erb +++ b/app/views/layouts/user_notifications.html.erb @@ -13,17 +13,17 @@ - -
-
+ +
+
- +
-
+ <%= yield %> diff --git a/lib/email/styles.rb b/lib/email/styles.rb index 0c7bcddc3..25d6a6414 100644 --- a/lib/email/styles.rb +++ b/lib/email/styles.rb @@ -91,6 +91,10 @@ module Email style('.rtl', 'direction: rtl;') style('td.body', 'padding-top:5px;', colspan: "2") style('.whisper td.body', 'font-style: italic; color: #9c9c9c;') + style('.wrapper', 'width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;') + style('.webkit', 'max-width:600px;') + style('.outer', 'Margin: 0 auto; width: 100%; max-width: 600px;') + style('.container', 'padding: 10px;') correct_first_body_margin correct_footer_style reset_tables @@ -138,6 +142,7 @@ module Email end def format_html + style('body', 'Margin: 0;padding:0;min-width:100%;background-color:#ffffff;') style('h3', 'margin: 15px 0 20px 0;') style('hr', 'background-color: #ddd; height: 1px; border: 1px;') style('a', 'text-decoration: none; font-weight: bold; color: #006699;') diff --git a/spec/components/email/styles_spec.rb b/spec/components/email/styles_spec.rb index 0e6bfcd36..e471c310f 100644 --- a/spec/components/email/styles_spec.rb +++ b/spec/components/email/styles_spec.rb @@ -120,6 +120,17 @@ describe Email::Styles do doc = notification_doc("
") expect(doc.at('img')['width']).to eq('45') end + + it "adds correct styles to the wrapper" do + doc = notification_doc('
') + expect(doc.at('center')['style']).to eq('width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;') + end + + it "doesn't override inline attributes" do + doc = notification_doc('
test
') + expect(doc.at('table')['align']).to eq('center') + expect(doc.at('table')['width']).to eq('600') + end end context "rewriting protocol relative URLs to the forum" do