mirror of
https://github.com/redmine/redmine.git
synced 2025-11-01 19:05:51 +01:00
shorten long line of ApplicationHelperTest
git-svn-id: http://svn.redmine.org/redmine/trunk@20613 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -74,16 +74,23 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
'https://foo.bar.' => '<a class="external" href="https://foo.bar">https://foo.bar</a>.',
|
||||
'This is a link: http://foo.bar.' => 'This is a link: <a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
||||
'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" href="http://foo.bar">http://foo.bar</a>).',
|
||||
'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
|
||||
'http://www.foo.bar/Test_(foobar)' => '<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
||||
'(see inline link : http://www.foo.bar/Test_(foobar))' => '(see inline link : <a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>)',
|
||||
'(see inline link : http://www.foo.bar/Test)' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>)',
|
||||
'(see inline link : http://www.foo.bar/Test).' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>).',
|
||||
'(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)',
|
||||
'http://foo.bar/foo.bar#foo.bar.' =>
|
||||
'<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
|
||||
'http://www.foo.bar/Test_(foobar)' =>
|
||||
'<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
||||
'(see inline link : http://www.foo.bar/Test_(foobar))' =>
|
||||
'(see inline link : <a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>)',
|
||||
'(see inline link : http://www.foo.bar/Test)' =>
|
||||
'(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>)',
|
||||
'(see inline link : http://www.foo.bar/Test).' =>
|
||||
'(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>).',
|
||||
'(see "inline link":http://www.foo.bar/Test_(foobar))' =>
|
||||
'(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)',
|
||||
'(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)',
|
||||
'(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).',
|
||||
'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
|
||||
'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
|
||||
'http://foo.bar/page?p=1&t=z&s=' =>
|
||||
'<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
|
||||
'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
|
||||
'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
|
||||
'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
|
||||
@@ -91,7 +98,9 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
'ftps://foo.bar' => '<a class="external" href="ftps://foo.bar">ftps://foo.bar</a>',
|
||||
'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>',
|
||||
# two exclamation marks
|
||||
'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
|
||||
'http://example.net/path!602815048C7B5C20!302.html' =>
|
||||
'<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">' \
|
||||
'http://example.net/path!602815048C7B5C20!302.html</a>',
|
||||
# escaping
|
||||
'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>',
|
||||
# wrap in angle brackets
|
||||
@@ -101,7 +110,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
'www.' => 'www.',
|
||||
'test-www.bar.com' => 'test-www.bar.com',
|
||||
# ends with a hyphen
|
||||
'http://www.redmine.org/example-' => '<a class="external" href="http://www.redmine.org/example-">http://www.redmine.org/example-</a>',
|
||||
'http://www.redmine.org/example-' =>
|
||||
'<a class="external" href="http://www.redmine.org/example-">http://www.redmine.org/example-</a>',
|
||||
}
|
||||
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)}
|
||||
end
|
||||
@@ -125,12 +135,19 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
def test_inline_images
|
||||
to_test = {
|
||||
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
|
||||
'floating !>http://foo.bar/image.jpg!' => 'floating <span style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></span>',
|
||||
'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="wiki-class-some-class" alt="" />',
|
||||
'with class !(wiki-class-foo)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="wiki-class-foo" alt="" />',
|
||||
'with style !{width:100px;height:100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height:100px;" alt="" />',
|
||||
'with title !http://foo.bar/image.jpg(This is a title)!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a title" alt="This is a title" />',
|
||||
'with title !http://foo.bar/image.jpg(This is a double-quoted "title")!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a double-quoted "title"" alt="This is a double-quoted "title"" />',
|
||||
'floating !>http://foo.bar/image.jpg!' =>
|
||||
'floating <span style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></span>',
|
||||
'with class !(some-class)http://foo.bar/image.jpg!' =>
|
||||
'with class <img src="http://foo.bar/image.jpg" class="wiki-class-some-class" alt="" />',
|
||||
'with class !(wiki-class-foo)http://foo.bar/image.jpg!' =>
|
||||
'with class <img src="http://foo.bar/image.jpg" class="wiki-class-foo" alt="" />',
|
||||
'with style !{width:100px;height:100px}http://foo.bar/image.jpg!' =>
|
||||
'with style <img src="http://foo.bar/image.jpg" style="width:100px;height:100px;" alt="" />',
|
||||
'with title !http://foo.bar/image.jpg(This is a title)!' =>
|
||||
'with title <img src="http://foo.bar/image.jpg" title="This is a title" alt="This is a title" />',
|
||||
'with title !http://foo.bar/image.jpg(This is a double-quoted "title")!' =>
|
||||
'with title <img src="http://foo.bar/image.jpg" title="This is a double-quoted "title"" ' \
|
||||
'alt="This is a double-quoted "title"" />',
|
||||
}
|
||||
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)}
|
||||
end
|
||||
@@ -149,12 +166,15 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
|
||||
def test_attached_images
|
||||
to_test = {
|
||||
'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />',
|
||||
'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />',
|
||||
'Inline image: !logo.gif!' =>
|
||||
'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />',
|
||||
'Inline image: !logo.GIF!' =>
|
||||
'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />',
|
||||
'No match: !ogo.gif!' => 'No match: <img src="ogo.gif" alt="" />',
|
||||
'No match: !ogo.GIF!' => 'No match: <img src="ogo.GIF" alt="" />',
|
||||
# link image
|
||||
'!logo.gif!:http://foo.bar/' => '<a href="http://foo.bar/"><img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" /></a>',
|
||||
'!logo.gif!:http://foo.bar/' =>
|
||||
'<a href="http://foo.bar/"><img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" /></a>',
|
||||
}
|
||||
attachments = Attachment.all
|
||||
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments)}
|
||||
@@ -168,7 +188,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
with_settings :text_formatting => 'textile' do
|
||||
to_test.each do |filename, result|
|
||||
attachment = Attachment.generate!(:filename => filename)
|
||||
assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />), textilizable("!#{filename}!", :attachments => [attachment])
|
||||
assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />),
|
||||
textilizable("!#{filename}!", :attachments => [attachment])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -183,7 +204,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
with_settings :text_formatting => 'markdown' do
|
||||
to_test.each do |filename, result|
|
||||
attachment = Attachment.generate!(:filename => filename)
|
||||
assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />), textilizable("", :attachments => [attachment])
|
||||
assert_include %(<img src="/attachments/download/#{attachment.id}/#{result}" alt="" />),
|
||||
textilizable("", :attachments => [attachment])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -191,7 +213,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
def test_attached_images_with_hires_naming
|
||||
attachment = Attachment.generate!(:filename => 'image@2x.png')
|
||||
assert_equal(
|
||||
%(<p><img src="/attachments/download/#{attachment.id}/image@2x.png" srcset="/attachments/download/#{attachment.id}/image@2x.png 2x" alt="" /></p>),
|
||||
%(<p><img src="/attachments/download/#{attachment.id}/image@2x.png" ) +
|
||||
%(srcset="/attachments/download/#{attachment.id}/image@2x.png 2x" alt="" /></p>),
|
||||
textilizable("!image@2x.png!", :attachments => [attachment])
|
||||
)
|
||||
end
|
||||
@@ -287,19 +310,25 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
|
||||
'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>',
|
||||
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>',
|
||||
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
||||
'"link (Link title with "double-quotes")":http://foo.bar' =>
|
||||
'<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
||||
"This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
|
||||
# no multiline link text
|
||||
"This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line<br />and another on a second line\":test",
|
||||
"This is a double quote \"on the first line\nand another on a second line\":test" =>
|
||||
"This is a double quote \"on the first line<br />and another on a second line\":test",
|
||||
# mailto link
|
||||
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
||||
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" =>
|
||||
"<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
||||
# two exclamation marks
|
||||
'"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
|
||||
'"a link":http://example.net/path!602815048C7B5C20!302.html' =>
|
||||
'<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
|
||||
# escaping
|
||||
'"test":http://foo"bar' => '<a href="http://foo"bar" class="external">test</a>',
|
||||
# ends with a hyphen
|
||||
'(see "inline link":http://www.foo.bar/Test-)' => '(see <a href="http://www.foo.bar/Test-" class="external">inline link</a>)',
|
||||
'http://foo.bar/page?p=1&t=z&s=-' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=-">http://foo.bar/page?p=1&t=z&s=-</a>',
|
||||
'(see "inline link":http://www.foo.bar/Test-)' =>
|
||||
'(see <a href="http://www.foo.bar/Test-" class="external">inline link</a>)',
|
||||
'http://foo.bar/page?p=1&t=z&s=-' =>
|
||||
'<a class="external" href="http://foo.bar/page?p=1&t=z&s=-">http://foo.bar/page?p=1&t=z&s=-</a>',
|
||||
'This is an intern "link":/foo/bar-' => 'This is an intern <a href="/foo/bar-">link</a>'
|
||||
}
|
||||
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)}
|
||||
@@ -1747,7 +1776,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
[projects(:projects_001), '<a href="/projects/ecookbook">eCookbook</a>'],
|
||||
[users(:users_001), '<a class="user active" href="/users/1">Redmine Admin</a>'],
|
||||
[versions(:versions_001), '<a title="07/01/2006" href="/versions/1">eCookbook - 0.1</a>'],
|
||||
[wiki_pages(:wiki_pages_001), '<a href="/projects/ecookbook/wiki/CookBook_documentation">CookBook documentation</a>']
|
||||
[wiki_pages(:wiki_pages_001),
|
||||
'<a href="/projects/ecookbook/wiki/CookBook_documentation">CookBook documentation</a>']
|
||||
].each do |record, link|
|
||||
assert_equal link, link_to_record(record)
|
||||
end
|
||||
@@ -1773,7 +1803,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
[news_attachment, '<a href="/news/1">eCookbook first release !</a>'],
|
||||
[attachments(:attachments_008), '<a href="/projects/ecookbook/files">Files</a>'],
|
||||
[attachments(:attachments_009), '<a href="/projects/ecookbook/files">Files</a>'],
|
||||
[attachments(:attachments_003), '<a href="/projects/ecookbook/wiki/Page_with_an_inline_image">Page with an inline image</a>'],
|
||||
[attachments(:attachments_003),
|
||||
'<a href="/projects/ecookbook/wiki/Page_with_an_inline_image">Page with an inline image</a>'],
|
||||
].each do |attachment, link|
|
||||
assert_equal link, link_to_attachment_container(attachment.container)
|
||||
end
|
||||
@@ -1838,7 +1869,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
set_language_if_valid 'en'
|
||||
users = [User.find(2), User.find(4)]
|
||||
User.current = User.find(4)
|
||||
assert_include '<option value="4"><< me >></option>', principals_options_for_select(users)
|
||||
assert_include '<option value="4"><< me >></option>',
|
||||
principals_options_for_select(users)
|
||||
end
|
||||
|
||||
def test_stylesheet_link_tag_should_pick_the_default_stylesheet
|
||||
@@ -1846,7 +1878,8 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
end
|
||||
|
||||
def test_stylesheet_link_tag_for_plugin_should_pick_the_plugin_stylesheet
|
||||
assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"', stylesheet_link_tag("styles", :plugin => :foo)
|
||||
assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"',
|
||||
stylesheet_link_tag("styles", :plugin => :foo)
|
||||
end
|
||||
|
||||
def test_image_tag_should_pick_the_default_image
|
||||
@@ -1976,8 +2009,10 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
end
|
||||
|
||||
def test_html_hours
|
||||
assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">:45</span>', html_hours('0:45')
|
||||
assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">.75</span>', html_hours('0.75')
|
||||
assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">:45</span>',
|
||||
html_hours('0:45')
|
||||
assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">.75</span>',
|
||||
html_hours('0.75')
|
||||
end
|
||||
|
||||
def test_form_for_includes_name_attribute
|
||||
@@ -2009,7 +2044,9 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
with_locale 'en' do
|
||||
assert_not_equal l(:general_csv_encoding), 'UTF-8'
|
||||
result = export_csv_encoding_select_tag
|
||||
assert_select_in result, "option[selected='selected'][value=#{l(:general_csv_encoding)}]", :text => l(:general_csv_encoding)
|
||||
assert_select_in result,
|
||||
"option[selected='selected'][value=#{l(:general_csv_encoding)}]",
|
||||
:text => l(:general_csv_encoding)
|
||||
assert_select_in result, "option[value='UTF-8']", :text => 'UTF-8'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user