Defect #40650 » 0001-Add-tests-for-current-alt-attribute-behavior-in-images.patch
| test/helpers/application_helper_test.rb | ||
|---|---|---|
| 198 | 198 |
end |
| 199 | 199 |
end |
| 200 | 200 | |
| 201 |
def test_attached_image_alt_attribute_with_textile |
|
| 202 |
attachments = Attachment.all |
|
| 203 |
with_settings text_formatting: 'textile' do |
|
| 204 |
# When alt text is set |
|
| 205 |
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?" title="alt text" alt="alt text" />], |
|
| 206 |
textilizable('!logo.gif(alt text)!', attachments: attachments)
|
|
| 207 | ||
| 208 |
# When alt text and style are set |
|
| 209 |
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?" style="width:100px;" title="alt text" alt="alt text" />], |
|
| 210 |
textilizable('!{width:100px}logo.gif(alt text)!', attachments: attachments)
|
|
| 211 | ||
| 212 |
# When alt text is not set |
|
| 213 |
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?" />], |
|
| 214 |
textilizable('!logo.gif!', attachments: attachments)
|
|
| 215 | ||
| 216 |
# When alt text is not set and the attachment has no description |
|
| 217 |
assert_match %r[<img src=".+?" alt="" loading=".+?" />], |
|
| 218 |
textilizable('!testfile.PNG!', attachments: attachments)
|
|
| 219 | ||
| 220 |
# When no matching attachments are found |
|
| 221 |
assert_match %r[<img src=".+?" alt="" />], |
|
| 222 |
textilizable('!no-match.jpg!', attachments: attachments)
|
|
| 223 |
assert_match %r[<img src=".+?" alt="alt text" />], |
|
| 224 |
textilizable('!no-match.jpg(alt text)!', attachments: attachments)
|
|
| 225 | ||
| 226 |
# When no attachment is registered |
|
| 227 |
assert_match %r[<img src=".+?" alt="" />], |
|
| 228 |
textilizable('!logo.gif!', attachments: [])
|
|
| 229 |
assert_match %r[<img src=".+?" alt="alt text" />], |
|
| 230 |
textilizable('!logo.gif(alt text)!', attachments: [])
|
|
| 231 |
end |
|
| 232 |
end |
|
| 233 | ||
| 201 | 234 |
def test_attached_images_on_issue |
| 202 | 235 |
issue = Issue.generate! |
| 203 | 236 |
attachment_1 = Attachment.generate!(:file => mock_file_with_options(:original_filename => "attached_on_issue.png"), :container => issue) |
| test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb | ||
|---|---|---|
| 62 | 62 |
end |
| 63 | 63 |
end |
| 64 | 64 | |
| 65 |
def test_attached_image_alt_attribute_with_madkrown |
|
| 66 |
attachments = Attachment.all |
|
| 67 |
with_settings text_formatting: 'common_mark' do |
|
| 68 |
# When alt text is set |
|
| 69 |
assert_match %r[<img src=".+?" alt="alt text" loading=".+?">], |
|
| 70 |
textilizable('', attachments: attachments)
|
|
| 71 | ||
| 72 |
# When alt text is not set |
|
| 73 |
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?">], |
|
| 74 |
textilizable('', attachments: attachments)
|
|
| 75 | ||
| 76 |
# When alt text is not set and the attachment has no description |
|
| 77 |
assert_match %r[<img src=".+?" alt="" loading=".+?">], |
|
| 78 |
textilizable('', attachments: attachments)
|
|
| 79 | ||
| 80 |
# When no matching attachments are found |
|
| 81 |
assert_match %r[<img src=".+?" alt="">], |
|
| 82 |
textilizable('', attachments: attachments)
|
|
| 83 |
assert_match %r[<img src=".+?" alt="alt text">], |
|
| 84 |
textilizable('', attachments: attachments)
|
|
| 85 | ||
| 86 |
# When no attachment is registered |
|
| 87 |
assert_match %r[<img src=".+?" alt="">], |
|
| 88 |
textilizable('', attachments: [])
|
|
| 89 |
assert_match %r[<img src=".+?" alt="alt text">], |
|
| 90 |
textilizable('', attachments: [])
|
|
| 91 |
end |
|
| 92 |
end |
|
| 65 | 93 |
end |
| 66 | 94 |
end |