aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/alert.t22
-rw-r--r--t/app/controller/alert_new.t2
-rw-r--r--t/app/model/responsetemplate.t8
3 files changed, 29 insertions, 3 deletions
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index 41aee5bbc..34e68177c 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -1,6 +1,7 @@
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
+use Test::MockModule;
use t::Mock::Nominatim;
# check that we can get the page
@@ -73,4 +74,25 @@ FixMyStreet::override_config {
is $mech->uri->path, '/rss/reports/Cheltenham/Lansdown';
};
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'fixmystreet',
+ MAPIT_URL => 'http://mapit.uk/',
+ GEOCODER => '',
+ RECAPTCHA => { secret => 'secret', site_key => 'site_key' },
+}, sub {
+ subtest 'recaptcha' => sub {
+ $mech->get_ok('/alert/list?pc=EH11BB');
+ $mech->content_lacks('g-recaptcha'); # GB is default test country
+
+ my $mod_app = Test::MockModule->new('FixMyStreet::App');
+ $mod_app->mock('user_country', sub { 'FR' });
+ my $mod_lwp = Test::MockModule->new('LWP::UserAgent');
+ $mod_lwp->mock('post', sub { HTTP::Response->new(200, 'OK', [], '{ "success": true }') });
+
+ $mech->get_ok('/alert/list?pc=EH11BB');
+ $mech->content_contains('g-recaptcha');
+ $mech->submit_form_ok({ with_fields => { rznvy => 'someone@example.org' } });
+ };
+};
+
done_testing();
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 7eba90530..d968b56b1 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -523,6 +523,8 @@ subtest "Test alerts are not sent for no-text updates" => sub {
};
$mech->email_count_is(1);
+ $user2->discard_changes;
+ isnt $user2->last_active, undef, 'Last active has been set';
$mech->delete_user($user1);
$mech->delete_user($user2);
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;