aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/State.pm4
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm18
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm5
-rw-r--r--t/cobrand/isleofwight.t3
-rw-r--r--t/cobrand/tfl.t42
6 files changed, 54 insertions, 24 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index 99c5b6dab..bac183271 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -278,7 +278,11 @@ sub problem_state_display {
return '' unless $state;
my $cobrand_name = $c->cobrand->moniker;
- $cobrand_name = 'bromley' if $self->problem->to_body_named('Bromley');
+ my $names = join(',,', @{$self->problem->body_names});
+ if ($names =~ /(Bromley|Isle of Wight|TfL)/) {
+ ($cobrand_name = lc $1) =~ s/ //g;
+ }
+
return FixMyStreet::DB->resultset("State")->display($state, 1, $cobrand_name);
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/State.pm b/perllib/FixMyStreet/DB/ResultSet/State.pm
index cb894005f..4f98efbf2 100644
--- a/perllib/FixMyStreet/DB/ResultSet/State.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/State.pm
@@ -1,6 +1,7 @@
package FixMyStreet::DB::ResultSet::State;
use base 'DBIx::Class::ResultSet';
+use utf8;
use strict;
use warnings;
use Memcached;
@@ -74,7 +75,8 @@ sub display {
return $unchanging->{$label} if $unchanging->{$label};
if ($cobrand && $label eq 'not responsible') {
return 'third party responsibility' if $cobrand eq 'bromley';
- return "not Island Roads' responsibility" if $cobrand eq 'isleofwight';
+ return "not Island Roads’ responsibility" if $cobrand eq 'isleofwight';
+ return "not TfL’s responsibility" if $cobrand eq 'tfl';
return _("not the council's responsibility");
}
if ($cobrand && $cobrand eq 'oxfordshire' && $label eq 'unable to fix') {
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 9725f1781..73c179751 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -46,6 +46,9 @@ sub send(;$) {
my $cobrand = $row->get_cobrand_logged;
FixMyStreet::DB->schema->cobrand($cobrand);
+ # Also get a cobrand that handles where a report is going
+ my $cobrand_handler = $cobrand->call_hook(get_body_handler_for_problem => $row) || $cobrand;
+
if ($debug_mode) {
$debug_unsent_count++;
print "\n";
@@ -62,7 +65,7 @@ sub send(;$) {
}
$cobrand->set_lang_and_domain($row->lang, 1);
- FixMyStreet::Map::set_map_class($cobrand->map_type);
+ FixMyStreet::Map::set_map_class($cobrand_handler->map_type);
if ( $row->is_from_abuser) {
$row->update( { state => 'hidden' } );
debug_print("hiding because its sender is flagged as an abuser", $row->id) if $debug_mode;
@@ -74,7 +77,7 @@ sub send(;$) {
}
# Template variables for the email
- my $email_base_url = $cobrand->base_url_for_report($row);
+ my $email_base_url = $cobrand_handler->base_url_for_report($row);
my %h = map { $_ => $row->$_ } qw/id title detail name category latitude longitude used_map/;
$h{report} = $row;
$h{cobrand} = $cobrand;
@@ -84,7 +87,7 @@ sub send(;$) {
$h{query} = $row->postcode;
$h{url} = $email_base_url . $row->url;
- $h{admin_url} = $row->admin_url($cobrand);
+ $h{admin_url} = $row->admin_url($cobrand_handler);
if ($row->photo) {
$h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n";
$h{image_url} = $email_base_url . $row->photos->[0]->{url_full};
@@ -126,19 +129,12 @@ sub send(;$) {
$missing = join(' / ', @missing) if @missing;
}
- my $send_confirmation_email = $cobrand->report_sent_confirmation_email;
+ my $send_confirmation_email = $cobrand_handler->report_sent_confirmation_email;
my @dear;
my %reporters = ();
my $skip = 0;
while (my $body = $bodies->next) {
- # See if this body wants confirmation email (in case report made on national site, for example)
- if (my $cobrand_body = $body->get_cobrand_handler) {
- if (my $id_ref = $cobrand_body->report_sent_confirmation_email) {
- $send_confirmation_email = $id_ref;
- }
- }
-
my $sender_info = $cobrand->get_body_sender( $body, $row->category );
my $sender = "FixMyStreet::SendReport::" . $sender_info->{method};
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index 80b60b381..ffff43472 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -106,7 +106,10 @@ sub send {
}
my $result = FixMyStreet::Email::send_cron($row->result_source->schema,
- $self->get_template($row), $h,
+ $self->get_template($row), {
+ %$h,
+ cobrand => $cobrand, # For correct logo that uses cobrand object
+ },
$params, $sender, $nomail, $cobrand, $row->lang);
unless ($result) {
diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t
index bd837b3c6..0c985e2fb 100644
--- a/t/cobrand/isleofwight.t
+++ b/t/cobrand/isleofwight.t
@@ -1,3 +1,4 @@
+use utf8;
use CGI::Simple;
use DateTime;
use Test::MockModule;
@@ -425,7 +426,7 @@ subtest "check not responsible as correct text" => sub {
$mech->get_ok('/report/' . $p->id);
};
- $mech->content_contains("not Island Roads' responsibility", "not reponsible message contains correct text");
+ $mech->content_contains("not Island Roads’ responsibility", "not reponsible message contains correct text");
$p->comments->delete;
$p->delete;
};
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index 69b112323..a327a00ef 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -384,16 +384,16 @@ subtest "change category, report resent to new location" => sub {
};
for my $test (
- [ 'BR1 3UH', 'tfl.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ],
- [ 'BR1 3UH', 'www.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ],
- [ 'BR1 3UH', 'bromley.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team' ],
- [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team' ],
- [ 'TW7 5JN', 'www.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team' ],
- [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address' ],
- [ 'TW7 5JN', 'www.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address' ],
+ [ 'BR1 3UH', 'tfl.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', 'reference number is FMS' ],
+ [ 'BR1 3UH', 'www.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', 'reference number is' ],
+ [ 'BR1 3UH', 'bromley.fixmystreet.com', 'Trees', 'TfL <bromley@example.com>', 'Bromley borough team', '' ],
+ [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team', 'reference number is FMS' ],
+ [ 'TW7 5JN', 'www.fixmystreet.com', 'Trees', 'TfL <hounslow@example.com>', 'Hounslow borough team', 'reference number is' ],
+ [ 'TW7 5JN', 'tfl.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address', 'reference number is FMS' ],
+ [ 'TW7 5JN', 'www.fixmystreet.com', 'Grit bins', 'TfL <hounslow@example.com>, TfL <gritbins@example.com>', 'Hounslow borough team and additional address', 'reference number is' ],
) {
- my ($postcode, $host, $category, $to, $name ) = @$test;
- subtest "test report is sent to $name" => sub {
+ my ($postcode, $host, $category, $to, $name, $ref ) = @$test;
+ subtest "test report is sent to $name on $host" => sub {
$mech->host($host);
$mech->log_in_ok( $user->email );
$mech->get_ok('/around');
@@ -422,6 +422,9 @@ for my $test (
FixMyStreet::Script::Reports::send();
my @email = $mech->get_email;
is $email[0]->header('To'), $to, 'Sent to correct address';
+ like $email[0]->as_string, qr/iEYI87gX6Upb\+tKYzrSmN83pTnv606AOtahHTepSm/, 'Right logo';
+ like $mech->get_text_body_from_email($email[0]), qr/https:\/\/street.tfl/, 'Correct link';
+ like $mech->get_text_body_from_email($email[1]), qr/$ref/, "Correct reference number in reporter email" if $ref;
$mech->clear_emails_ok;
FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report for borough team'})->delete;
};
@@ -826,6 +829,27 @@ FixMyStreet::override_config {
};
FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet', 'tfl' ],
+ MAPIT_URL => 'http://mapit.uk/'
+}, sub {
+ foreach (qw(tfl.fixmystreet.com fixmystreet.com)) {
+ $mech->host($_);
+ my ($p) = $mech->create_problems_for_body(1, $body->id, 'NotResp');
+ my $c = FixMyStreet::DB->resultset('Comment')->create({
+ problem => $p, user => $p->user, anonymous => 't', text => 'Update text',
+ problem_state => 'not responsible', state => 'confirmed', mark_fixed => 0,
+ confirmed => DateTime->now(),
+ });
+ subtest "check not responsible as correct text on $_" => sub {
+ $mech->get_ok('/report/' . $p->id);
+ $mech->content_contains("not TfL’s responsibility", "not reponsible message contains correct text");
+ };
+ $p->comments->delete;
+ $p->delete;
+ }
+};
+
+FixMyStreet::override_config {
ALLOWED_COBRANDS => 'bromley',
MAPIT_URL => 'http://mapit.uk/'
}, sub {