0008-Rails-6.1-add-header-present-to-csv-tests-29914-3292.patch

Marius BALTEANU, 2021-03-30 18:41

Download (10.7 KB)

View differences:

test/functional/issues_controller_test.rb
843 843
    get(:index, :params => {:format => 'csv'})
844 844
    assert_response :success
845 845

  
846
    assert_equal 'text/csv', @response.media_type
846
    assert_equal 'text/csv; header=present', @response.media_type
847 847
    assert response.body.starts_with?("#,")
848 848
    lines = response.body.chomp.split("\n")
849 849
    # default columns + id and project
......
859 859
      }
860 860
    )
861 861
    assert_response :success
862
    assert_equal 'text/csv', @response.media_type
862
    assert_equal 'text/csv; header=present', @response.media_type
863 863
  end
864 864

  
865 865
  def test_index_csv_without_any_filters
......
894 894
      )
895 895
      assert_response :success
896 896
    end
897
    assert_equal 'text/csv', response.media_type
897
    assert_equal 'text/csv; header=present', response.media_type
898 898
    headers = response.body.chomp.split("\n").first.split(',')
899 899
    assert_include 'Description', headers
900 900
    assert_include 'test_index_csv_with_description', response.body
......
922 922
      }
923 923
    )
924 924
    assert_response :success
925
    assert_equal 'text/csv', @response.media_type
925
    assert_equal 'text/csv; header=present', @response.media_type
926 926
    lines = @response.body.chomp.split("\n")
927 927
    assert_include "#{issue.id},#{issue.subject},7.33", lines
928 928
  end
......
937 937
    )
938 938
    assert_response :success
939 939

  
940
    assert_equal 'text/csv', @response.media_type
940
    assert_equal 'text/csv; header=present', @response.media_type
941 941
    assert_match /\A#,/, response.body
942 942
    lines = response.body.chomp.split("\n")
943 943
    assert_equal IssueQuery.new.available_inline_columns.size, lines[0].split(',').size
......
1035 1035
          :format => 'csv'
1036 1036
        }
1037 1037
      )
1038
      assert_equal 'text/csv', @response.media_type
1038
      assert_equal 'text/csv; header=present', @response.media_type
1039 1039
      lines = @response.body.chomp.split("\n")
1040 1040
      header = lines[0]
1041 1041
      status = (+"\xaa\xac\xbaA").force_encoding('Big5')
......
1058 1058
          :set_filter => 1
1059 1059
        }
1060 1060
      )
1061
      assert_equal 'text/csv', @response.media_type
1061
      assert_equal 'text/csv; header=present', @response.media_type
1062 1062
      lines = @response.body.chomp.split("\n")
1063 1063
      header = lines[0]
1064 1064
      issue_line = lines.find {|l| l =~ /^#{issue.id},/}
......
1084 1084
          :set_filter => 1
1085 1085
        }
1086 1086
      )
1087
      assert_equal 'text/csv', @response.media_type
1087
      assert_equal 'text/csv; header=present', @response.media_type
1088 1088
      lines = @response.body.chomp.split("\n")
1089 1089
      assert_include "#{issue.id},1234.50,#{str1}", lines
1090 1090
    end
......
1104 1104
          :set_filter => 1
1105 1105
        }
1106 1106
      )
1107
      assert_equal 'text/csv', @response.media_type
1107
      assert_equal 'text/csv; header=present', @response.media_type
1108 1108
      lines = @response.body.chomp.split("\n")
1109 1109
      assert_include "#{issue.id};1234,50;#{str1}", lines
1110 1110
    end
......
1659 1659
      }
1660 1660
    )
1661 1661
    assert_response :success
1662
    assert_equal 'text/csv', response.media_type
1662
    assert_equal 'text/csv; header=present', response.media_type
1663 1663
    lines = response.body.chomp.split("\n")
1664 1664
    assert_include '1,"Related to #7, Related to #8, Blocks #11"', lines
1665 1665
    assert_include '2,Blocked by #12', lines
test/functional/projects_controller_test.rb
203 203
    with_settings :date_format => '%m/%d/%Y' do
204 204
      get :index, :params => {:format => 'csv'}
205 205
      assert_response :success
206
      assert_equal 'text/csv', response.media_type
206
      assert_equal 'text/csv; header=present', response.media_type
207 207
    end
208 208
  end
209 209

  
test/functional/roles_controller_test.rb
279 279
    )
280 280
    assert_response :success
