Skip to content

Commit

Permalink
Fixed usage of wrong assert (which resulted in always true/success by…
Browse files Browse the repository at this point in the history
… checking hard coded values).
  • Loading branch information
thorsteneckel committed Oct 24, 2018
1 parent a3e531a commit e0fd1e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/unit/aaa_string_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ class AaaStringTest < ActiveSupport::TestCase
html = '<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">'
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
assert_match(/<img style="width: 181px; height: 125px" src="cid:.+?">/, body)
assert(1, attachments_inline.count)
assert_equal(1, attachments_inline.count)
assert_equal('image1.jpeg', attachments_inline[0][:filename])
assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
Expand All @@ -1000,7 +1000,7 @@ class AaaStringTest < ActiveSupport::TestCase
html = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc">'
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
assert_match(/<img src="cid:.+?" style="width: 181px; height: 125px" alt="abc">/, body)
assert(1, attachments_inline.count)
assert_equal(1, attachments_inline.count)
assert_equal('image1.jpeg', attachments_inline[0][:filename])
assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
Expand All @@ -1009,7 +1009,7 @@ class AaaStringTest < ActiveSupport::TestCase
html = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc"><invalid what ever'
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
assert_match(/<img src="cid:.+?" style="width: 181px; height: 125px" alt="abc">/, body)
assert(1, attachments_inline.count)
assert_equal(1, attachments_inline.count)
assert_equal('image1.jpeg', attachments_inline[0][:filename])
assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
Expand All @@ -1018,12 +1018,12 @@ class AaaStringTest < ActiveSupport::TestCase
html = '<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">'
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
assert_match(/<img src="\/some_one.png" style="width: 181px; height: 125px" alt="abc">/, body)
assert(0, attachments_inline.count)
assert_equal(0, attachments_inline.count)

html = '<div><img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..."><p>123</p><img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..."></div>'
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
assert_match(/<div>\s+<img style="width: 181px; height: 125px" src="cid:.+?"><p>123<\/p>\s+<img style="width: 181px; height: 125px" src="cid:.+?">\s+<\/div>/, body)
assert(2, attachments_inline.count)
assert_equal(2, attachments_inline.count)
assert_equal('image1.jpeg', attachments_inline[0][:filename])
assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
Expand Down

0 comments on commit e0fd1e5

Please sign in to comment.