diff options
author | Matthew Somerville <matthew@mysociety.org> | 2013-02-01 15:28:08 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2013-02-04 06:53:02 +0000 |
commit | 488a8f21a0c1bc2b9501c9d94d69db56cccd80ae (patch) | |
tree | 68becf501e9492466a80015e8ace9a7fb1557cfa /t/app/controller/report_display.t | |
parent | 3e0d12e8584d132b573f536ab5cd01e24241827b (diff) | |
parent | 28aa1dd7fb1c9bc93aa204afae67cf68fe36ee6b (diff) |
Merge remote branch 'origin/zurich'
Conflicts:
bin/open311-populate-service-list
bin/send-comments
bin/update-all-reports
conf/crontab.ugly
db/schema.sql
perllib/FixMyStreet/App/Controller/Admin.pm
perllib/FixMyStreet/App/Controller/Report/New.pm
perllib/FixMyStreet/App/Controller/Reports.pm
perllib/FixMyStreet/Cobrand/Default.pm
perllib/FixMyStreet/Cobrand/LichfieldDC.pm
perllib/FixMyStreet/DB/Result/Open311conf.pm
perllib/FixMyStreet/DB/Result/Problem.pm
perllib/FixMyStreet/DB/ResultSet/Problem.pm
perllib/FixMyStreet/SendReport.pm
perllib/FixMyStreet/SendReport/Email.pm
perllib/FixMyStreet/SendReport/Open311.pm
perllib/Open311/GetServiceRequestUpdates.pm
perllib/Open311/PopulateServiceList.pm
t/app/controller/report_new.t
t/app/controller/rss.t
templates/web/bromley/report/display.html
templates/web/default/admin/council_contacts.html
templates/web/default/common_header_tags.html
templates/web/default/dashboard/index.html
templates/web/default/front/stats.html
templates/web/default/report/_main.html
templates/web/default/report/update-form.html
templates/web/emptyhomes/index.html
templates/web/emptyhomes/report/display.html
templates/web/emptyhomes/report/new/councils_text_all.html
templates/web/emptyhomes/reports/body.html
templates/web/emptyhomes/reports/index.html
templates/web/fixmystreet/report/new/fill_in_details_form.html
templates/web/fixmystreet/report/update-form.html
web/cobrands/fixmystreet/fixmystreet.js
web/js/fixmystreet.js
Diffstat (limited to 't/app/controller/report_display.t')
-rw-r--r-- | t/app/controller/report_display.t | 114 |
1 files changed, 100 insertions, 14 deletions
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index aa04e499b..a3c4edfc7 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -5,6 +5,7 @@ use Test::More; use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; +use Test::LongString; use DateTime; my $mech = FixMyStreet::TestMech->new; @@ -33,7 +34,7 @@ my $dt = DateTime->new( my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { postcode => 'SW1A 1AA', - council => '2504', + bodies_str => '2504', areas => ',105255,11806,11828,2247,2504,', category => 'Other', title => 'Test 2', @@ -94,6 +95,19 @@ subtest "change report to unconfirmed and check for 404 status" => sub { ok $report->update( { state => 'confirmed' } ), 'confirm report again'; }; + +subtest "Zurich unconfirmeds are 200" => sub { + if ( !FixMyStreet::Cobrand->exists('zurich') ) { + plan skip_all => 'Skipping Zurich test without Zurich cobrand'; + } + $mech->host( 'zurich.fixmystreet.com' ); + ok $report->update( { state => 'unconfirmed' } ), 'unconfirm report'; + $mech->get_ok("/report/$report_id"); + $mech->content_contains( 'This report is awaiting moderation' ); + ok $report->update( { state => 'confirmed' } ), 'confirm report again'; + $mech->host( 'www.fixmystreet.com' ); +}; + subtest "change report to hidden and check for 410 status" => sub { ok $report->update( { state => 'hidden' } ), 'hide report'; ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; @@ -385,39 +399,111 @@ for my $test ( }; } +subtest "Zurich banners are displayed correctly" => sub { + if ( !FixMyStreet::Cobrand->exists('zurich') ) { + plan skip_all => 'Skipping Zurich test without Zurich cobrand'; + } + $mech->host( 'zurich.fixmystreet.com' ); + + for my $test ( + { + description => 'new report', + state => 'unconfirmed', + banner_id => 'closed', + banner_text => 'Erfasst' + }, + { + description => 'confirmed report', + state => 'confirmed', + banner_id => 'closed', + banner_text => 'Aufgenommen', + }, + { + description => 'fixed report', + state => 'fixed - council', + banner_id => 'fixed', + banner_text => 'Erledigt', + }, + { + description => 'closed report', + state => 'closed', + banner_id => 'fixed', + banner_text => 'Erledigt', + }, + { + description => 'in progress report', + state => 'in progress', + banner_id => 'progress', + banner_text => 'In Bearbeitung', + }, + { + description => 'planned report', + state => 'planned', + banner_id => 'progress', + banner_text => 'In Bearbeitung', + }, + ) { + subtest "banner for $test->{description}" => sub { + $report->state( $test->{state} ); + $report->update; + + $mech->get_ok("/report/$report_id"); + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + my $banner = $mech->extract_problem_banner; + if ( $banner->{text} ) { + $banner->{text} =~ s/^ //g; + $banner->{text} =~ s/ $//g; + } + + is $banner->{id}, $test->{banner_id}, 'banner id'; + if ($test->{banner_text}) { + like_string( $banner->{text}, qr/$test->{banner_text}/i, 'banner text is ' . $test->{banner_text} ); + } else { + is $banner->{text}, $test->{banner_text}, 'banner text'; + } + + }; + } + + $mech->host( 'www.fixmystreet.com' ); +}; + +$mech->create_body_ok(2504, 'Westminster City Council'); +$mech->create_body_ok(2505, 'Camden Borough Council'); + for my $test ( { desc => 'no state dropdown if user not from authority', - from_council => 0, + from_body => undef, no_state => 1, - report_council => '2504', + report_body => '2504', }, { desc => 'state dropdown if user from authority', - from_council => 2504, + from_body => 2504, no_state => 0, - report_council => '2504', + report_body => '2504', }, { - desc => 'no state dropdown if user not from same council as problem', - from_council => 2505, + desc => 'no state dropdown if user not from same body as problem', + from_body => 2505, no_state => 1, - report_council => '2504', + report_body => '2504', }, { - desc => 'state dropdown if user from authority and problem sent to multiple councils', - from_council => 2504, + desc => 'state dropdown if user from authority and problem sent to multiple bodies', + from_body => 2504, no_state => 0, - report_council => '2504,2506', + report_body => '2504,2506', }, ) { subtest $test->{desc} => sub { $mech->log_in_ok( $user->email ); - $user->from_council( $test->{from_council} ); + $user->from_body( $test->{from_body} ); $user->update; $report->discard_changes; - $report->council( $test->{report_council} ); + $report->bodies_str( $test->{report_body} ); $report->update; $mech->get_ok("/report/$report_id"); @@ -431,7 +517,7 @@ for my $test ( } $report->discard_changes; -$report->council( 2504 ); +$report->bodies_str( 2504 ); $report->update; # tidy up |