mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Add tests for current alt attribute behavior in images (#40650).
Patch by Katsuya HIDAKA (@hidakatsuya). git-svn-id: https://svn.redmine.org/redmine/trunk@22844 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
81e0a93238
commit
9293b72a45
@ -198,6 +198,39 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_attached_image_alt_attribute_with_textile
|
||||
attachments = Attachment.all
|
||||
with_settings text_formatting: 'textile' do
|
||||
# When alt text is set
|
||||
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?" title="alt text" alt="alt text" />],
|
||||
textilizable('!logo.gif(alt text)!', attachments: attachments)
|
||||
|
||||
# When alt text and style are set
|
||||
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" />],
|
||||
textilizable('!{width:100px}logo.gif(alt text)!', attachments: attachments)
|
||||
|
||||
# When alt text is not set
|
||||
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?" />],
|
||||
textilizable('!logo.gif!', attachments: attachments)
|
||||
|
||||
# When alt text is not set and the attachment has no description
|
||||
assert_match %r[<img src=".+?" alt="" loading=".+?" />],
|
||||
textilizable('!testfile.PNG!', attachments: attachments)
|
||||
|
||||
# When no matching attachments are found
|
||||
assert_match %r[<img src=".+?" alt="" />],
|
||||
textilizable('!no-match.jpg!', attachments: attachments)
|
||||
assert_match %r[<img src=".+?" alt="alt text" />],
|
||||
textilizable('!no-match.jpg(alt text)!', attachments: attachments)
|
||||
|
||||
# When no attachment is registered
|
||||
assert_match %r[<img src=".+?" alt="" />],
|
||||
textilizable('!logo.gif!', attachments: [])
|
||||
assert_match %r[<img src=".+?" alt="alt text" />],
|
||||
textilizable('!logo.gif(alt text)!', attachments: [])
|
||||
end
|
||||
end
|
||||
|
||||
def test_attached_images_on_issue
|
||||
issue = Issue.generate!
|
||||
attachment_1 = Attachment.generate!(:file => mock_file_with_options(:original_filename => "attached_on_issue.png"), :container => issue)
|
||||
|
||||
@ -62,5 +62,33 @@ class Redmine::WikiFormatting::CommonMark::ApplicationHelperTest < Redmine::Help
|
||||
end
|
||||
end
|
||||
|
||||
def test_attached_image_alt_attribute_with_madkrown
|
||||
attachments = Attachment.all
|
||||
with_settings text_formatting: 'common_mark' do
|
||||
# When alt text is set
|
||||
assert_match %r[<img src=".+?" alt="alt text" loading=".+?">],
|
||||
textilizable('', attachments: attachments)
|
||||
|
||||
# When alt text is not set
|
||||
assert_match %r[<img src=".+?" title="This is a logo" alt="This is a logo" loading=".+?">],
|
||||
textilizable('', attachments: attachments)
|
||||
|
||||
# When alt text is not set and the attachment has no description
|
||||
assert_match %r[<img src=".+?" alt="" loading=".+?">],
|
||||
textilizable('', attachments: attachments)
|
||||
|
||||
# When no matching attachments are found
|
||||
assert_match %r[<img src=".+?" alt="">],
|
||||
textilizable('', attachments: attachments)
|
||||
assert_match %r[<img src=".+?" alt="alt text">],
|
||||
textilizable('', attachments: attachments)
|
||||
|
||||
# When no attachment is registered
|
||||
assert_match %r[<img src=".+?" alt="">],
|
||||
textilizable('', attachments: [])
|
||||
assert_match %r[<img src=".+?" alt="alt text">],
|
||||
textilizable('', attachments: [])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user