Mercurial > hg > soundsoftware-site
diff test/unit/helpers/application_helper_test.rb @ 931:ec1c49528f36 cannam_integration
Merge from branch "redmine-1.3"
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 15:04:58 +0100 |
parents | 5e80956cc792 5f33065ddc4b |
children | bb32da3bea34 |
line wrap: on
line diff
--- a/test/unit/helpers/application_helper_test.rb Wed Jun 27 14:56:14 2012 +0100 +++ b/test/unit/helpers/application_helper_test.rb Wed Jun 27 15:04:58 2012 +0100 @@ -732,6 +732,8 @@ h3. Subtitle with *some* _modifiers_ +h3. Subtitle with @inline code@ + h1. Another title h3. An "Internet link":http://www.redmine.org/ inside subtitle @@ -748,6 +750,7 @@ '<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' + '<ul>' + '<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' + + '<li><a href="#Subtitle-with-inline-code">Subtitle with inline code</a></li>' + '</ul>' + '</li>' + '</ul>' + @@ -768,6 +771,33 @@ assert textilizable(raw).gsub("\n", "").include?(expected) end + def test_table_of_content_should_generate_unique_anchors + raw = <<-RAW +{{toc}} + +h1. Title + +h2. Subtitle + +h2. Subtitle +RAW + + expected = '<ul class="toc">' + + '<li><a href="#Title">Title</a>' + + '<ul>' + + '<li><a href="#Subtitle">Subtitle</a></li>' + + '<li><a href="#Subtitle-2">Subtitle</a></li>' + '</ul>' + '</li>' + + '</ul>' + + @project = Project.find(1) + result = textilizable(raw).gsub("\n", "") + assert_include expected, result + assert_include '<a name="Subtitle">', result + assert_include '<a name="Subtitle-2">', result + end + def test_table_of_content_should_contain_included_page_headings raw = <<-RAW {{toc}} @@ -786,6 +816,48 @@ assert textilizable(raw).gsub("\n", "").include?(expected) end + def test_section_edit_links + raw = <<-RAW +h1. Title + +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. + +h2. Subtitle with a [[Wiki]] link + +h2. Subtitle with *some* _modifiers_ + +h2. Subtitle with @inline code@ + +<pre> +some code + +h2. heading inside pre + +<h2>html heading inside pre</h2> +</pre> + +h2. Subtitle after pre tag +RAW + + @project = Project.find(1) + set_language_if_valid 'en' + result = textilizable(raw, :edit_section_links => {:controller => 'wiki', :action => 'edit', :project_id => '1', :id => 'Test'}).gsub("\n", "") + + # heading that contains inline code + assert_match Regexp.new('<div class="contextual" title="Edit this section">' + + '<a href="/projects/1/wiki/Test/edit\?section=4"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' + + '<a name="Subtitle-with-inline-code"></a>' + + '<h2 >Subtitle with <code>inline code</code><a href="#Subtitle-with-inline-code" class="wiki-anchor">¶</a></h2>'), + result + + # last heading + assert_match Regexp.new('<div class="contextual" title="Edit this section">' + + '<a href="/projects/1/wiki/Test/edit\?section=5"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' + + '<a name="Subtitle-after-pre-tag"></a>' + + '<h2 >Subtitle after pre tag<a href="#Subtitle-after-pre-tag" class="wiki-anchor">¶</a></h2>'), + result + end + def test_default_formatter Setting.text_formatting = 'unknown' text = 'a *link*: http://www.example.net/' @@ -853,6 +925,14 @@ link_to_project(project, {:action => 'settings'}, :class => "project") end + def test_link_to_legacy_project_with_numerical_identifier_should_use_id + # numeric identifier are no longer allowed + Project.update_all "identifier=25", "id=1" + + assert_equal '<a href="/projects/1">eCookbook</a>', + link_to_project(Project.find(1)) + end + def test_principals_options_for_select_with_users users = [User.find(2), User.find(4)] assert_equal %(<option value="2">John Smith</option><option value="4">Robert Hill</option>),