# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Channel::EmailBuild > Inline Images Adjustments', aggregate_failures: true, type: :model do
let(:html_body) do
<<~HTML.chomp
Test Admin Agent
--
Super Support - Waterford Business Park
5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA
Email: hot@example.com - Web:
http://www.example.com/
--
HTML
end
let(:mail) do
Channel::EmailBuild.build(
from: 'sender@example.com',
to: 'recipient@example.com',
body: html_body,
content_type: 'text/html',
)
end
context 'when an email is built with inline images' do
it 'adjusts the inline images width and height' do
expect(mail.html_part.body.to_s).to include('')
expect(mail.html_part.body.to_s).to include('font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;')
expect(mail.html_part.body.to_s).to include('')
end
end
context 'when no complete HTML document is provided' do
let(:html_body) do
<<~HTML.chomp
Test Admin Agent
--
Super Support - Waterford Business Park
5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA
Email: hot@example.com - Web:
http://www.example.com/
--
HTML
end
it 'completes the HTML document and adjusts the inline images width and height' do
expect(mail.html_part.body.to_s).to include('')
expect(mail.html_part.body.to_s).to include("font-family:'Helvetica Neue', Helvetica, Arial, Geneva, sans-serif; font-size: 12px;")
expect(mail.html_part.body.to_s).to include('')
end
end
end