diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Queue/Item/Report.pm | 2 | ||||
-rw-r--r-- | t/app/controller/waste.t | 14 | ||||
-rw-r--r-- | templates/email/bromley/confirm_report_sent.html | 1 | ||||
-rw-r--r-- | templates/email/bromley/confirm_report_sent.txt | 1 |
6 files changed, 23 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 98ebd4972..f64a109e8 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -1676,7 +1676,7 @@ sub redirect_or_confirm_creation : Private { $c->forward( 'create_related_things' ); if ($c->stash->{contributing_as_another_user} && $report->user->email && $report->user->id != $c->user->id - && !$c->cobrand->report_sent_confirmation_email) { + && !$c->cobrand->report_sent_confirmation_email($report)) { $c->send_email( 'other-reported.txt', { to => [ [ $report->user->email, $report->name ] ], } ); diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 176762323..5fc03eb81 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -379,6 +379,14 @@ sub munge_load_and_group_problems { } } +# We want to send confirmation emails only for Waste reports +sub report_sent_confirmation_email { + my ($self, $report) = @_; + my $contact = $report->contact or return; + return 'id' if grep { $_ eq 'Waste' } @{$report->contact->groups}; + return ''; +} + sub munge_around_category_where { my ($self, $where) = @_; $where->{extra} = [ undef, { -not_like => '%Waste%' } ]; diff --git a/perllib/FixMyStreet/Queue/Item/Report.pm b/perllib/FixMyStreet/Queue/Item/Report.pm index 60e9ad3dc..070b244bb 100644 --- a/perllib/FixMyStreet/Queue/Item/Report.pm +++ b/perllib/FixMyStreet/Queue/Item/Report.pm @@ -243,7 +243,7 @@ sub _send { sub _post_send { my ($self, $result) = @_; - my $send_confirmation_email = $self->cobrand_handler->report_sent_confirmation_email; + my $send_confirmation_email = $self->cobrand_handler->report_sent_confirmation_email($self->report); unless ($result) { $self->report->update( { whensent => \'current_timestamp', diff --git a/t/app/controller/waste.t b/t/app/controller/waste.t index 85536981b..9c7b9a3ac 100644 --- a/t/app/controller/waste.t +++ b/t/app/controller/waste.t @@ -2,6 +2,7 @@ use utf8; use Test::MockModule; use Test::MockTime qw(:all); use FixMyStreet::TestMech; +use FixMyStreet::Script::Reports; FixMyStreet::App->log->disable('info'); END { FixMyStreet::App->log->enable('info'); } @@ -30,17 +31,18 @@ sub create_contact { $contact->update; } -create_contact({ category => 'Report missed collection', email => 'missed' }); -create_contact({ category => 'Request new container', email => 'request' }, +create_contact({ category => 'Report missed collection', email => 'missed@example.org' }); +create_contact({ category => 'Request new container', email => 'request@example.org' }, { code => 'Quantity', required => 1, automated => 'hidden_field' }, { code => 'Container_Type', required => 1, automated => 'hidden_field' }, ); -create_contact({ category => 'General enquiry', email => 'general' }, +create_contact({ category => 'General enquiry', email => 'general@example.org' }, { code => 'Notes', description => 'Notes', required => 1, datatype => 'text' }); FixMyStreet::override_config { ALLOWED_COBRANDS => ['bromley', 'fixmystreet'], COBRAND_FEATURES => { echo => { bromley => { sample_data => 1 } }, waste => { bromley => 1 } }, + MAPIT_URL => 'http://mapit.uk/', }, sub { $mech->host('bromley.fixmystreet.com'); subtest 'Missing address lookup' => sub { @@ -82,6 +84,12 @@ FixMyStreet::override_config { $mech->content_contains($user->email); $mech->submit_form_ok({ with_fields => { process => 'summary' } }); $mech->content_contains('Your report has been sent'); + FixMyStreet::Script::Reports::send(); + my @emails = $mech->get_email; + is $emails[0]->header('To'), '"Bromley Council" <missed@example.org>'; + is $emails[1]->header('To'), $user->email; + my $body = $mech->get_text_body_from_email($emails[1]); + like $body, qr/Your report to Bromley Council has been logged/; is $user->alerts->count, 1; }; diff --git a/templates/email/bromley/confirm_report_sent.html b/templates/email/bromley/confirm_report_sent.html new file mode 100644 index 000000000..5a0c19f0d --- /dev/null +++ b/templates/email/bromley/confirm_report_sent.html @@ -0,0 +1 @@ +[% INCLUDE 'other-reported.html' %]
\ No newline at end of file diff --git a/templates/email/bromley/confirm_report_sent.txt b/templates/email/bromley/confirm_report_sent.txt new file mode 100644 index 000000000..72fe01f6d --- /dev/null +++ b/templates/email/bromley/confirm_report_sent.txt @@ -0,0 +1 @@ +[% INCLUDE 'other-reported.txt' %]
\ No newline at end of file |