aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm2
-rw-r--r--t/cobrand/oxfordshire.t44
2 files changed, 45 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index 3d2d784b8..14d6ec479 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -97,7 +97,7 @@ sub send() {
!( $last_problem_state eq '' && $row->{item_problem_state} eq 'confirmed' ) &&
$last_problem_state ne $row->{item_problem_state}
) {
- my $state = FixMyStreet::DB->resultset("State")->display($row->{item_problem_state}, 1, $cobrand);
+ my $state = FixMyStreet::DB->resultset("State")->display($row->{item_problem_state}, 1, $cobrand->moniker);
my $update = _('State changed to:') . ' ' . $state;
$row->{item_text} = $row->{item_text} ? $row->{item_text} . "\n\n" . $update :
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index b8422a28b..dd5eedc8d 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -1,6 +1,7 @@
use Test::MockModule;
use FixMyStreet::TestMech;
+use FixMyStreet::Script::Alerts;
my $mech = FixMyStreet::TestMech->new;
my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
@@ -61,6 +62,49 @@ subtest 'can use customer reference to search for reports' => sub {
};
};
+my $user = $mech->create_user_ok( 'user@example.com', name => 'Test User' );
+my $user2 = $mech->create_user_ok( 'user2@example.com', name => 'Test User2' );
+
+subtest 'check unable to fix label' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ my $problem = $problems[0];
+ $problem->state( 'unable to fix' );
+ $problem->update;
+
+ my $alert = FixMyStreet::DB->resultset('Alert')->create( {
+ parameter => $problem->id,
+ alert_type => 'new_updates',
+ cobrand => 'oxfordshire',
+ user => $user,
+ } )->confirm;
+
+ FixMyStreet::DB->resultset('Comment')->create( {
+ problem_state => 'unable to fix',
+ problem_id => $problem->id,
+ user_id => $user2->id,
+ name => 'User',
+ mark_fixed => 'f',
+ text => "this is an update",
+ state => 'confirmed',
+ confirmed => 'now()',
+ anonymous => 'f',
+ } );
+
+
+ $mech->get_ok('/report/' . $problem->id);
+ $mech->content_contains('Investigation complete');
+
+ FixMyStreet::Script::Alerts::send();
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ my $body = $mech->get_text_body_from_email($email);
+ like $body, qr/Investigation complete/, 'state correct in email';
+ };
+};
+
END {
done_testing();
}