1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-20 15:31:12 +00:00

fix source indent of ApplicationHelperTest

git-svn-id: http://svn.redmine.org/redmine/trunk@20071 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2020-09-24 16:06:32 +00:00
parent fd30592dd3
commit f33d2d0be4

View File

@ -45,9 +45,11 @@ class ApplicationHelperTest < Redmine::HelperTest
User.current = User.find_by_login('admin') User.current = User.find_by_login('admin')
@project = Issue.first.project # Used by helper @project = Issue.first.project # Used by helper
response = link_to_if_authorized( response =
'By controller/actionr', link_to_if_authorized(
{:controller => 'issues', :action => 'edit', :id => Issue.first.id}) 'By controller/actionr',
{:controller => 'issues', :action => 'edit', :id => Issue.first.id}
)
assert_match /href/, response assert_match /href/, response
end end
@ -56,9 +58,11 @@ class ApplicationHelperTest < Redmine::HelperTest
@project = Project.find('private-child') @project = Project.find('private-child')
issue = @project.issues.first issue = @project.issues.first
assert !issue.visible? assert !issue.visible?
response = link_to_if_authorized( response =
'Never displayed', link_to_if_authorized(
{:controller => 'issues', :action => 'show', :id => issue}) 'Never displayed',
{:controller => 'issues', :action => 'show', :id => issue}
)
assert_nil response assert_nil response
end end
@ -187,42 +191,51 @@ class ApplicationHelperTest < Redmine::HelperTest
def test_attached_images_with_hires_naming def test_attached_images_with_hires_naming
attachment = Attachment.generate!(:filename => 'image@2x.png') attachment = Attachment.generate!(:filename => 'image@2x.png')
assert_equal( 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])) textilizable("!image@2x.png!", :attachments => [attachment])
)
end end
def test_attached_images_filename_extension def test_attached_images_filename_extension
a1 = Attachment.new( a1 =
:container => Issue.find(1), Attachment.new(
:file => mock_file_with_options({:original_filename => "testtest.JPG"}), :container => Issue.find(1),
:author => User.find(1)) :file => mock_file_with_options({:original_filename => "testtest.JPG"}),
:author => User.find(1)
)
assert a1.save assert a1.save
assert_equal "testtest.JPG", a1.filename assert_equal "testtest.JPG", a1.filename
assert_equal "image/jpeg", a1.content_type assert_equal "image/jpeg", a1.content_type
assert a1.image? assert a1.image?
a2 = Attachment.new( a2 =
:container => Issue.find(1), Attachment.new(
:file => mock_file_with_options({:original_filename => "testtest.jpeg"}), :container => Issue.find(1),
:author => User.find(1)) :file => mock_file_with_options({:original_filename => "testtest.jpeg"}),
:author => User.find(1)
)
assert a2.save assert a2.save
assert_equal "testtest.jpeg", a2.filename assert_equal "testtest.jpeg", a2.filename
assert_equal "image/jpeg", a2.content_type assert_equal "image/jpeg", a2.content_type
assert a2.image? assert a2.image?
a3 = Attachment.new( a3 =
:container => Issue.find(1), Attachment.new(
:file => mock_file_with_options({:original_filename => "testtest.JPE"}), :container => Issue.find(1),
:author => User.find(1)) :file => mock_file_with_options({:original_filename => "testtest.JPE"}),
:author => User.find(1)
)
assert a3.save assert a3.save
assert_equal "testtest.JPE", a3.filename assert_equal "testtest.JPE", a3.filename
assert_equal "image/jpeg", a3.content_type assert_equal "image/jpeg", a3.content_type
assert a3.image? assert a3.image?
a4 = Attachment.new( a4 =
:container => Issue.find(1), Attachment.new(
:file => mock_file_with_options({:original_filename => "Testtest.BMP"}), :container => Issue.find(1),
:author => User.find(1)) :file => mock_file_with_options({:original_filename => "Testtest.BMP"}),
:author => User.find(1)
)
assert a4.save assert a4.save
assert_equal "Testtest.BMP", a4.filename assert_equal "Testtest.BMP", a4.filename
assert_equal "image/x-ms-bmp", a4.content_type assert_equal "image/x-ms-bmp", a4.content_type
@ -310,60 +323,74 @@ class ApplicationHelperTest < Redmine::HelperTest
{:controller => 'issues', :action => 'show', :id => 3}, {:controller => 'issues', :action => 'show', :id => 3},
:class => Issue.find(3).css_classes, :class => Issue.find(3).css_classes,
:title => 'Bug: Error 281 when updating a recipe (New)') :title => 'Bug: Error 281 when updating a recipe (New)')
ext_issue_link = link_to( ext_issue_link =
'Bug #3: Error 281 when updating a recipe', link_to(
{:controller => 'issues', :action => 'show', :id => 3}, 'Bug #3: Error 281 when updating a recipe',
:class => Issue.find(3).css_classes, {:controller => 'issues', :action => 'show', :id => 3},
:title => 'Status: New') :class => Issue.find(3).css_classes,
note_link = link_to( :title => 'Status: New'
'#3-14', )
{:controller => 'issues', :action => 'show', note_link =
:id => 3, :anchor => 'note-14'}, link_to(
:class => Issue.find(3).css_classes, '#3-14',
:title => 'Bug: Error 281 when updating a recipe (New)') {:controller => 'issues', :action => 'show',
ext_note_link = link_to( :id => 3, :anchor => 'note-14'},
'Bug #3-14: Error 281 when updating a recipe', :class => Issue.find(3).css_classes,
{:controller => 'issues', :action => 'show', :title => 'Bug: Error 281 when updating a recipe (New)'
:id => 3, :anchor => 'note-14'}, )
:class => Issue.find(3).css_classes, ext_note_link =
:title => 'Status: New') link_to(
note_link2 = link_to( 'Bug #3-14: Error 281 when updating a recipe',
'#3#note-14', {:controller => 'issues', :action => 'show',
{:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'},
:id => 3, :anchor => 'note-14'}, :class => Issue.find(3).css_classes,
:class => Issue.find(3).css_classes, :title => 'Status: New'
:title => 'Bug: Error 281 when updating a recipe (New)') )
ext_note_link2 = link_to( note_link2 =
'Bug #3#note-14: Error 281 when updating a recipe', link_to(
{:controller => 'issues', :action => 'show', '#3#note-14',
:id => 3, :anchor => 'note-14'}, {:controller => 'issues', :action => 'show',
:class => Issue.find(3).css_classes, :id => 3, :anchor => 'note-14'},
:title => 'Status: New') :class => Issue.find(3).css_classes,
:title => 'Bug: Error 281 when updating a recipe (New)'
revision_link = link_to( )
'r1', ext_note_link2 =
{:controller => 'repositories', :action => 'revision', link_to(
:id => 'ecookbook', :repository_id => 10, :rev => 1}, 'Bug #3#note-14: Error 281 when updating a recipe',
:class => 'changeset', {:controller => 'issues', :action => 'show',
:title => 'My very first commit do not escaping #<>&') :id => 3, :anchor => 'note-14'},
revision_link2 = link_to( :class => Issue.find(3).css_classes,
'r2', :title => 'Status: New'
{:controller => 'repositories', :action => 'revision', )
:id => 'ecookbook', :repository_id => 10, :rev => 2}, revision_link =
:class => 'changeset', link_to(
:title => 'This commit fixes #1, #2 and references #1 & #3') 'r1',
{:controller => 'repositories', :action => 'revision',
changeset_link2 = link_to( :id => 'ecookbook', :repository_id => 10, :rev => 1},
'691322a8eb01e11fd7', :class => 'changeset',
{:controller => 'repositories', :action => 'revision', :title => 'My very first commit do not escaping #<>&'
:id => 'ecookbook', :repository_id => 10, :rev => 1}, )
:class => 'changeset', :title => 'My very first commit do not escaping #<>&') revision_link2 =
link_to(
document_link = link_to( 'r2',
'Test document', {:controller => 'repositories', :action => 'revision',
{:controller => 'documents', :action => 'show', :id => 1}, :id => 'ecookbook', :repository_id => 10, :rev => 2},
:class => 'document') :class => 'changeset',
:title => 'This commit fixes #1, #2 and references #1 & #3'
)
changeset_link2 =
link_to(
'691322a8eb01e11fd7',
{:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 1},
:class => 'changeset', :title => 'My very first commit do not escaping #<>&'
)
document_link =
link_to(
'Test document',
{:controller => 'documents', :action => 'show', :id => 1},
:class => 'document'
)
version_link = link_to('1.0', version_link = link_to('1.0',
{:controller => 'versions', :action => 'show', :id => 2}, {:controller => 'versions', :action => 'show', :id => 2},
:class => 'version') :class => 'version')
@ -633,22 +660,28 @@ class ApplicationHelperTest < Redmine::HelperTest
hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg') hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg')
Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd') Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd')
changeset_link = link_to( changeset_link =
'r2', link_to(
{:controller => 'repositories', :action => 'revision', 'r2',
:id => 'ecookbook', :repository_id => 10, :rev => 2}, {:controller => 'repositories', :action => 'revision',
:class => 'changeset', :id => 'ecookbook', :repository_id => 10, :rev => 2},
:title => 'This commit fixes #1, #2 and references #1 & #3') :class => 'changeset',
svn_changeset_link = link_to( :title => 'This commit fixes #1, #2 and references #1 & #3'
'svn_repo-1|r123', )
{:controller => 'repositories', :action => 'revision', svn_changeset_link =
:id => 'ecookbook', :repository_id => 'svn_repo-1', :rev => 123}, link_to(
:class => 'changeset', :title => '') 'svn_repo-1|r123',
hg_changeset_link = link_to( {:controller => 'repositories', :action => 'revision',
'hg1|abcd', :id => 'ecookbook', :repository_id => 'svn_repo-1', :rev => 123},
{:controller => 'repositories', :action => 'revision', :class => 'changeset', :title => ''
:id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, )
:class => 'changeset', :title => '') hg_changeset_link =
link_to(
'hg1|abcd',
{:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'},
:class => 'changeset', :title => ''
)
source_link = link_to('source:some/file', source_link = link_to('source:some/file',
{:controller => 'repositories', :action => 'entry', {:controller => 'repositories', :action => 'entry',
:id => 'ecookbook', :repository_id => 10, :id => 'ecookbook', :repository_id => 10,
@ -682,27 +715,36 @@ class ApplicationHelperTest < Redmine::HelperTest
hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg') hg = Repository::Mercurial.create!(:project_id => 1, :identifier => 'hg1', :url => '/foo/hg')
Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd') Changeset.create!(:repository => hg, :committed_on => Time.now, :revision => '123', :scmid => 'abcd')
changeset_link = link_to( changeset_link =
'ecookbook:r2', link_to(
{:controller => 'repositories', :action => 'revision', 'ecookbook:r2',
:id => 'ecookbook', :repository_id => 10, :rev => 2}, {:controller => 'repositories', :action => 'revision',
:class => 'changeset', :id => 'ecookbook', :repository_id => 10, :rev => 2},
:title => 'This commit fixes #1, #2 and references #1 & #3') :class => 'changeset',
svn_changeset_link = link_to( :title => 'This commit fixes #1, #2 and references #1 & #3'
'ecookbook:svn1|r123', )
{:controller => 'repositories', :action => 'revision', svn_changeset_link =
:id => 'ecookbook', :repository_id => 'svn1', :rev => 123}, link_to(
:class => 'changeset', :title => '') 'ecookbook:svn1|r123',
hg_changeset_link = link_to( {:controller => 'repositories', :action => 'revision',
'ecookbook:hg1|abcd', :id => 'ecookbook', :repository_id => 'svn1', :rev => 123},
{:controller => 'repositories', :action => 'revision', :class => 'changeset', :title => ''
:id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, )
:class => 'changeset', :title => '') hg_changeset_link =
link_to(
source_link = link_to('ecookbook:source:some/file', 'ecookbook:hg1|abcd',
{:controller => 'repositories', :action => 'entry', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'},
:path => ['some', 'file']}, :class => 'source') :class => 'changeset', :title => ''
)
source_link =
link_to(
'ecookbook:source:some/file',
{:controller => 'repositories', :action => 'entry',
:id => 'ecookbook', :repository_id => 10,
:path => ['some', 'file']},
:class => 'source'
)
hg_source_link = link_to('ecookbook:source:hg1|some/file', hg_source_link = link_to('ecookbook:source:hg1|some/file',
{:controller => 'repositories', :action => 'entry', {:controller => 'repositories', :action => 'entry',
:id => 'ecookbook', :repository_id => 'hg1', :id => 'ecookbook', :repository_id => 'hg1',
@ -727,24 +769,29 @@ class ApplicationHelperTest < Redmine::HelperTest
def test_redmine_links_git_commit def test_redmine_links_git_commit
@project = Project.find(3) @project = Project.find(3)
r = Repository::Git.create!(:project => @project, :url => '/tmp/test/git') r = Repository::Git.create!(:project => @project, :url => '/tmp/test/git')
c = Changeset.create!( c =
:repository => r, Changeset.create!(
:committed_on => Time.now, :repository => r,
:revision => 'abcd', :committed_on => Time.now,
:scmid => 'abcd', :revision => 'abcd',
:comments => 'test commit') :scmid => 'abcd',
changeset_link = link_to('abcd', :comments => 'test commit'
{ )
:controller => 'repositories', changeset_link =
:action => 'revision', link_to(
:id => 'subproject1', 'abcd',
:repository_id => r.id, {
:rev => 'abcd', :controller => 'repositories',
}, :action => 'revision',
:class => 'changeset', :title => 'test commit') :id => 'subproject1',
:repository_id => r.id,
:rev => 'abcd',
},
:class => 'changeset', :title => 'test commit'
)
to_test = { to_test = {
'commit:abcd' => changeset_link, 'commit:abcd' => changeset_link,
} }
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)} to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)}
end end
@ -752,36 +799,42 @@ class ApplicationHelperTest < Redmine::HelperTest
def test_redmine_links_mercurial_commit def test_redmine_links_mercurial_commit
@project = Project.find(3) @project = Project.find(3)
r = Repository::Mercurial.create!(:project => @project, :url => '/tmp/test') r = Repository::Mercurial.create!(:project => @project, :url => '/tmp/test')
c = Changeset.create!( c =
:repository => r, Changeset.create!(
:committed_on => Time.now, :repository => r,
:revision => '123', :committed_on => Time.now,
:scmid => 'abcd', :revision => '123',
:comments => 'test commit') :scmid => 'abcd',
changeset_link_rev = link_to( :comments => 'test commit'
'r123', )
{ changeset_link_rev =
:controller => 'repositories', link_to(
:action => 'revision', 'r123',
:id => 'subproject1', {
:repository_id => r.id, :controller => 'repositories',
:rev => '123', :action => 'revision',
}, :id => 'subproject1',
:class => 'changeset', :title => 'test commit') :repository_id => r.id,
changeset_link_commit = link_to( :rev => '123',
'abcd', },
{ :class => 'changeset', :title => 'test commit'
:controller => 'repositories', )
:action => 'revision', changeset_link_commit =
:id => 'subproject1', link_to(
:repository_id => r.id, 'abcd',
:rev => 'abcd', {
}, :controller => 'repositories',
:class => 'changeset', :title => 'test commit') :action => 'revision',
:id => 'subproject1',
:repository_id => r.id,
:rev => 'abcd',
},
:class => 'changeset', :title => 'test commit'
)
to_test = { to_test = {
'r123' => changeset_link_rev, 'r123' => changeset_link_rev,
'commit:abcd' => changeset_link_commit, 'commit:abcd' => changeset_link_commit,
} }
to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)} to_test.each {|text, result| assert_equal "<p>#{result}</p>", textilizable(text)}
end end
@ -1460,12 +1513,13 @@ class ApplicationHelperTest < Redmine::HelperTest
RAW RAW
@project = Project.find(1) @project = Project.find(1)
set_language_if_valid 'en' set_language_if_valid 'en'
result = textilizable( result =
raw, textilizable(
:edit_section_links => raw,
{:controller => 'wiki', :action => 'edit', :edit_section_links =>
:project_id => '1', :id => 'Test'} {:controller => 'wiki', :action => 'edit',
).gsub("\n", "") :project_id => '1', :id => 'Test'}
).gsub("\n", "")
# heading that contains inline code # heading that contains inline code
assert_match( assert_match(
Regexp.new('<div class="contextual heading-2" title="Edit this section" id="section-4">' + Regexp.new('<div class="contextual heading-2" title="Edit this section" id="section-4">' +