New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop slashes breaking csv report downloads #3642
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3642 +/- ##
==========================================
- Coverage 82.69% 82.64% -0.06%
==========================================
Files 348 348
Lines 23750 23750
Branches 3609 3609
==========================================
- Hits 19641 19629 -12
- Misses 2973 2984 +11
- Partials 1136 1137 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of testing you probably want something similar to the existing "export as CSV" test but using a category with a slash in the name.
fixmystreet/t/app/controller/dashboard.t
Lines 182 to 224 in 76436d0
subtest 'export as csv' => sub { | |
$mech->create_problems_for_body(1, $body->id, 'Title', { | |
detail => "this report\nis split across\nseveral lines", | |
category => 'Problem one', | |
areas => ",$alt_area_id,2651,", | |
}); | |
$mech->get_ok('/dashboard?export=1'); | |
my @rows = $mech->content_as_csv; | |
is scalar @rows, 19, '1 (header) + 18 (reports) = 19 lines'; | |
is scalar @{$rows[0]}, 22, '22 columns present'; | |
is_deeply $rows[0], | |
[ | |
'Report ID', | |
'Title', | |
'Detail', | |
'User Name', | |
'Category', | |
'Subcategory', | |
'Created', | |
'Confirmed', | |
'Acknowledged', | |
'Fixed', | |
'Closed', | |
'Status', | |
'Latitude', | |
'Longitude', | |
'Query', | |
'Ward', | |
'Easting', | |
'Northing', | |
'Report URL', | |
'Device Type', | |
'Site Used', | |
'Reported As', | |
], | |
'Column headers look correct'; | |
is $rows[5]->[15], 'Trowbridge', 'Ward column is name not ID'; | |
is $rows[5]->[16], '529025', 'Correct Easting conversion'; | |
is $rows[5]->[17], '179716', 'Correct Northing conversion'; | |
}; |
27924bc
to
c36b3d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚔️
954c40f was setting extra metadata, rather than the extra field it should have been.
Removes slashes from category names as: Forward slash stops a file being created. Backward slash stops a file being retrieved. Co-Authored-By: M Somerville <matthew@mysociety.org>
c36b3d8
to
010af6a
Compare
Removes slashes from category names used in file name for csv download.
Backward slash makes the file not retrievable.
Forward slash makes the file not saveable.
https://github.com/mysociety/societyworks/issues/2679