Skip to content

Commit

Permalink
[Bromley] Reset category override once sent.
Browse files Browse the repository at this point in the history
Otherwise, a later resending will still use the override category.
  • Loading branch information
dracos committed Nov 11, 2024
1 parent bb5576f commit a7366f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
1 change: 1 addition & 0 deletions perllib/FixMyStreet/SendReport/Open311.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ sub send {
$row->discard_changes;

if ( $skip || $resp ) {
$row->unset_extra_metadata('open311_category_override'); # If we were overridden, we don't want to keep that for future
$row->update({ external_id => $resp });
$self->success( 1 );
} else {
Expand Down
44 changes: 25 additions & 19 deletions t/cobrand/bromley.t
Original file line number Diff line number Diff line change
Expand Up @@ -891,25 +891,16 @@ subtest 'redirecting of reports between backends' => sub {
});
$report->cobrand_data('waste');
$report->update;
FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',
}, sub {
my $updates = Open311::PostServiceRequestUpdates->new();
$updates->send;
};
my $updates = Open311::PostServiceRequestUpdates->new();
$updates->send;

$comment->discard_changes;
is $comment->send_state, 'unprocessed', "did not send";

$comment->update({ send_fail_count => 0 });
$report->update({ cobrand_data => '' });

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',
}, sub {
my $updates = Open311::PostServiceRequestUpdates->new();
$updates->send;
};
$updates->send;

$report->discard_changes;
is $report->get_extra_metadata('open311_category_override'), 'Street Services', 'category override applied';
Expand All @@ -920,13 +911,7 @@ subtest 'redirecting of reports between backends' => sub {
$comment->discard_changes;
is $comment->send_state, 'skipped', "skipped sending comment";

FixMyStreet::override_config {
STAGING_FLAGS => { send_reports => 1 },
ALLOWED_COBRANDS => [ 'bromley' ],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
FixMyStreet::Script::Reports::send();
};
FixMyStreet::Script::Reports::send();

$report->discard_changes;
is $report->send_state, 'sent', 'report was resent';
Expand All @@ -949,6 +934,27 @@ subtest 'redirecting of reports between backends' => sub {
my $comment = FixMyStreet::DB->resultset("Comment")->search(undef, { order_by => { -desc => 'id' } })->first;
is $comment->text, 'Template text';
};

subtest "Echo then redirect it back to Confirm" => sub {
my $in = $mech->echo_notify_xml('guid', 2104, 15004, 1252);
$mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in);
is $report->comments->count, 4, 'A new update';
$report->discard_changes;
is $report->state, 'in progress', 'A state change';
is $report->get_extra_metadata('external_status_code'), 1252;
my $comment = FixMyStreet::DB->resultset("Comment")->search(undef, { order_by => { -desc => 'id' } })->first;
is $comment->text, 'Completed';

FixMyStreet::Script::Reports::send();

$report->discard_changes;
is $report->send_state, 'sent', 'report was resent';

my $req = Open311->test_req_used;
my $c = CGI::Simple->new($req->content);
is $c->param('service_code'), 'LBB_RRE_FROM_VEOLIA_STREETS';
};

};
};

Expand Down

0 comments on commit a7366f4

Please sign in to comment.