From f30c91341aba5c4037de40d75bf8ecd42cb4b5cd Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 1 Apr 2021 14:59:31 +0000 Subject: [PATCH] Rails 6.1: add header=present to csv tests (#29914, #32921). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@20887 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/issues_controller_test.rb | 20 ++++++++++---------- test/functional/projects_controller_test.rb | 2 +- test/functional/roles_controller_test.rb | 2 +- test/functional/timelog_controller_test.rb | 4 ++-- test/functional/timelog_report_test.rb | 10 +++++----- test/functional/users_controller_test.rb | 10 +++++----- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 7bbc48e76..ccebb4311 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -843,7 +843,7 @@ class IssuesControllerTest < Redmine::ControllerTest get(:index, :params => {:format => 'csv'}) assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type assert response.body.starts_with?("#,") lines = response.body.chomp.split("\n") # default columns + id and project @@ -859,7 +859,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end def test_index_csv_without_any_filters @@ -894,7 +894,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :success end - assert_equal 'text/csv', response.media_type + assert_equal 'text/csv; header=present', response.media_type headers = response.body.chomp.split("\n").first.split(',') assert_include 'Description', headers assert_include 'test_index_csv_with_description', response.body @@ -922,7 +922,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") assert_include "#{issue.id},#{issue.subject},7.33", lines end @@ -937,7 +937,7 @@ class IssuesControllerTest < Redmine::ControllerTest ) assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type assert_match /\A#,/, response.body lines = response.body.chomp.split("\n") assert_equal IssueQuery.new.available_inline_columns.size, lines[0].split(',').size @@ -1035,7 +1035,7 @@ class IssuesControllerTest < Redmine::ControllerTest :format => 'csv' } ) - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") header = lines[0] status = (+"\xaa\xac\xbaA").force_encoding('Big5') @@ -1058,7 +1058,7 @@ class IssuesControllerTest < Redmine::ControllerTest :set_filter => 1 } ) - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") header = lines[0] issue_line = lines.find {|l| l =~ /^#{issue.id},/} @@ -1084,7 +1084,7 @@ class IssuesControllerTest < Redmine::ControllerTest :set_filter => 1 } ) - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") assert_include "#{issue.id},1234.50,#{str1}", lines end @@ -1104,7 +1104,7 @@ class IssuesControllerTest < Redmine::ControllerTest :set_filter => 1 } ) - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") assert_include "#{issue.id};1234,50;#{str1}", lines end @@ -1659,7 +1659,7 @@ class IssuesControllerTest < Redmine::ControllerTest } ) assert_response :success - assert_equal 'text/csv', response.media_type + assert_equal 'text/csv; header=present', response.media_type lines = response.body.chomp.split("\n") assert_include '1,"Related to #7, Related to #8, Blocks #11"', lines assert_include '2,Blocked by #12', lines diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 7506d3ba1..2c3cb2968 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -203,7 +203,7 @@ class ProjectsControllerTest < Redmine::ControllerTest with_settings :date_format => '%m/%d/%Y' do get :index, :params => {:format => 'csv'} assert_response :success - assert_equal 'text/csv', response.media_type + assert_equal 'text/csv; header=present', response.media_type end end diff --git a/test/functional/roles_controller_test.rb b/test/functional/roles_controller_test.rb index 552f85287..c1bb859a4 100644 --- a/test/functional/roles_controller_test.rb +++ b/test/functional/roles_controller_test.rb @@ -279,7 +279,7 @@ class RolesControllerTest < Redmine::ControllerTest ) assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Number of lines permissions = Redmine::AccessControl.permissions - Redmine::AccessControl.public_permissions diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 1f7682737..b1a4899cc 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -1569,7 +1569,7 @@ class TimelogControllerTest < Redmine::ControllerTest with_settings :date_format => '%m/%d/%Y' do get :index, :params => {:format => 'csv'} assert_response :success - assert_equal 'text/csv', response.media_type + assert_equal 'text/csv; header=present', response.media_type end end @@ -1577,7 +1577,7 @@ class TimelogControllerTest < Redmine::ControllerTest with_settings :date_format => '%m/%d/%Y' do get :index, :params => {:project_id => 1, :format => 'csv'} assert_response :success - assert_equal 'text/csv', response.media_type + assert_equal 'text/csv; header=present', response.media_type end end diff --git a/test/functional/timelog_report_test.rb b/test/functional/timelog_report_test.rb index 5b56f1ea9..19ae055ea 100644 --- a/test/functional/timelog_report_test.rb +++ b/test/functional/timelog_report_test.rb @@ -233,7 +233,7 @@ class TimelogReportTest < Redmine::ControllerTest :format => "csv" } assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Headers assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first @@ -251,7 +251,7 @@ class TimelogReportTest < Redmine::ControllerTest :format => "csv" } assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Headers assert_equal 'Project,User,Overtime,2007-3,2007-4,Total time', lines.first @@ -304,7 +304,7 @@ class TimelogReportTest < Redmine::ControllerTest } end assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Headers s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5') @@ -349,7 +349,7 @@ class TimelogReportTest < Redmine::ControllerTest } end assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Headers s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5') @@ -384,7 +384,7 @@ class TimelogReportTest < Redmine::ControllerTest :format => "csv" } assert_response :success - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type lines = @response.body.chomp.split("\n") # Headers s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1') diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 15e8cf2ea..c185f0eca 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -85,7 +85,7 @@ class UsersControllerTest < Redmine::ControllerTest assert_include 'Authenticator app', response.body.split("\n").second assert_include 'disabled', response.body.split("\n").third - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end end @@ -103,7 +103,7 @@ class UsersControllerTest < Redmine::ControllerTest assert_include 'float field;date field', response.body assert_include '2,10;10/01/2020', response.body - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end end @@ -115,7 +115,7 @@ class UsersControllerTest < Redmine::ControllerTest assert_equal User.logged.status(3).count, response.body.chomp.split("\n").size - 1 assert_include 'locked', response.body assert_not_include 'active', response.body - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end end @@ -125,7 +125,7 @@ class UsersControllerTest < Redmine::ControllerTest assert_equal User.logged.like('John').count, response.body.chomp.split("\n").size - 1 assert_include 'John', response.body - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end def test_index_csv_with_group_filter @@ -133,7 +133,7 @@ class UsersControllerTest < Redmine::ControllerTest assert_response :success assert_equal Group.find(10).users.count, response.body.chomp.split("\n").size - 1 - assert_equal 'text/csv', @response.media_type + assert_equal 'text/csv; header=present', @response.media_type end def test_show -- 2.39.5