inline_image_adjustments_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Channel::EmailBuild > Inline Images Adjustments', aggregate_failures: true, type: :model do
  4. let(:html_body) do
  5. <<~HTML.chomp
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  10. </head>
  11. <body style="font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;">
  12. <img style="width: 125px; max-width: 100%; height: 187.5px;" src="cid:1.e83460e9-7e36-48f7-97db-dc7f0ba7c51f@zammad.example.com">
  13. <br><br>
  14. <div data-signature="true" data-signature-id="1">
  15. Test Admin Agent<br><br>
  16. --<br>
  17. Super Support - Waterford Business Park<br>
  18. 5201 Blue Lagoon Drive - 8th Floor &amp; 9th Floor - Miami, 33126 USA<br>
  19. Email: hot@example.com - Web: <a href="http://www.example.com/" rel="nofollow noreferrer noopener" target="_blank">http://www.example.com/</a><br>
  20. --
  21. </div>
  22. </body>
  23. </html>
  24. HTML
  25. end
  26. let(:mail) do
  27. Channel::EmailBuild.build(
  28. from: 'sender@example.com',
  29. to: 'recipient@example.com',
  30. body: html_body,
  31. content_type: 'text/html',
  32. )
  33. end
  34. context 'when an email is built with inline images' do
  35. it 'adjusts the inline images width and height' do
  36. expect(mail.html_part.body.to_s).to include('<img style="width: 125px; max-width: 100%; height: 187.5px;" src="cid:1.e83460e9-7e36-48f7-97db-dc7f0ba7c51f@zammad.example.com" height="187.5" width="125">')
  37. end
  38. end
  39. end