comparison test/unit/helpers/application_helper_test.rb @ 929:5f33065ddc4b redmine-1.3

Update to Redmine SVN rev 9414 on 1.3-stable branch
author Chris Cannam
date Wed, 27 Jun 2012 14:54:18 +0100
parents cbb26bc654de
children ec1c49528f36 433d4f72a19b
comparison
equal deleted inserted replaced
909:cbb26bc654de 929:5f33065ddc4b
730 some code 730 some code
731 </pre> 731 </pre>
732 732
733 h3. Subtitle with *some* _modifiers_ 733 h3. Subtitle with *some* _modifiers_
734 734
735 h3. Subtitle with @inline code@
736
735 h1. Another title 737 h1. Another title
736 738
737 h3. An "Internet link":http://www.redmine.org/ inside subtitle 739 h3. An "Internet link":http://www.redmine.org/ inside subtitle
738 740
739 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues 741 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
746 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' + 748 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
747 '<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' + 749 '<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
748 '<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' + 750 '<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' +
749 '<ul>' + 751 '<ul>' +
750 '<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' + 752 '<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' +
753 '<li><a href="#Subtitle-with-inline-code">Subtitle with inline code</a></li>' +
751 '</ul>' + 754 '</ul>' +
752 '</li>' + 755 '</li>' +
753 '</ul>' + 756 '</ul>' +
754 '</li>' + 757 '</li>' +
755 '<li><a href="#Another-title">Another title</a>' + 758 '<li><a href="#Another-title">Another title</a>' +
766 769
767 @project = Project.find(1) 770 @project = Project.find(1)
768 assert textilizable(raw).gsub("\n", "").include?(expected) 771 assert textilizable(raw).gsub("\n", "").include?(expected)
769 end 772 end
770 773
774 def test_table_of_content_should_generate_unique_anchors
775 raw = <<-RAW
776 {{toc}}
777
778 h1. Title
779
780 h2. Subtitle
781
782 h2. Subtitle
783 RAW
784
785 expected = '<ul class="toc">' +
786 '<li><a href="#Title">Title</a>' +
787 '<ul>' +
788 '<li><a href="#Subtitle">Subtitle</a></li>' +
789 '<li><a href="#Subtitle-2">Subtitle</a></li>'
790 '</ul>'
791 '</li>' +
792 '</ul>'
793
794 @project = Project.find(1)
795 result = textilizable(raw).gsub("\n", "")
796 assert_include expected, result
797 assert_include '<a name="Subtitle">', result
798 assert_include '<a name="Subtitle-2">', result
799 end
800
771 def test_table_of_content_should_contain_included_page_headings 801 def test_table_of_content_should_contain_included_page_headings
772 raw = <<-RAW 802 raw = <<-RAW
773 {{toc}} 803 {{toc}}
774 804
775 h1. Included 805 h1. Included
782 '<li><a href="#Child-page-1">Child page 1</a></li>' + 812 '<li><a href="#Child-page-1">Child page 1</a></li>' +
783 '</ul>' 813 '</ul>'
784 814
785 @project = Project.find(1) 815 @project = Project.find(1)
786 assert textilizable(raw).gsub("\n", "").include?(expected) 816 assert textilizable(raw).gsub("\n", "").include?(expected)
817 end
818
819 def test_section_edit_links
820 raw = <<-RAW
821 h1. Title
822
823 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
824
825 h2. Subtitle with a [[Wiki]] link
826
827 h2. Subtitle with *some* _modifiers_
828
829 h2. Subtitle with @inline code@
830
831 <pre>
832 some code
833
834 h2. heading inside pre
835
836 <h2>html heading inside pre</h2>
837 </pre>
838
839 h2. Subtitle after pre tag
840 RAW
841
842 @project = Project.find(1)
843 set_language_if_valid 'en'
844 result = textilizable(raw, :edit_section_links => {:controller => 'wiki', :action => 'edit', :project_id => '1', :id => 'Test'}).gsub("\n", "")
845
846 # heading that contains inline code
847 assert_match Regexp.new('<div class="contextual" title="Edit this section">' +
848 '<a href="/projects/1/wiki/Test/edit\?section=4"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
849 '<a name="Subtitle-with-inline-code"></a>' +
850 '<h2 >Subtitle with <code>inline code</code><a href="#Subtitle-with-inline-code" class="wiki-anchor">&para;</a></h2>'),
851 result
852
853 # last heading
854 assert_match Regexp.new('<div class="contextual" title="Edit this section">' +
855 '<a href="/projects/1/wiki/Test/edit\?section=5"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' +
856 '<a name="Subtitle-after-pre-tag"></a>' +
857 '<h2 >Subtitle after pre tag<a href="#Subtitle-after-pre-tag" class="wiki-anchor">&para;</a></h2>'),
858 result
787 end 859 end
788 860
789 def test_default_formatter 861 def test_default_formatter
790 Setting.text_formatting = 'unknown' 862 Setting.text_formatting = 'unknown'
791 text = 'a *link*: http://www.example.net/' 863 text = 'a *link*: http://www.example.net/'
851 link_to_project(project, {:only_path => false, :jump => 'blah'}) 923 link_to_project(project, {:only_path => false, :jump => 'blah'})
852 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>), 924 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>),
853 link_to_project(project, {:action => 'settings'}, :class => "project") 925 link_to_project(project, {:action => 'settings'}, :class => "project")
854 end 926 end
855 927
928 def test_link_to_legacy_project_with_numerical_identifier_should_use_id
929 # numeric identifier are no longer allowed
930 Project.update_all "identifier=25", "id=1"
931
932 assert_equal '<a href="/projects/1">eCookbook</a>',
933 link_to_project(Project.find(1))
934 end
935
856 def test_principals_options_for_select_with_users 936 def test_principals_options_for_select_with_users
857 users = [User.find(2), User.find(4)] 937 users = [User.find(2), User.find(4)]
858 assert_equal %(<option value="2">John Smith</option><option value="4">Robert Hill</option>), 938 assert_equal %(<option value="2">John Smith</option><option value="4">Robert Hill</option>),
859 principals_options_for_select(users) 939 principals_options_for_select(users)
860 end 940 end