diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-01 16:51:48 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-06-20 12:57:12 +0100 |
commit | 67ef55d16668102724fc23d2d95dcbc9705afed1 (patch) | |
tree | edc9b29c7f17b9e5a71d8cc1a80d274ba2984a34 /t/open311 | |
parent | 1aeca7c6130aa6de377c8e00e8d22ae05943e919 (diff) |
[Open311] Allow description in email template.
By specifying a placeholder in an email template, it can be replaced
by the description returned from the Open311 server.
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/getservicerequestupdates.t | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 130b618c9..3cb2fda69 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -144,7 +144,7 @@ sub create_problem { detail => '', used_map => 1, user_id => 1, - name => '', + name => 'Test User', state => 'confirmed', service => '', cobrand => 'default', @@ -453,6 +453,37 @@ for my $test ( }; } +my $response_template_vars = $bodies{2482}->response_templates->create({ + title => "a placeholder action scheduled template", + text => "We are investigating this report: {{description}}", + auto_response => 1, + state => "action scheduled" +}); +subtest 'Check template placeholders' => sub { + my $local_requests_xml = setup_xml($problem->external_id, $problem->id, 'ACTION_SCHEDULED', 'We will do this in the morning.'); + my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', extended_statuses => undef, test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } ); + + $problem->lastupdate( DateTime->now()->subtract( days => 1 ) ); + $problem->state( 'fixed - council' ); + $problem->update; + + my $update = Open311::GetServiceRequestUpdates->new; + $update->fetch($o); + + is $problem->comments->count, 1, 'comment count'; + $problem->discard_changes; + + my $c = FixMyStreet::DB->resultset('Comment')->search( { external_id => 638344 } )->first; + ok $c, 'comment exists'; + is $c->text, "We are investigating this report: We will do this in the morning.", 'text correct'; + is $c->mark_fixed, 0, 'mark_closed correct'; + is $c->problem_state, 'action scheduled', 'problem_state correct'; + is $c->mark_open, 0, 'mark_open correct'; + is $c->state, 'confirmed', 'comment state correct'; + is $problem->state, 'action scheduled', 'correct problem state'; + $problem->comments->delete; +}; + my $problemB = create_problem($bodies{2237}->id); for my $test ( |