diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/MapIt.pm | 1 | ||||
-rw-r--r-- | t/cobrand/isleofwight.t | 37 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 47 |
3 files changed, 65 insertions, 20 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index b5cc694df..8b8bb5978 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -49,6 +49,7 @@ my @PLACES = ( [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ], [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], [ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ], + [ 'PO30 5XJ', 50.71086, -1.29573, 2636, 'Isle of Wight Council', 'UTA' ], [ 'OX28 4DS', 51.784721, -1.494453 ], [ 'E14 2DN', 51.508536, '0.000001' ], # Norway diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t new file mode 100644 index 000000000..c3e5a7810 --- /dev/null +++ b/t/cobrand/isleofwight.t @@ -0,0 +1,37 @@ +use FixMyStreet::TestMech; + +ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); + +my $isleofwight_id = $mech->create_body_ok(2636, 'Isle of Wight Council')->id; +$mech->create_contact_ok( + body_id => $isleofwight_id, + category => 'Potholes', + email => 'pothole@example.org', +); + +my $user = $mech->create_user_ok('user@example.org'); + +my @reports = $mech->create_problems_for_body(1, $isleofwight_id, 'An Isle of wight report', { + confirmed => '2019-05-25 09:00', + lastupdate => '2019-05-25 09:00', + latitude => 50.7108, + longitude => -1.29573, + user => $user +}); + +subtest "only original reporter can comment" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => 'isleofwight', + }, sub { + $mech->get_ok('/report/' . $reports[0]->id); + $mech->content_contains('Only the original reporter may leave updates'); + + $mech->log_in_ok('user@example.org'); + $mech->get_ok('/report/' . $reports[0]->id); + $mech->content_lacks('Only the original reporter may leave updates'); + }; +}; + + +done_testing(); diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 809fd3a19..382f684f9 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -24,6 +24,7 @@ my $user = FixMyStreet::DB->resultset('User')->find_or_create( my %bodies = ( 2237 => FixMyStreet::DB->resultset("Body")->create({ name => 'Oxfordshire' }), 2494 => FixMyStreet::DB->resultset("Body")->create({ name => 'Bexley' }), + 2636 => FixMyStreet::DB->resultset("Body")->create({ name => 'Isle of Wight' }), 2482 => FixMyStreet::DB->resultset("Body")->create({ name => 'Bromley', send_method => 'Open311', @@ -36,6 +37,7 @@ my %bodies = ( ); $bodies{2237}->body_areas->create({ area_id => 2237 }); $bodies{2494}->body_areas->create({ area_id => 2494 }); +$bodies{2636}->body_areas->create({ area_id => 2636 }); my $response_template = $bodies{2482}->response_templates->create({ title => "investigating template", @@ -529,29 +531,34 @@ for my $test ( }; } -subtest 'Marking report as fixed closes it for updates (Bexley)' => sub { - my $local_requests_xml = setup_xml($problemB->external_id, $problemB->id, 'CLOSED'); - my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); +for ( + { id => 2494, cobrand => 'bexley' }, + { id => 2636, cobrand => 'isleofwight' } +) { + subtest "Marking report as fixed closes it for updates ($_->{cobrand})" => sub { + my $local_requests_xml = setup_xml($problemB->external_id, $problemB->id, 'CLOSED'); + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); - $problemB->update( { bodies_str => $bodies{2494}->id } ); + $problemB->update( { bodies_str => $bodies{$_->{id}}->id } ); - my $update = Open311::GetServiceRequestUpdates->new( - system_user => $user, - current_open311 => $o, - current_body => $bodies{2494}, - current_cobrand => $bodies{2494}->get_cobrand_handler, - ); - FixMyStreet::override_config { - ALLOWED_COBRANDS => 'bexley', - }, sub { - $update->process_body; - }; + my $update = Open311::GetServiceRequestUpdates->new( + system_user => $user, + current_open311 => $o, + current_body => $bodies{$_->{id}}, + current_cobrand => $bodies{$_->{id}}->get_cobrand_handler, + ); + FixMyStreet::override_config { + ALLOWED_COBRANDS => $_->{cobrand}, + }, sub { + $update->process_body; + }; - $problemB->discard_changes; - is $problemB->comments->count, 1, 'comment count'; - is $problemB->get_extra_metadata('closed_updates'), 1; - $problemB->comments->delete; -}; + $problemB->discard_changes; + is $problemB->comments->count, 1, 'comment count'; + is $problemB->get_extra_metadata('closed_updates'), 1; + $problemB->comments->delete; + }; +} subtest 'Update with media_url includes image in update' => sub { my $UPLOAD_DIR = tempdir( CLEANUP => 1 ); |