281 281

  
282
    assert_equal 'text/csv', @response.media_type
282
    assert_equal 'text/csv; header=present', @response.media_type
283 283
    lines = @response.body.chomp.split("\n")
284 284
    # Number of lines
285 285
    permissions = Redmine::AccessControl.permissions - Redmine::AccessControl.public_permissions
test/functional/timelog_controller_test.rb
1569 1569
    with_settings :date_format => '%m/%d/%Y' do
1570 1570
      get :index, :params => {:format => 'csv'}
1571 1571
      assert_response :success
1572
      assert_equal 'text/csv', response.media_type
1572
      assert_equal 'text/csv; header=present', response.media_type
1573 1573
    end
1574 1574
  end
1575 1575

  
......
1577 1577
    with_settings :date_format => '%m/%d/%Y' do
1578 1578
      get :index, :params => {:project_id => 1, :format => 'csv'}
1579 1579
      assert_response :success
1580
      assert_equal 'text/csv', response.media_type
1580
      assert_equal 'text/csv; header=present', response.media_type
1581 1581
    end
1582 1582
  end
1583 1583

  
test/functional/timelog_report_test.rb
233 233
      :format => "csv"
234 234
    }
235 235
    assert_response :success
236
    assert_equal 'text/csv', @response.media_type
236
    assert_equal 'text/csv; header=present', @response.media_type
237 237
    lines = @response.body.chomp.split("\n")
238 238
    # Headers
239 239
    assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first
......
251 251
      :format => "csv"
252 252
    }
253 253
    assert_response :success
254
    assert_equal 'text/csv', @response.media_type
254
    assert_equal 'text/csv; header=present', @response.media_type
255 255
    lines = @response.body.chomp.split("\n")
256 256
    # Headers
257 257
    assert_equal 'Project,User,Overtime,2007-3,2007-4,Total time', lines.first
......
304 304
      }
305 305
    end
306 306
    assert_response :success
307
    assert_equal 'text/csv', @response.media_type
307
    assert_equal 'text/csv; header=present', @response.media_type
308 308
    lines = @response.body.chomp.split("\n")
309 309
    # Headers
310 310
    s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
......
349 349
      }
350 350
    end
351 351
    assert_response :success
352
    assert_equal 'text/csv', @response.media_type
352
    assert_equal 'text/csv; header=present', @response.media_type
353 353
    lines = @response.body.chomp.split("\n")
354 354
    # Headers
355 355
    s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
......
384 384
        :format => "csv"
385 385
      }
386 386
      assert_response :success
387
      assert_equal 'text/csv', @response.media_type
387
      assert_equal 'text/csv; header=present', @response.media_type
388 388
      lines = @response.body.chomp.split("\n")
389 389
      # Headers
390 390
      s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1')
test/functional/users_controller_test.rb
85 85
      assert_include 'Authenticator app', response.body.split("\n").second
86 86
      assert_include 'disabled', response.body.split("\n").third
87 87

  
88
      assert_equal 'text/csv', @response.media_type
88
      assert_equal 'text/csv; header=present', @response.media_type
89 89
    end
90 90
  end
91 91

  
......
103 103

  
104 104
      assert_include 'float field;date field', response.body
105 105
      assert_include '2,10;10/01/2020', response.body
106
      assert_equal 'text/csv', @response.media_type
106
      assert_equal 'text/csv; header=present', @response.media_type
107 107
    end
108 108
  end
109 109

  
......
115 115
      assert_equal User.logged.status(3).count, response.body.chomp.split("\n").size - 1
116 116
      assert_include 'locked', response.body
117 117
      assert_not_include 'active', response.body
118
      assert_equal 'text/csv', @response.media_type
118
      assert_equal 'text/csv; header=present', @response.media_type
119 119
    end
120 120
  end
121 121

  
......
125 125

  
126 126
    assert_equal User.logged.like('John').count, response.body.chomp.split("\n").size - 1
127 127
    assert_include 'John', response.body
128
    assert_equal 'text/csv', @response.media_type
128
    assert_equal 'text/csv; header=present', @response.media_type
129 129
  end
130 130

  
131 131
  def test_index_csv_with_group_filter
......
133 133
    assert_response :success
134 134

  
135 135
    assert_equal Group.find(10).users.count, response.body.chomp.split("\n").size - 1
136
    assert_equal 'text/csv', @response.media_type
136
    assert_equal 'text/csv; header=present', @response.media_type
137 137
  end
138 138

  
139 139
  def test_show
140
-