Defect #32921 » 0001-Rails-6-add-header-present-to-csv-tests.patch
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
}
|
||
|
)
|
||
|
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
|
||
| ... | ... | |
|
)
|
||
|
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
|
||
| ... | ... | |
|
}
|
||
|
)
|
||
|
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
|
||
| ... | ... | |
|
)
|
||
|
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
|
||
| ... | ... | |
|
: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')
|
||
| ... | ... | |
|
: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},/}
|
||
| ... | ... | |
|
: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
|
||
| ... | ... | |
|
: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
|
||
| ... | ... | |
|
}
|
||
|
)
|
||
|
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
|
||
| test/functional/projects_controller_test.rb | ||
|---|---|---|
|
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
|
||
| test/functional/timelog_controller_test.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| test/functional/timelog_report_test.rb | ||
|---|---|---|
|
: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
|
||
| ... | ... | |
|
: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
|
||
| ... | ... | |
|
}
|
||
|
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')
|
||
| ... | ... | |
|
}
|
||
|
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')
|
||
| ... | ... | |
|
: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')
|
||
| test/functional/users_controller_test.rb | ||
|---|---|---|
|
assert_equal User.logged.status(1).count, response.body.chomp.split("\n").size - 1
|
||
|
assert_include 'active', response.body
|
||
|
assert_not_include 'locked', response.body
|
||
|
assert_equal 'text/csv', @response.media_type
|
||
|
assert_equal 'text/csv; header=present', @response.media_type
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
- « Previous
- 1
- 2
- 3
- Next »