aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model/responsetemplate.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/model/responsetemplate.t')
-rw-r--r--t/app/model/responsetemplate.t8
1 files changed, 5 insertions, 3 deletions
diff --git a/t/app/model/responsetemplate.t b/t/app/model/responsetemplate.t
index 9efc7e3b4..29c41a0e0 100644
--- a/t/app/model/responsetemplate.t
+++ b/t/app/model/responsetemplate.t
@@ -1,3 +1,4 @@
+use utf8;
use FixMyStreet::TestMech;
use JSON::MaybeXS;
@@ -7,7 +8,7 @@ my $area_id = 2651;
my $body = $mech->create_body_ok($area_id, 'Edinburgh Council');
my $c1 = $mech->create_contact_ok(category => 'Potholes', body_id => $body->id, email => 'p');
my $c2 = $mech->create_contact_ok(category => 'Graffiti', body_id => $body->id, email => 'g');
-my $t1 = FixMyStreet::DB->resultset('ResponseTemplate')->create({ body_id => $body->id, title => "Title 1", text => "Text 1" });
+my $t1 = FixMyStreet::DB->resultset('ResponseTemplate')->create({ body_id => $body->id, title => "Title 1", text => "Text 1 ⛄" });
my $t2 = FixMyStreet::DB->resultset('ResponseTemplate')->create({ body_id => $body->id, title => "Title 2", text => "Text 2", state => 'investigating' });
my $t3 = FixMyStreet::DB->resultset('ResponseTemplate')->create({ body_id => $body->id, title => "Title 3", text => "Text 3" });
$t1->add_to_contacts($c1);
@@ -17,12 +18,13 @@ my @contacts = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { bod
subtest 'by_categories returns allresponse templates grouped by category' => sub {
my $templates = FixMyStreet::DB->resultset('ResponseTemplate')->by_categories(\@contacts, body_id => $body->id);
- my $potholes = decode_json($templates->{Potholes});
- my $graffiti = decode_json($templates->{Graffiti});
+ my $potholes = JSON::MaybeXS->new->decode($templates->{Potholes});
+ my $graffiti = JSON::MaybeXS->new->decode($templates->{Graffiti});
is scalar @$potholes, 2, 'Potholes have 2 templates';
is scalar @$graffiti, 2, 'Graffiti has 2 templates';
is $graffiti->[0]->{state}, 'investigating', 'Graffiti first template has right state';
+ is $potholes->[0]->{id}, 'Text 1 ⛄', 'Pothole first template has right text';
};
done_testing;