diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-22 11:29:22 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-25 12:29:47 +0000 |
commit | fd5a8de180bd67fef7ce14c476ef0fd94c29ce19 (patch) | |
tree | 5b70ae898cfdce635edc58b7fd8fb05654750939 /t/app/controller/dashboard.t | |
parent | e481c2fd127c46024b1b15587981dca00eada44c (diff) |
Factor out test CSV content function.
Diffstat (limited to 't/app/controller/dashboard.t')
-rw-r--r-- | t/app/controller/dashboard.t | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 37903513c..ff8d1a9d5 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -167,12 +167,7 @@ FixMyStreet::override_config { areas => ",$alt_area_id,2651,", }); $mech->get_ok('/dashboard?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; - } + my @rows = $mech->content_as_csv; is scalar @rows, 19, '1 (header) + 18 (reports) = 19 lines'; is scalar @{$rows[0]}, 20, '20 columns present'; @@ -209,12 +204,7 @@ FixMyStreet::override_config { 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; - } + my @rows = $mech->content_as_csv; is scalar @rows, 15, '1 (header) + 14 (updates) = 15 lines'; is scalar @{$rows[0]}, 8, '8 columns present'; |