Project

General

Profile

Feature #34863 » 0003-Change-the-text-formatting-of-fixtures-to-Markdown.patch

Go MAEDA, 2021-03-16 10:35

View differences:

test/fixtures/journals.yml
15 15
  journalized_id: 1
16 16
journals_003:
17 17
  created_on: <%= 1.days.ago.to_date.to_s(:db) %>
18
  notes: "A comment with inline image: !picture.jpg! and a reference to #1 and r2."
18
  notes: "A comment with inline image: ![](picture.jpg) and a reference to #1 and r2."
19 19
  id: 3
20 20
  journalized_type: Issue
21 21
  user_id: 2
test/fixtures/wiki_content_versions.yml
9 9
  wiki_content_id: 1
10 10
  compression: ""
11 11
  data: |-
12
    h1. CookBook documentation v1
12
    # CookBook documentation v1
13 13

  
14 14
    
15 15
    Line from v1
......
24 24
  wiki_content_id: 1
25 25
  compression: ""
26 26
  data: |-
27
    h1. CookBook documentation v2
27
    # CookBook documentation v2
28 28

  
29 29
    
30 30
    Line from v1
......
39 39
  wiki_content_id: 1
40 40
  compression: ""
41 41
  data: |-
42
    h1. CookBook documentation v3
42
    # CookBook documentation v3
43 43

  
44 44
    Some updated [[documentation]] here...
45 45
wiki_content_versions_004: 
46 46
  data: |-
47
    h1. Another page
47
    # Another page
48 48
    
49 49
    This is a link to a ticket: #2
50 50
  updated_on: 2007-03-08 00:18:07 +01:00
......
56 56
  comments: 
57 57
wiki_content_versions_005: 
58 58
  data: |-
59
    h1. Title
59
    # Title
60 60
    
61 61
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
62 62
    
63
    h2. Heading 1
63
    ## Heading 1
64 64
    
65
    @WHATEVER@
65
    `WHATEVER`
66 66
    
67 67
    Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
68 68

  
......
80 80
  comments: 
81 81
wiki_content_versions_006: 
82 82
  data: |-
83
    h1. Title
83
    # Title
84 84
    
85 85
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
86 86
    
87
    h2. Heading 1
87
    ## Heading 1
88 88
    
89 89
    @WHATEVER@
90 90
    
91 91
    Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
92 92
    
93
    h2. Heading 2
93
    ## Heading 2
94 94

  
95 95
    Morbi facilisis accumsan orci non pharetra.
96 96
  updated_on: 2007-03-08 00:18:07 +01:00
......
102 102
  comments: 
103 103
wiki_content_versions_007: 
104 104
  data: |-
105
    h1. Page with an inline image
105
    # Page with an inline image
106 106
    
107 107
    This is an inline image:
108 108
    
109
    !logo.gif!
109
    ![](logo.gif)
110 110
  updated_on: 2007-03-08 00:18:07 +01:00
111 111
  page_id: 4
112 112
  wiki_content_id: 4
test/fixtures/wiki_contents.yml
1 1
--- 
2 2
wiki_contents_001: 
3 3
  text: |-
4
    h1. CookBook documentation
4
    # CookBook documentation
5 5

  
6 6
    {{child_pages}}
7 7

  
......
14 14
  comments: Gzip compression activated
15 15
wiki_contents_002: 
16 16
  text: |-
17
    h1. Another page
17
    # Another page
18 18
    
19 19
    This is a link to a ticket: #2
20 20
    And this is an included page:
......
27 27
  comments: 
28 28
wiki_contents_003: 
29 29
  text: |-
30
    h1. Start page
30
    # Start page
31 31
    
32 32
    E-commerce web site start page
33 33
  updated_on: 2007-03-08 00:18:07 +01:00
......
38 38
  comments: 
39 39
wiki_contents_004: 
40 40
  text: |-
41
    h1. Page with an inline image
41
    # Page with an inline image
42 42
    
43 43
    This is an inline image:
44 44
    
45
    !logo.gif!
45
    ![](logo.gif)
46 46
  updated_on: 2007-03-08 00:18:07 +01:00
47 47
  page_id: 4
48 48
  id: 4
......
51 51
  comments: 
