Mercurial > hg > soundsoftware-site
diff test/unit/helpers/application_helper_test.rb @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | cd2282d2aa55 0579821a129a |
line wrap: on
line diff
--- a/test/unit/helpers/application_helper_test.rb Fri Nov 19 14:05:24 2010 +0000 +++ b/test/unit/helpers/application_helper_test.rb Thu Jan 13 14:12:06 2011 +0000 @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require File.dirname(__FILE__) + '/../../test_helper' +require File.expand_path('../../../test_helper', __FILE__) class ApplicationHelperTest < ActionView::TestCase @@ -147,7 +147,7 @@ } to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } end - + def test_redmine_links issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, :class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)') @@ -224,7 +224,89 @@ @project = Project.find(1) to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" } end - + + def test_redmine_links_git_commit + changeset_link = link_to('abcd', + { + :controller => 'repositories', + :action => 'revision', + :id => 'subproject1', + :rev => 'abcd', + }, + :class => 'changeset', :title => 'test commit') + to_test = { + 'commit:abcd' => changeset_link, + } + @project = Project.find(3) + r = Repository::Git.create!(:project => @project, :url => '/tmp/test/git') + assert r + c = Changeset.new(:repository => r, + :committed_on => Time.now, + :revision => 'abcd', + :scmid => 'abcd', + :comments => 'test commit') + assert( c.save ) + to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } + end + + # TODO: Bazaar commit id contains mail address, so it contains '@' and '_'. + def test_redmine_links_darcs_commit + changeset_link = link_to('20080308225258-98289-abcd456efg.gz', + { + :controller => 'repositories', + :action => 'revision', + :id => 'subproject1', + :rev => '123', + }, + :class => 'changeset', :title => 'test commit') + to_test = { + 'commit:20080308225258-98289-abcd456efg.gz' => changeset_link, + } + @project = Project.find(3) + r = Repository::Darcs.create!(:project => @project, :url => '/tmp/test/darcs') + assert r + c = Changeset.new(:repository => r, + :committed_on => Time.now, + :revision => '123', + :scmid => '20080308225258-98289-abcd456efg.gz', + :comments => 'test commit') + assert( c.save ) + to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } + end + + def test_redmine_links_mercurial_commit + changeset_link_rev = link_to('r123', + { + :controller => 'repositories', + :action => 'revision', + :id => 'subproject1', + :rev => '123' , + }, + :class => 'changeset', :title => 'test commit') + changeset_link_commit = link_to('abcd', + { + :controller => 'repositories', + :action => 'revision', + :id => 'subproject1', + :rev => 'abcd' , + }, + :class => 'changeset', :title => 'test commit') + to_test = { + 'r123' => changeset_link_rev, + 'commit:abcd' => changeset_link_commit, + } + @project = Project.find(3) + r = Repository::Mercurial.create!(:project => @project, :url => '/tmp/test') + assert r + c = Changeset.new(:repository => r, + :committed_on => Time.now, + :revision => '123', + :scmid => 'abcd', + :comments => 'test commit') + assert( c.save ) + to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } + end + def test_attachment_links attachment_link = link_to('error281.txt', {:controller => 'attachments', :action => 'download', :id => '1'}, :class => 'attachment') to_test = { @@ -275,7 +357,13 @@ "<!-- opening comment" => "<p><!-- opening comment</p>", # remove attributes except class "<pre class='foo'>some text</pre>" => "<pre class='foo'>some text</pre>", + '<pre class="foo">some text</pre>' => '<pre class="foo">some text</pre>', + "<pre class='foo bar'>some text</pre>" => "<pre class='foo bar'>some text</pre>", + '<pre class="foo bar">some text</pre>' => '<pre class="foo bar">some text</pre>', "<pre onmouseover='alert(1)'>some text</pre>" => "<pre>some text</pre>", + # xss + '<pre><code class=""onmouseover="alert(1)">text</code></pre>' => '<pre><code>text</code></pre>', + '<pre class=""onmouseover="alert(1)">text</pre>' => '<pre>text</pre>', } to_test.each { |text, result| assert_equal result, textilizable(text) } end @@ -422,7 +510,11 @@ h2. Subtitle with [[Wiki|another Wiki]] link h2. Subtitle with %{color:red}red text% - + +<pre> +some code +</pre> + h3. Subtitle with *some* _modifiers_ h1. Another title @@ -458,7 +550,7 @@ '</ul>' @project = Project.find(1) - assert textilizable(raw).gsub("\n", "").include?(expected) + assert textilizable(raw).gsub("\n", "").include?(expected), textilizable(raw) end def test_table_of_content_should_contain_included_page_headings @@ -600,6 +692,7 @@ Date.today - 100 => 'about 3 months late', Date.today - 20000 => 'over 54 years late', } + ::I18n.locale = :en to_test.each do |date, expected| assert_equal expected, due_date_distance_in_words(date) end