Project

General

Profile

Defect #32921 » 0001-Rails-6-add-header-present-to-csv-tests.patch

Marius BĂLTEANU, 2020-01-31 14:54

View differences:

test/functional/issues_controller_test.rb
781 781
    get(:index, :params => {:format => 'csv'})
782 782
    assert_response :success
783 783

  
784
    assert_equal 'text/csv', @response.media_type
784
    assert_equal 'text/csv; header=present', @response.media_type
785 785
    assert response.body.starts_with?("#,")
786 786
    lines = response.body.chomp.split("\n")
787 787
    # default columns + id and project
......
797 797
      }
798 798
    )
799 799
    assert_response :success
800
    assert_equal 'text/csv', @response.media_type
800
    assert_equal 'text/csv; header=present', @response.media_type
801 801
  end
802 802

  
803 803
  def test_index_csv_without_any_filters
......
832 832
      )
833 833
      assert_response :success
834 834
    end
835
    assert_equal 'text/csv', response.media_type
835
    assert_equal 'text/csv; header=present', response.media_type
836 836
    headers = response.body.chomp.split("\n").first.split(',')
837 837
    assert_include 'Description', headers
838 838
    assert_include 'test_index_csv_with_description', response.body
......
860 860
      }
861 861
    )
862 862
    assert_response :success
863
    assert_equal 'text/csv', @response.media_type
863
    assert_equal 'text/csv; header=present', @response.media_type
864 864
    lines = @response.body.chomp.split("\n")
865 865
    assert_include "#{issue.id},#{issue.subject},7.33", lines
866 866
  end
......
875 875
    )
876 876
    assert_response :success
877 877

  
878
    assert_equal 'text/csv', @response.media_type
878
    assert_equal 'text/csv; header=present', @response.media_type
879 879
    assert_match /\A#,/, response.body
880 880
    lines = response.body.chomp.split("\n")
881 881
    assert_equal IssueQuery.new.available_inline_columns.size, lines[0].split(',').size
......
973 973
          :format => 'csv'
974 974
        }
975 975
      )
976
      assert_equal 'text/csv', @response.media_type
976
      assert_equal 'text/csv; header=present', @response.media_type
977 977
      lines = @response.body.chomp.split("\n")
978 978
      header = lines[0]
979 979
      status = (+"\xaa\xac\xbaA").force_encoding('Big5')
......
996 996
          :set_filter => 1
997 997
        }
998 998
      )
999
      assert_equal 'text/csv', @response.media_type
999
      assert_equal 'text/csv; header=present', @response.media_type
1000 1000
      lines = @response.body.chomp.split("\n")
1001 1001
      header = lines[0]
1002 1002
      issue_line = lines.find {|l| l =~ /^#{issue.id},/}
......
1022 1022
          :set_filter => 1
1023 1023
        }
1024 1024
      )
1025
      assert_equal 'text/csv', @response.media_type
1025
      assert_equal 'text/csv; header=present', @response.media_type
1026 1026
      lines = @response.body.chomp.split("\n")
1027 1027
      assert_include "#{issue.id},1234.50,#{str1}", lines
1028 1028
    end
......
1042 1042
          :set_filter => 1
1043 1043
        }
1044 1044
      )
1045
      assert_equal 'text/csv', @response.media_type
1045
      assert_equal 'text/csv; header=present', @response.media_type
1046 1046
      lines = @response.body.chomp.split("\n")
1047 1047
      assert_include "#{issue.id};1234,50;#{str1}", lines
1048 1048
    end
......
1597 1597
      }
1598 1598
    )
1599 1599
    assert_response :success
1600
    assert_equal 'text/csv', response.media_type
1600
    assert_equal 'text/csv; header=present', response.media_type
1601 1601
    lines = response.body.chomp.split("\n")
1602 1602
    assert_include '1,"Related to #7, Related to #8, Blocks #11"', lines
1603 1603
    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/timelog_controller_test.rb
1383 1383
    with_settings :date_format => '%m/%d/%Y' do
1384 1384
      get :index, :params => {:format => 'csv'}
1385 1385
      assert_response :success
1386
      assert_equal 'text/csv', response.media_type
1386
      assert_equal 'text/csv; header=present', response.media_type
1387 1387
    end
1388 1388
  end
1389 1389

  
......
1391 1391
    with_settings :date_format => '%m/%d/%Y' do
1392 1392
      get :index, :params => {:project_id => 1, :format => 'csv'}
1393 1393
      assert_response :success
1394
      assert_equal 'text/csv', response.media_type
1394
      assert_equal 'text/csv; header=present', response.media_type
1395 1395
    end
1396 1396
  end
1397 1397

  
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
......
289 289
      }
290 290
    end
291 291
    assert_response :success
292
    assert_equal 'text/csv', @response.media_type
292
    assert_equal 'text/csv; header=present', @response.media_type
293 293
    lines = @response.body.chomp.split("\n")
294 294
    # Headers
295 295
    s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
......
334 334
      }
335 335
    end
336 336
    assert_response :success
337
    assert_equal 'text/csv', @response.media_type
337
    assert_equal 'text/csv; header=present', @response.media_type
338 338
    lines = @response.body.chomp.split("\n")
339 339
    # Headers
340 340
    s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5')
......
369 369
        :format => "csv"
370 370
      }
371 371
      assert_response :success
372
      assert_equal 'text/csv', @response.media_type
372
      assert_equal 'text/csv; header=present', @response.media_type
373 373
      lines = @response.body.chomp.split("\n")
374 374
      # Headers
375 375
      s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1')
test/functional/users_controller_test.rb
74 74
      assert_equal User.logged.status(1).count, response.body.chomp.split("\n").size - 1
75 75
      assert_include 'active', response.body
76 76
      assert_not_include 'locked', response.body
77
      assert_equal 'text/csv', @response.media_type
77
      assert_equal 'text/csv; header=present', @response.media_type
78 78
    end
79 79
  end
80 80

  
......
86 86
      assert_equal User.logged.status(3).count, response.body.chomp.split("\n").size - 1
87 87
      assert_include 'locked', response.body
88 88
      assert_not_include 'active', response.body
89
      assert_equal 'text/csv', @response.media_type
89
      assert_equal 'text/csv; header=present', @response.media_type
90 90
    end
91 91
  end
92 92

  
......
96 96

  
97 97
    assert_equal User.logged.like('John').count, response.body.chomp.split("\n").size - 1
98 98
    assert_include 'John', response.body
99
    assert_equal 'text/csv', @response.media_type
99
    assert_equal 'text/csv; header=present', @response.media_type
100 100
  end
101 101

  
102 102
  def test_index_csv_with_group_filter
......
104 104
    assert_response :success
105 105

  
106 106
    assert_equal Group.find(10).users.count, response.body.chomp.split("\n").size - 1
107
    assert_equal 'text/csv', @response.media_type
107
    assert_equal 'text/csv; header=present', @response.media_type
108 108
  end
109 109

  
110 110
  def test_show
(3-3/3)