52 52
wiki_contents_005: 
53 53
  text: |-
54
    h1. Child page 1
54
    # Child page 1
55 55
    
56 56
    This is a child page
57 57
  updated_on: 2007-03-08 00:18:07 +01:00
......
62 62
  comments: 
63 63
wiki_contents_006: 
64 64
  text: |-
65
    h1. Child page 2
65
    # Child page 2
66 66
    
67 67
    This is a child page
68 68
  updated_on: 2007-03-08 00:18:07 +01:00
......
105 105
  comments: 
106 106
wiki_contents_011: 
107 107
  text: |-
108
    h1. Title
108
    # Title
109 109
    
110 110
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
111 111
    
112
    h2. Heading 1
112
    ## Heading 1
113 113
    
114
    @WHATEVER@
114
    `WHATEVER`
115 115
    
116 116
    Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
117 117

  
118 118
    Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc.
119 119
    
120
    h2. Heading 2
120
    ## Heading 2
121 121

  
122 122
    Morbi facilisis accumsan orci non pharetra.
123 123
  updated_on: 2007-03-08 00:18:07 +01:00
test/functional/issues_controller_test.rb
1701 1701
  end
1702 1702

  
1703 1703
  def test_index_with_last_notes_column
1704
    with_settings :text_formatting => 'textile' do
1704
    with_settings :text_formatting => 'markdown' do
