##// END OF EJS Templates
Rails4: replace hard-coded html with class at ApplicationHelperTest#test_wiki_links_within_wiki_page_context...
Toshi MARUYAMA -
r12568:3817f1e30455
parent child
Show More
@@ -714,30 +714,64 RAW
714 end
714 end
715
715
716 def test_wiki_links_within_wiki_page_context
716 def test_wiki_links_within_wiki_page_context
717
718 page = WikiPage.find_by_title('Another_page' )
717 page = WikiPage.find_by_title('Another_page' )
719
720 to_test = {
718 to_test = {
721 # link to another page
719 '[[CookBook documentation]]' =>
722 '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
720 link_to("CookBook documentation",
723 '[[CookBook documentation|documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">documentation</a>',
721 "/projects/ecookbook/wiki/CookBook_documentation",
724 '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
722 :class => "wiki-page"),
725 '[[CookBook documentation#One-section|documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">documentation</a>',
723 '[[CookBook documentation|documentation]]' =>
724 link_to("documentation",
725 "/projects/ecookbook/wiki/CookBook_documentation",
726 :class => "wiki-page"),
727 '[[CookBook documentation#One-section]]' =>
728 link_to("CookBook documentation",
729 "/projects/ecookbook/wiki/CookBook_documentation#One-section",
730 :class => "wiki-page"),
731 '[[CookBook documentation#One-section|documentation]]' =>
732 link_to("documentation",
733 "/projects/ecookbook/wiki/CookBook_documentation#One-section",
734 :class => "wiki-page"),
726 # link to the current page
735 # link to the current page
727 '[[Another page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Another page</a>',
736 '[[Another page]]' =>
728 '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
737 link_to("Another page",
729 '[[Another page#anchor]]' => '<a href="#anchor" class="wiki-page">Another page</a>',
738 "/projects/ecookbook/wiki/Another_page",
730 '[[Another page#anchor|Page]]' => '<a href="#anchor" class="wiki-page">Page</a>',
739 :class => "wiki-page"),
740 '[[Another page|Page]]' =>
741 link_to("Page",
742 "/projects/ecookbook/wiki/Another_page",
743 :class => "wiki-page"),
744 '[[Another page#anchor]]' =>
745 link_to("Another page",
746 "#anchor",
747 :class => "wiki-page"),
748 '[[Another page#anchor|Page]]' =>
749 link_to("Page",
750 "#anchor",
751 :class => "wiki-page"),
731 # page that doesn't exist
752 # page that doesn't exist
732 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page?parent=Another_page" class="wiki-page new">Unknown page</a>',
753 '[[Unknown page]]' =>
733 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page?parent=Another_page" class="wiki-page new">404</a>',
754 link_to("Unknown page",
734 '[[Unknown page#anchor]]' => '<a href="/projects/ecookbook/wiki/Unknown_page?parent=Another_page#anchor" class="wiki-page new">Unknown page</a>',
755 "/projects/ecookbook/wiki/Unknown_page?parent=Another_page",
735 '[[Unknown page#anchor|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page?parent=Another_page#anchor" class="wiki-page new">404</a>',
756 :class => "wiki-page new"),
757 '[[Unknown page|404]]' =>
758 link_to("404",
759 "/projects/ecookbook/wiki/Unknown_page?parent=Another_page",
760 :class => "wiki-page new"),
761 '[[Unknown page#anchor]]' =>
762 link_to("Unknown page",
763 "/projects/ecookbook/wiki/Unknown_page?parent=Another_page#anchor",
764 :class => "wiki-page new"),
765 '[[Unknown page#anchor|404]]' =>
766 link_to("404",
767 "/projects/ecookbook/wiki/Unknown_page?parent=Another_page#anchor",
768 :class => "wiki-page new"),
736 }
769 }
737
738 @project = Project.find(1)
770 @project = Project.find(1)
739
771 to_test.each do |text, result|
740 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(WikiContent.new( :text => text, :page => page ), :text) }
772 assert_equal "<p>#{result}</p>",
773 textilizable(WikiContent.new( :text => text, :page => page ), :text)
774 end
741 end
775 end
742
776
743 def test_wiki_links_anchor_option_should_prepend_page_title_to_href
777 def test_wiki_links_anchor_option_should_prepend_page_title_to_href
General Comments 0
You need to be logged in to leave comments. Login now