Skip to content
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

Merged
merged 2 commits into from Nov 26, 2021
Merged

Conversation

MorayMySoc
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #3642 (010af6a) into master (1711f9a) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
perllib/FixMyStreet/Reporting.pm 94.96% <ø> (ø)
perllib/FixMyStreet/Cobrand/Bromley.pm 92.60% <100.00%> (ø)
web/js/front.js 82.25% <0.00%> (-1.62%) ⬇️
web/cobrands/fixmystreet/assets.js 88.23% <0.00%> (-1.52%) ⬇️
perllib/Utils.pm 97.97% <0.00%> (-1.02%) ⬇️
web/cobrands/fixmystreet-uk-councils/alloy.js 90.09% <0.00%> (-1.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1711f9a...010af6a. Read the comment docs.

Copy link
Member

@chrismytton chrismytton left a 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.

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';
};

CHANGELOG.md Outdated Show resolved Hide resolved
@dracos dracos marked this pull request as ready for review November 24, 2021 20:56
Copy link
Member

@chrismytton chrismytton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚔️

dracos and others added 2 commits November 26, 2021 10:11
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>
@dracos dracos merged commit 2762bd7 into master Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants