aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-11 13:17:27 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-11 13:17:27 +0100
commit5accaad402d24f37851d8b85084fda2859b1ae16 (patch)
treeca923c4170bea77fe40ba8ae13c34a9b4c99d6d1 /t/open311
parentfda83d5c4c9962c17fd0629e8ee17b50e3dbbac4 (diff)
add ability to suppress alerts to report creator on
comments updated from open311
Diffstat (limited to 't/open311')
-rw-r--r--t/open311/getservicerequestupdates.t66
1 files changed, 66 insertions, 0 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 062a9e2f1..92d03e385 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -455,6 +455,72 @@ foreach my $test ( {
};
}
+foreach my $test ( {
+ desc => 'normally alerts are not suppressed',
+ suppress_alerts => 0,
+ },
+ {
+ desc => 'alerts suppressed if suppress_alerts set',
+ suppress_alerts => 1,
+ }
+) {
+ subtest $test->{desc} => sub {
+ my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
+ <service_requests_updates>
+ <request_update>
+ <update_id>638344</update_id>
+ <service_request_id>@{[ $problem->external_id ]}</service_request_id>
+ <service_request_id_ext>@{[ $problem->id ]}</service_request_id_ext>
+ <status>closed</status>
+ <description>This is a note</description>
+ <updated_datetime>UPDATED_DATETIME</updated_datetime>
+ </request_update>
+ </service_requests_updates>
+ };
+
+ $problem->comments->delete;
+ $problem->state( 'confirmed' );
+ $problem->lastupdate( $dt->subtract( hours => 3 ) );
+ $problem->update;
+
+ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create( {
+ alert_type => 'new_updates',
+ parameter => $problem->id,
+ confirmed => 1,
+ user_id => $problem->user->id,
+ } );
+
+ $requests_xml =~ s/UPDATED_DATETIME/$dt/;
+
+ my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'update.xml' => $requests_xml } );
+
+ my $update = Open311::GetServiceRequestUpdates->new(
+ system_user => $user,
+ suppress_alerts => $test->{suppress_alerts},
+ );
+
+ my $council_details = { areaid => 2482 };
+ $update->update_comments( $o, $council_details );
+ $problem->discard_changes;
+
+ my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->search(
+ {
+ alert_id => $alert->id,
+ parameter => $problem->comments->first->id,
+ }
+ );
+
+ if ( $test->{suppress_alerts} ) {
+ ok $alerts_sent->count(), 'alerts suppressed';
+ } else {
+ is $alerts_sent->count(), 0, 'alerts not suppressed';
+ }
+
+ $alerts_sent->delete;
+ $alert->delete;
+ }
+}
+
$problem2->comments->delete();
$problem->comments->delete();
$problem2->delete;