##// END OF EJS Templates
Rails4: replace hard-coded html with class at ApplicationHelperTest#test_wiki_links...
Toshi MARUYAMA -
r12602:7a594a2c3d8c
parent child
Show More
@@ -644,36 +644,86 RAW
644 644 def test_wiki_links
645 645 russian_eacape = CGI.escape(@russian_test)
646 646 to_test = {
647 '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
648 '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
647 '[[CookBook documentation]]' =>
648 link_to("CookBook documentation",
649 "/projects/ecookbook/wiki/CookBook_documentation",
650 :class => "wiki-page"),
651 '[[Another page|Page]]' =>
652 link_to("Page",
653 "/projects/ecookbook/wiki/Another_page",
654 :class => "wiki-page"),
649 655 # title content should be formatted
650 '[[Another page|With _styled_ *title*]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">With <em>styled</em> <strong>title</strong></a>',
651 '[[Another page|With title containing <strong>HTML entities &amp; markups</strong>]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">With title containing &lt;strong&gt;HTML entities &amp; markups&lt;/strong&gt;</a>',
656 '[[Another page|With _styled_ *title*]]' =>
657 link_to("With <em>styled</em> <strong>title</strong>".html_safe,
658 "/projects/ecookbook/wiki/Another_page",
659 :class => "wiki-page"),
660 '[[Another page|With title containing <strong>HTML entities &amp; markups</strong>]]' =>
661 link_to("With title containing &lt;strong&gt;HTML entities &amp; markups&lt;/strong&gt;".html_safe,
662 "/projects/ecookbook/wiki/Another_page",
663 :class => "wiki-page"),
652 664 # link with anchor
653 '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
654 '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
665 '[[CookBook documentation#One-section]]' =>
666 link_to("CookBook documentation",
667 "/projects/ecookbook/wiki/CookBook_documentation#One-section",
668 :class => "wiki-page"),
669 '[[Another page#anchor|Page]]' =>
670 link_to("Page",
671 "/projects/ecookbook/wiki/Another_page#anchor",
672 :class => "wiki-page"),
655 673 # UTF8 anchor
656 674 "[[Another_page##{@russian_test}|#{@russian_test}]]" =>
657 %|<a href="/projects/ecookbook/wiki/Another_page##{russian_eacape}" class="wiki-page">#{@russian_test}</a>|,
675 link_to(@russian_test,
676 "/projects/ecookbook/wiki/Another_page##{russian_eacape}",
677 :class => "wiki-page"),
658 678 # page that doesn't exist
659 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
660 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
679 '[[Unknown page]]' =>
680 link_to("Unknown page",
681 "/projects/ecookbook/wiki/Unknown_page",
682 :class => "wiki-page new"),
683 '[[Unknown page|404]]' =>
684 link_to("404",
685 "/projects/ecookbook/wiki/Unknown_page",
686 :class => "wiki-page new"),
661 687 # link to another project wiki
662 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">onlinestore</a>',
663 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">Wiki</a>',
664 '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>',
665 '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>',
666 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
688 '[[onlinestore:]]' =>
689 link_to("onlinestore",
690 "/projects/onlinestore/wiki",
691 :class => "wiki-page"),
692 '[[onlinestore:|Wiki]]' =>
693 link_to("Wiki",
694 "/projects/onlinestore/wiki",
695 :class => "wiki-page"),
696 '[[onlinestore:Start page]]' =>
697 link_to("Start page",
698 "/projects/onlinestore/wiki/Start_page",
699 :class => "wiki-page"),
700 '[[onlinestore:Start page|Text]]' =>
701 link_to("Text",
702 "/projects/onlinestore/wiki/Start_page",
703 :class => "wiki-page"),
704 '[[onlinestore:Unknown page]]' =>
705 link_to("Unknown page",
706 "/projects/onlinestore/wiki/Unknown_page",
707 :class => "wiki-page new"),
667 708 # striked through link
668 '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>',
669 '-[[Another page|Page]] link-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a> link</del>',
709 '-[[Another page|Page]]-' =>
710 "<del>".html_safe +
711 link_to("Page",
712 "/projects/ecookbook/wiki/Another_page",
713 :class => "wiki-page").html_safe +
714 "</del>".html_safe,
715 '-[[Another page|Page]] link-' =>
716 "<del>".html_safe +
717 link_to("Page",
718 "/projects/ecookbook/wiki/Another_page",
719 :class => "wiki-page").html_safe +
720 " link</del>".html_safe,
670 721 # escaping
671 722 '![[Another page|Page]]' => '[[Another page|Page]]',
672 723 # project does not exist
673 724 '[[unknowproject:Start]]' => '[[unknowproject:Start]]',
674 725 '[[unknowproject:Start|Page title]]' => '[[unknowproject:Start|Page title]]',
675 726 }
676
677 727 @project = Project.find(1)
678 728 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
679 729 end
General Comments 0
You need to be logged in to leave comments. Login now