aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2013-12-23 17:05:07 +0000
committerHakim Cassimally <hakim@mysociety.org>2013-12-23 17:05:07 +0000
commit2de7fa2f95a935293cd8fc1f15af14441b021e50 (patch)
tree3f0266fb9f6acde8026593c9610d9655bebf1eab /t
parentf6b9e9ee08db4211e69df28957c3f4a770bd1d57 (diff)
Fix test breakage
for Zurich tests, count how many reports already exist as a baseline.
Diffstat (limited to 't')
-rw-r--r--t/cobrand/zurich.t29
1 files changed, 23 insertions, 6 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index a4f3963c6..73007ff59 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -78,12 +78,30 @@ sub cleanup {
$mech->delete_user( 'sdm1@example.org' );
}
+sub get_export_rows_count {
+ my $mech = shift;
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ }, sub {
+ $mech->get_ok( '/admin/stats?export=1' );
+ };
+ is $mech->res->code, 200, 'csv retrieved ok';
+ is $mech->content_type, 'text/csv', 'content_type correct' and do {
+ my @lines = split /\n/, $mech->content;
+ return @lines - 1;
+ };
+ return;
+}
+
cleanup();
+my $EXISTING_REPORT_COUNT = 0;
+
subtest "set up superuser" => sub {
my $superuser = $mech->log_in_ok( 'super@example.org' );
# a user from body $zurich is a superuser, as $zurich has no parent id!
$superuser->update({ from_body => $zurich->id });
+ $EXISTING_REPORT_COUNT = get_export_rows_count($mech);
$mech->log_out_ok;
};
@@ -635,14 +653,13 @@ subtest "test stats" => sub {
# my @data = $mech->content =~ /(?:moderiert|abgeschlossen): \d+/g;
# diag Dumper(\@data); use Data::Dumper;
- $mech->get_ok( '/admin/stats?export=1' );
- is $mech->res->code, 200, 'csv retrieved ok';
- is $mech->content_type, 'text/csv', 'content_type correct' and do {
+ my $export_count = get_export_rows_count($mech);
+ if (defined $export_count) {
+ is $export_count - $EXISTING_REPORT_COUNT, 3, 'Correct number of reports';
$mech->content_contains(',fixed - council,');
$mech->content_contains(',hidden,');
- my @lines = split /\n/, $mech->content;
- is scalar @lines, 4, 'Correct number of lines';
- };
+ }
+
$mech->log_out_ok;
};
};