diff options
Diffstat (limited to 't/app/controller/reports.t')
-rw-r--r-- | t/app/controller/reports.t | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index a4dab6597..42e69fd03 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -8,15 +8,25 @@ use DateTime; ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); -$mech->delete_problems_for_council( 2504 ); -$mech->delete_problems_for_council( 2651 ); +$mech->create_body_ok(2514, 'Birmingham City Council'); +$mech->create_body_ok(2651, 'City of Edinburgh Council'); +$mech->create_body_ok(2504, 'Westminster City Council'); -my @edinburgh_problems = $mech->create_problems_for_council(3, 2651, 'All reports'); -my @westminster_problems = $mech->create_problems_for_council(5, 2504, 'All reports'); +$mech->delete_problems_for_body( 2504 ); +$mech->delete_problems_for_body( 2651 ); + +my @edinburgh_problems = $mech->create_problems_for_body(3, 2651, 'All reports'); +my @westminster_problems = $mech->create_problems_for_body(5, 2504, 'All reports'); is scalar @westminster_problems, 5, 'correct number of westminster problems created'; is scalar @edinburgh_problems, 3, 'correct number of edinburgh problems created'; +$edinburgh_problems[1]->update( { + state => 'in progress', + confirmed => DateTime->now()->subtract( weeks => 6 ), + lastupdate => DateTime->now()->subtract( weeks => 5 ), +} ); + # Run the cron script that makes the data for /reports so we don't get an error. system( "bin/cron-wrapper update-all-reports" ); @@ -27,12 +37,18 @@ $mech->content_contains('Birmingham'); my $stats = $mech->extract_report_stats; -is $stats->{'City of Edinburgh Council'}->[1], 3, 'correct number of reports for Edinburgh'; +is $stats->{'City of Edinburgh Council'}->[1], 2, 'correct number of new reports for Edinburgh'; +is $stats->{'City of Edinburgh Council'}->[2], 1, 'correct number of older reports for Edinburgh'; + is $stats->{'Westminster City Council'}->[1], 5, 'correct number of reports for Westminster'; -$mech->follow_link_ok( { text_regex => qr/Birmingham/ } ); +FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.mysociety.org/', +}, sub { + $mech->follow_link_ok( { text_regex => qr/Birmingham/ } ); + $mech->get_ok('/reports/Westminster'); +}; -$mech->get_ok('/reports/Westminster'); $mech->title_like(qr/Westminster City Council/); $mech->content_contains('Westminster City Council'); $mech->content_contains('All reports Test 3 for 2504', 'problem to be marked non public visible'); @@ -43,7 +59,11 @@ is scalar @$problems, 5, 'correct number of problems displayed'; my $private = $westminster_problems[2]; ok $private->update( { non_public => 1 } ), 'problem marked non public'; -$mech->get_ok('/reports/Westminster'); +FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.mysociety.org/', +}, sub { + $mech->get_ok('/reports/Westminster'); +}; $problems = $mech->extract_problem_list; is scalar @$problems, 4, 'only public problems are displayed'; @@ -53,23 +73,30 @@ $mech->get_ok('/reports'); $stats = $mech->extract_report_stats; is $stats->{'Westminster City Council'}->[1], 5, 'non public reports included in stats'; -SKIP: { - skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 ) - unless FixMyStreet::Cobrand->exists('emptyhomes'); - ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes'; - $mech->get_ok('/reports'); - # EHA lacks one column the others have - $mech->content_lacks('state unknown'); - - skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 8 ) - unless FixMyStreet::Cobrand->exists('fiksgatami'); - mySociety::MaPit::configure('http://mapit.nuug.no/'); - ok $mech->host("fiksgatami.no"), 'change host to fiksgatami'; - $mech->get_ok('/reports'); - # There should only be one Oslo - $mech->content_contains('Oslo'); - $mech->content_unlike(qr{Oslo">Oslo.*Oslo}s); -} +subtest "test emptyhomes all reports page" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'emptyhomes' ], + }, sub { + ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes'; + $mech->get_ok('/reports'); + # EHA lacks one column the others have + $mech->content_lacks('state unknown'); + }; +}; + +subtest "test fiksgatami all reports page" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'fiksgatami' ], + MAPIT_URL => 'http://mapit.nuug.no/', + }, sub { + $mech->create_body_ok(3, 'Oslo'); + ok $mech->host("fiksgatami.no"), 'change host to fiksgatami'; + $mech->get_ok('/reports'); + # There should only be one Oslo + $mech->content_contains('Oslo'); + $mech->content_unlike(qr{Oslo">Oslo.*Oslo}s); + } +}; done_testing(); |