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 =
link_to_if_authorized(
'By controller/actionr', 'By controller/actionr',
{:controller => 'issues', :action => 'edit', :id => Issue.first.id}) {: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 =
link_to_if_authorized(
'Never displayed', 'Never displayed',
{:controller => 'issues', :action => 'show', :id => issue}) {:controller => 'issues', :action => 'show', :id => issue}
)
assert_nil response assert_nil response
end end
@ -188,41 +192,50 @@ class ApplicationHelperTest < Redmine::HelperTest
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 =
Attachment.new(
:container => Issue.find(1), :container => Issue.find(1),
:file => mock_file_with_options({:original_filename => "testtest.JPG"}), :file => mock_file_with_options({:original_filename => "testtest.JPG"}),
:author => User.find(1)) :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 =
Attachment.new(
:container => Issue.find(1), :container => Issue.find(1),
:file => mock_file_with_options({:original_filename => "testtest.jpeg"}), :file => mock_file_with_options({:original_filename => "testtest.jpeg"}),
:author => User.find(1)) :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 =
Attachment.new(
:container => Issue.find(1), :container => Issue.find(1),
:file => mock_file_with_options({:original_filename => "testtest.JPE"}), :file => mock_file_with_options({:original_filename => "testtest.JPE"}),
:author => User.find(1)) :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 =
Attachment.new(
:container => Issue.find(1), :container => Issue.find(1),
:file => mock_file_with_options({:original_filename => "Testtest.BMP"}), :file => mock_file_with_options({:original_filename => "Testtest.BMP"}),
:author => User.find(1)) :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 =
link_to(
'Bug #3: Error 281 when updating a recipe', 'Bug #3: Error 281 when updating a recipe',
{: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 => 'Status: New') :title => 'Status: New'
note_link = link_to( )
note_link =
link_to(
'#3-14', '#3-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 => 'Bug: Error 281 when updating a recipe (New)') :title => 'Bug: Error 281 when updating a recipe (New)'
ext_note_link = link_to( )
ext_note_link =
link_to(
'Bug #3-14: Error 281 when updating a recipe', 'Bug #3-14: Error 281 when updating a recipe',
{: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 => 'Status: New'
note_link2 = link_to( )
note_link2 =
link_to(
'#3#note-14', '#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 => 'Bug: Error 281 when updating a recipe (New)') :title => 'Bug: Error 281 when updating a recipe (New)'
ext_note_link2 = link_to( )
ext_note_link2 =
link_to(
'Bug #3#note-14: Error 281 when updating a recipe', 'Bug #3#note-14: Error 281 when updating a recipe',
{: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 => 'Status: New'
)
revision_link = link_to( revision_link =
link_to(
'r1', 'r1',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 1}, :id => 'ecookbook', :repository_id => 10, :rev => 1},
:class => 'changeset', :class => 'changeset',
:title => 'My very first commit do not escaping #<>&') :title => 'My very first commit do not escaping #<>&'
revision_link2 = link_to( )
revision_link2 =
link_to(
'r2', 'r2',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 2}, :id => 'ecookbook', :repository_id => 10, :rev => 2},
:class => 'changeset', :class => 'changeset',
:title => 'This commit fixes #1, #2 and references #1 & #3') :title => 'This commit fixes #1, #2 and references #1 & #3'
)
changeset_link2 = link_to( changeset_link2 =
link_to(
'691322a8eb01e11fd7', '691322a8eb01e11fd7',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 1}, :id => 'ecookbook', :repository_id => 10, :rev => 1},
:class => 'changeset', :title => 'My very first commit do not escaping #<>&') :class => 'changeset', :title => 'My very first commit do not escaping #<>&'
)
document_link = link_to( document_link =
link_to(
'Test document', 'Test document',
{:controller => 'documents', :action => 'show', :id => 1}, {:controller => 'documents', :action => 'show', :id => 1},
:class => 'document') :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 =
link_to(
'r2', 'r2',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 2}, :id => 'ecookbook', :repository_id => 10, :rev => 2},
:class => 'changeset', :class => 'changeset',
:title => 'This commit fixes #1, #2 and references #1 & #3') :title => 'This commit fixes #1, #2 and references #1 & #3'
svn_changeset_link = link_to( )
svn_changeset_link =
link_to(
'svn_repo-1|r123', 'svn_repo-1|r123',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 'svn_repo-1', :rev => 123}, :id => 'ecookbook', :repository_id => 'svn_repo-1', :rev => 123},
:class => 'changeset', :title => '') :class => 'changeset', :title => ''
hg_changeset_link = link_to( )
hg_changeset_link =
link_to(
'hg1|abcd', 'hg1|abcd',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, :id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'},
:class => 'changeset', :title => '') :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 =
link_to(
'ecookbook:r2', 'ecookbook:r2',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 10, :rev => 2}, :id => 'ecookbook', :repository_id => 10, :rev => 2},
:class => 'changeset', :class => 'changeset',
:title => 'This commit fixes #1, #2 and references #1 & #3') :title => 'This commit fixes #1, #2 and references #1 & #3'
svn_changeset_link = link_to( )
svn_changeset_link =
link_to(
'ecookbook:svn1|r123', 'ecookbook:svn1|r123',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 'svn1', :rev => 123}, :id => 'ecookbook', :repository_id => 'svn1', :rev => 123},
:class => 'changeset', :title => '') :class => 'changeset', :title => ''
hg_changeset_link = link_to( )
hg_changeset_link =
link_to(
'ecookbook:hg1|abcd', 'ecookbook:hg1|abcd',
{:controller => 'repositories', :action => 'revision', {:controller => 'repositories', :action => 'revision',
:id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'}, :id => 'ecookbook', :repository_id => 'hg1', :rev => 'abcd'},
:class => 'changeset', :title => '') :class => 'changeset', :title => ''
)
source_link = link_to('ecookbook:source:some/file', source_link =
link_to(
'ecookbook:source:some/file',
{:controller => 'repositories', :action => 'entry', {:controller => 'repositories', :action => 'entry',
:id => 'ecookbook', :repository_id => 10, :id => 'ecookbook', :repository_id => 10,
:path => ['some', 'file']}, :class => 'source') :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,13 +769,17 @@ 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 =
Changeset.create!(
:repository => r, :repository => r,
:committed_on => Time.now, :committed_on => Time.now,
:revision => 'abcd', :revision => 'abcd',
:scmid => 'abcd', :scmid => 'abcd',
:comments => 'test commit') :comments => 'test commit'
changeset_link = link_to('abcd', )
changeset_link =
link_to(
'abcd',
{ {
:controller => 'repositories', :controller => 'repositories',
:action => 'revision', :action => 'revision',
@ -741,7 +787,8 @@ class ApplicationHelperTest < Redmine::HelperTest
:repository_id => r.id, :repository_id => r.id,
:rev => 'abcd', :rev => 'abcd',
}, },
:class => 'changeset', :title => 'test commit') :class => 'changeset', :title => 'test commit'
)
to_test = { to_test = {
'commit:abcd' => changeset_link, 'commit:abcd' => changeset_link,
} }
@ -752,13 +799,16 @@ 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 =
Changeset.create!(
:repository => r, :repository => r,
:committed_on => Time.now, :committed_on => Time.now,
:revision => '123', :revision => '123',
:scmid => 'abcd', :scmid => 'abcd',
:comments => 'test commit') :comments => 'test commit'
changeset_link_rev = link_to( )
changeset_link_rev =
link_to(
'r123', 'r123',
{ {
:controller => 'repositories', :controller => 'repositories',
@ -767,8 +817,10 @@ class ApplicationHelperTest < Redmine::HelperTest
:repository_id => r.id, :repository_id => r.id,
:rev => '123', :rev => '123',
}, },
:class => 'changeset', :title => 'test commit') :class => 'changeset', :title => 'test commit'
changeset_link_commit = link_to( )
changeset_link_commit =
link_to(
'abcd', 'abcd',
{ {
:controller => 'repositories', :controller => 'repositories',
@ -777,7 +829,8 @@ class ApplicationHelperTest < Redmine::HelperTest
:repository_id => r.id, :repository_id => r.id,
:rev => 'abcd', :rev => 'abcd',
}, },
:class => 'changeset', :title => 'test commit') :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,
@ -1460,7 +1513,8 @@ 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 =
textilizable(
raw, raw,
:edit_section_links => :edit_section_links =>
{:controller => 'wiki', :action => 'edit', {:controller => 'wiki', :action => 'edit',