1705 1705
      get(
1706 1706
        :index,
1707 1707
        :params => {
......
2862 2862
  end
2863 2863

  
2864 2864
  def test_show_atom
2865
    with_settings :text_formatting => 'textile' do
2865
    with_settings :text_formatting => 'markdown' do
2866 2866
      get(
2867 2867
        :show,
2868 2868
        :params => {
test/functional/wiki_controller_test.rb
30 30
  end
31 31

  
32 32
  def test_show_start_page
33
    with_settings :text_formatting => 'textile' do
33
    with_settings :text_formatting => 'markdown' do
34 34
      get :show, :params => {:project_id => 'ecookbook'}
35 35
      assert_response :success
36 36

  
......
49 49
  end
50 50

  
51 51
  def test_show_page_with_name
52
    with_settings :text_formatting => 'textile' do
52
    with_settings :text_formatting => 'markdown' do
53 53
      get :show, :params => {:project_id => 1, :id => 'Another_page'}
54 54
      assert_response :success
55 55

  
......
118 118
  end
119 119

  
120 120
  def test_show_should_display_section_edit_links
121
    with_settings :text_formatting => 'textile' do
121
    with_settings :text_formatting => 'markdown' do
122 122
      @request.session[:user_id] = 2
123 123
      get :show, :params => {:project_id => 1, :id => 'Page with sections'}
124 124

  
......
129 129
  end
130 130

  
131 131
  def test_show_current_version_should_display_section_edit_links
132
    with_settings :text_formatting => 'textile' do
132
    with_settings :text_formatting => 'markdown' do
133 133
      @request.session[:user_id] = 2
134 134
      get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 3}
135 135

  
......
328 328
  end
329 329

  
330 330
  def test_edit_section
331
    with_settings :text_formatting => 'textile' do
331
    with_settings :text_formatting => 'markdown' do
332 332
      @request.session[:user_id] = 2
333 333
      get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2}
334 334

  
335 335
      assert_response :success
336 336

  
337 337
      page = WikiPage.find_by_title('Page_with_sections')
338
      section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
338
      section, hash = Redmine::WikiFormatting::Markdown::Formatter.new(page.content.text).get_section(2)
339 339

  
340 340
      assert_select 'textarea[name=?]', 'content[text]', :text => section
341 341
      assert_select 'input[name=section][type=hidden][value="2"]'
......
566 566
  end
567 567

  
568 568
  def test_update_section
569
    with_settings :text_formatting => 'textile' do
569
    with_settings :text_formatting => 'markdown' do
570 570
      @request.session[:user_id] = 2
571 571
      page = WikiPage.find_by(title: 'Page_with_sections')
572
      section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
572
      section, hash = Redmine::WikiFormatting::Markdown::Formatter.new(page.content.text).get_section(2)
573 573
      text = page.content.text
574 574

  
575 575
      assert_no_difference 'WikiPage.count' do
......
589 589
        end
590 590
      end
591 591
      assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
592
      assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, 'New section content'), page.reload.content.text
592
      assert_equal Redmine::WikiFormatting::Markdown::Formatter.new(text).update_section(2, 'New section content'), page.reload.content.text
593 593
    end
594 594
  end
595 595

  
596 596
  def test_update_section_should_allow_stale_page_update
597
    with_settings :text_formatting => 'textile' do
597
    with_settings :text_formatting => 'markdown' do
598 598
      @request.session[:user_id] = 2
599 599
      page = WikiPage.find_by(title: 'Page_with_sections')
600
      section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
600
      section, hash = Redmine::WikiFormatting::Markdown::Formatter.new(page.content.text).get_section(2)
601 601
      text = page.content.text
602 602

  
603 603
      assert_no_difference 'WikiPage.count' do
......
618 618
      end
619 619
      assert_redirected_to '/projects/ecookbook/wiki/Page_with_sections#section-2'
620 620
      page.reload
621
      assert_equal Redmine::WikiFormatting::Textile::Formatter.new(text).update_section(2, 'New section content'), page.content.text
621
      assert_equal Redmine::WikiFormatting::Markdown::Formatter.new(text).update_section(2, 'New section content'), page.content.text
622 622
      assert_equal 4, page.content.version
623 623
    end
624 624
  end
......
764 764
    assert_select 'table.annotate tr:nth-child(1)' do
765 765
      assert_select 'th.line-num', :text => '1'
766 766
      assert_select 'td.author', :text => /Redmine Admin/
767
      assert_select 'td', :text => /h1\. CookBook documentation v2/
767
      assert_select 'td', :text => /# CookBook documentation v2/
768 768
    end
769 769

  
770 770
    # Line 2
......
1119 1119
  end
1120 1120

  
1121 1121
  def test_show_html
1122
    with_settings :text_formatting => 'textile' do
1122
    with_settings :text_formatting => 'markdown' do
1123 1123
      @request.session[:user_id] = 2
1124 1124
      get :show, :params => {:project_id => 1, :format => 'html'}
1125 1125
      assert_response :success
......
1132 1132
  end
1133 1133

  
1134 1134
  def test_show_versioned_html
1135
    with_settings :text_formatting => 'textile' do
1135
    with_settings :text_formatting => 'markdown' do
1136 1136
      @request.session[:user_id] = 2
1137 1137
      get :show, :params => {:project_id => 1, :format => 'html', :version => 2}
1138 1138
      assert_response :success
......
1152 1152
    assert_equal 'text/plain', @response.media_type
1153 1153
    assert_equal 'attachment; filename="CookBook_documentation.txt"',
1154 1154
                 @response.headers['Content-Disposition']
1155
    assert_include 'h1. CookBook documentation', @response.body
1155
    assert_include '# CookBook documentation', @response.body
1156 1156
  end
1157 1157

  
1158 1158
  def test_show_versioned_txt
......
1163 1163
    assert_equal 'text/plain', @response.media_type
1164 1164
    assert_equal 'attachment; filename="CookBook_documentation.txt"',
1165 1165
                 @response.headers['Content-Disposition']
1166
    assert_include 'h1. CookBook documentation v2', @response.body
1166
    assert_include '# CookBook documentation v2', @response.body
1167 1167
  end
1168 1168

  
1169 1169
  def test_show_filename_should_be_uri_encoded_for_ms_browsers
test/helpers/application_helper_test.rb
1591 1591
    raw = <<~RAW
1592 1592
      {{toc}}
1593 1593

  
1594
      h1. Included
1594
      # Included
1595 1595

  
1596 1596
      {{include(Child_1)}}
1597 1597
    RAW
......
1601 1601
               '<li><a href="#Child-page-1">Child page 1</a></li>' +
1602 1602
               '</ul>'
1603 1603
    @project = Project.find(1)
1604
    with_settings :text_formatting => 'textile' do
1604
    with_settings :text_formatting => 'markdown' do
1605 1605
      assert textilizable(raw).delete("\n").include?(expected)
1606 1606
    end
1607 1607
  end
(3-3/7)