Project

General

Profile

Defect #22967 » tests_for_special_characters_breaks_wiki_links.patch

Marius BĂLTEANU, 2018-03-31 14:58

View differences:

test/helpers/application_helper_test.rb
750 750
    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
751 751
  end
752 752

  
753
  def test_wiki_links_with_special_characters_should_work_in_textile
754
    to_test = wiki_links_with_special_characters
755

  
756
    @project = Project.find(1)
757
    with_settings :text_formatting => 'textile' do
758
      to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
759
    end
760
  end
761

  
762
  def test_wiki_links_with_special_characters_should_work_in_markdown
763
    to_test = wiki_links_with_special_characters
764

  
765
    @project = Project.find(1)
766
    with_settings :text_formatting => 'markdown' do
767
      to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text).strip }
768
    end
769
  end
770

  
771

  
753 772
  def test_wiki_links_within_local_file_generation_context
754 773
    to_test = {
755 774
      # link to a page
......
1568 1587
    assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">:45</span>', html_hours('0:45')
1569 1588
    assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">.75</span>', html_hours('0.75')
1570 1589
  end
1590

  
1591
  private
1592

  
1593
  def wiki_links_with_special_characters
1594
    return {
1595
      '[[Jack & Coke]]' =>
1596
          link_to("Jack & Coke",
1597
                  "/projects/ecookbook/wiki/Jack_&_Coke",
1598
                  :class => "wiki-page new"),
1599
      '[[a "quoted" name]]' =>
1600
          link_to("a \"quoted\" name",
1601
                  "/projects/ecookbook/wiki/A_%22quoted%22_name",
1602
                  :class => "wiki-page new"),
1603
      '[[le français, c\'est super]]' =>
1604
          link_to("le français, c\'est super",
1605
                  "/projects/ecookbook/wiki/Le_fran%C3%A7ais_c'est_super",
1606
                  :class => "wiki-page new"),
1607
      '[[broken < less]]' =>
1608
          link_to("broken < less",
1609
                  "/projects/ecookbook/wiki/Broken_%3C_less",
1610
                  :class => "wiki-page new"),
1611
      '[[broken > more]]' =>
1612
          link_to("broken > more",
1613
                  "/projects/ecookbook/wiki/Broken_%3E_more",
1614
                  :class => "wiki-page new"),
1615
    }
1616
  end
1571 1617
end
(4-4/6)