, mixed with other HTML elements' do
let(:html) { '
123
' }
it 'converts embedded image to cid' do
expect(body).to match(%r{
\s+
123
\s+
\s+
})
end
it 'extracts two attachments' do
expect(inline_attachments.length).to be(2)
end
it 'sets filenames sequentially (as imageN.jpeg)' do
expect(inline_attachments.first[:filename]).to eq('image1.jpeg')
expect(inline_attachments.second[:filename]).to eq('image2.jpeg')
end
it 'sets Content-Types to image/jpeg' do
expect(inline_attachments.first[:preferences]['Content-Type']).to eq('image/jpeg')
expect(inline_attachments.second[:preferences]['Content-Type']).to eq('image/jpeg')
end
it 'sets Content-IDs based on Zammad fqdn' do
expect(inline_attachments.first[:preferences]['Content-ID']).to match(/@#{Setting.get('fqdn')}/)
expect(inline_attachments.second[:preferences]['Content-ID']).to match(/@#{Setting.get('fqdn')}/)
end
it 'sets Content-Dispositions to inline' do
expect(inline_attachments.first[:preferences]['Content-Disposition']).to eq('inline')
expect(inline_attachments.second[:preferences]['Content-Disposition']).to eq('inline')
end
end
end
end
describe '.dynamic_image_size' do
context 'for image at absolute path' do
context 'with src attr last' do
it 'add max-width: 100% rule to style attr' do
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
context 'with src attr first' do
it 'add max-width: 100% rule to style attr' do
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
end
context 'for base64-encoded inline images' do
context 'with src attr last' do
it 'add max-width: 100% rule to style attr' do
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
context 'with src attr first' do
it 'add max-width: 100% rule to style attr' do
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
end
end
end