diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-05 12:04:11 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-05 12:04:11 +0100 |
commit | 06d166694a9253b99a9c2720266b8b5cdc557d0f (patch) | |
tree | f8901aabcea9871cf96dc5a8c3d20a134af5f9cf /t/app | |
parent | c358aa2beeb4637d190a91def6c7a4b23d162b51 (diff) | |
parent | cdffddc061b58a61e78fe230bef2f0271baec006 (diff) |
Merge branch 'dashboard-update-csv-export'
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/dashboard.t | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index b53056968..3a031bec3 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -43,9 +43,13 @@ foreach my $problem (@fixed_problems) { $mech->create_comment_for_problem($problem, $counciluser, 'Title', 'text', 0, 'confirmed', 'fixed'); } +my $first_problem_id; +my $first_update_id; foreach my $problem (@closed_problems) { $problem->update({ state => 'closed' }); - $mech->create_comment_for_problem($problem, $counciluser, 'Title', 'text', 0, 'confirmed', 'closed', { confirmed => \'current_timestamp' }); + my ($update) = $mech->create_comment_for_problem($problem, $counciluser, 'Title', 'text', 0, 'confirmed', 'closed', { confirmed => \'current_timestamp' }); + $first_problem_id = $problem->id unless $first_problem_id; + $first_update_id = $update->id unless $first_update_id; } my $categories = scraper { @@ -154,7 +158,7 @@ FixMyStreet::override_config { } is scalar @rows, 19, '1 (header) + 18 (reports) = 19 lines'; - is scalar @{$rows[0]}, 18, '18 columns present'; + is scalar @{$rows[0]}, 20, '20 columns present'; is_deeply $rows[0], [ @@ -176,6 +180,8 @@ FixMyStreet::override_config { 'Easting', 'Northing', 'Report URL', + 'Site Used', + 'Reported As', ], 'Column headers look correct'; @@ -184,6 +190,32 @@ FixMyStreet::override_config { is $rows[5]->[16], '179716', 'Correct Northing conversion'; }; + subtest 'export updates as csv' => sub { + $mech->get_ok('/dashboard?updates=1&export=1'); + open my $data_handle, '<', \$mech->content; + my $csv = Text::CSV->new( { binary => 1 } ); + my @rows; + while ( my $row = $csv->getline( $data_handle ) ) { + push @rows, $row; + } + is scalar @rows, 15, '1 (header) + 14 (updates) = 15 lines'; + is scalar @{$rows[0]}, 8, '8 columns present'; + + is_deeply $rows[0], + [ + 'Report ID', 'Update ID', 'Date', 'Status', 'Problem state', + 'Text', 'User Name', 'Reported As', + ], + 'Column headers look correct'; + + is $rows[1]->[0], $first_problem_id, 'Correct report ID'; + is $rows[1]->[1], $first_update_id, 'Correct update ID'; + is $rows[1]->[3], 'confirmed', 'Correct state'; + is $rows[1]->[4], 'closed', 'Correct problem state'; + is $rows[1]->[5], 'text', 'Correct text'; + is $rows[1]->[6], 'Title', 'Correct name'; + }; + subtest 'export as csv using token' => sub { $mech->log_out_ok; |