diff --git a/spec/components/email/styles_spec.rb b/spec/components/email/styles_spec.rb index 6b4af50b8..0e6bfcd36 100644 --- a/spec/components/email/styles_spec.rb +++ b/spec/components/email/styles_spec.rb @@ -16,6 +16,14 @@ describe Email::Styles do Nokogiri::HTML(styler.to_html) end + def notification_doc(html) + styler = Email::Styles.new(html) + styler.format_basic + styler.format_notification + styler.format_html + Nokogiri::HTML(styler.to_html) + end + context "basic formatter" do it "works with an empty string" do @@ -24,12 +32,16 @@ describe Email::Styles do expect(style.to_html).to be_blank end - # Pending due to email effort @coding-horror made in d2fb2bc4c - skip "adds a max-width to images" do - doc = basic_doc("") + it "adds a max-width to big images" do + doc = basic_doc("") expect(doc.at("img")["style"]).to match("max-width") end + it "doesn't add a maz-width to small images" do + doc = basic_doc("") + expect(doc.at("img")["style"]).not_to match("max-width") + end + it "adds a width and height to images with an emoji path" do doc = basic_doc("") expect(doc.at("img")["width"]).to eq("20") @@ -97,6 +109,19 @@ describe Email::Styles do end end + context "format notifications" do + it "adds both styles and attributes" do + doc = notification_doc("
hello
") + expect(doc.at('td')['style']).to eq('padding-top:5px;') + expect(doc.at('td')['colspan']).to eq('2') + end + + it "adds attributes when no styles are present" do + doc = notification_doc("
") + expect(doc.at('img')['width']).to eq('45') + end + end + context "rewriting protocol relative URLs to the forum" do it "doesn't rewrite a url to another site" do doc = html_doc('hello') @@ -163,5 +188,4 @@ describe Email::Styles do end end - end