diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/Nominatim.pm | 4 | ||||
-rw-r--r-- | t/app/controller/dashboard.t | 39 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 2 |
3 files changed, 42 insertions, 3 deletions
diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm index 5edbc9b30..6a61b423e 100644 --- a/t/Mock/Nominatim.pm +++ b/t/Mock/Nominatim.pm @@ -6,7 +6,7 @@ use Web::Simple; has json => ( is => 'lazy', default => sub { - JSON->new->pretty->allow_blessed->convert_blessed; + JSON->new->utf8->pretty->allow_blessed->convert_blessed; }, ); @@ -30,7 +30,7 @@ sub query { my ($self, $q) = @_; if ($q eq 'high street') { return [ - {"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Edinburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734}, + {"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Ed\x{ed}nburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734}, {"osm_type"=>"node","osm_id"=>"27424410","lat"=>"55.8596449","lon"=>"-4.240377","display_name"=>"High Street, Collegelands, Merchant City, Glasgow, Glasgow City, Scotland, G, United Kingdom","class"=>"railway","type"=>"station","importance"=>0.53074299592768} ]; } diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 14bd76c41..3a22d4280 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -634,6 +634,45 @@ FixMyStreet::override_config { is $rows[5]->[15], '610591', 'Correct Easting conversion'; is $rows[5]->[16], '126573', 'Correct Northing conversion'; }; + + delete_problems(); + subtest 'check date restriction' => sub { + make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 1 ) }); + make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 50 ) }); + make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 31 ) }); + + $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; + } + + is scalar @rows, 2, '1 (header) + 1 (reports) = 2 lines'; + + $mech->get_ok('/dashboard?export=1&start_date=' . DateTime->now->subtract('days' => 32)->ymd); + + open $data_handle, '<', \$mech->content; + $csv = Text::CSV->new( { binary => 1 } ); + @rows = (); + while ( my $row = $csv->getline( $data_handle ) ) { + push @rows, $row; + } + + is scalar @rows, 3, '1 (header) + 2 (reports) = 3 lines'; + + $mech->get_ok('/dashboard?export=1&start_date=' . DateTime->now->subtract('days' => 51)->ymd . '&end_date=' . DateTime->now->subtract('days' => 49)->ymd ); + + open $data_handle, '<', \$mech->content; + $csv = Text::CSV->new( { binary => 1 } ); + @rows = (); + while ( my $row = $csv->getline( $data_handle ) ) { + push @rows, $row; + } + + is scalar @rows, 2, '1 (header) + 1 (reports) = 2 lines'; + }; }; restore_time; diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 06b5830e3..133a8c950 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -102,7 +102,7 @@ subtest "Test ajax decimal points" => sub { $mech->content_contains('51.5'); $mech->get_ok('/ajax/lookup_location?term=high+street'); - $mech->content_contains('Edinburgh'); + $mech->content_contains("Ed\xc3\xadnburgh"); }; }; |