aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-09-12 13:25:34 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-09-13 15:12:12 +0100
commit90da7da99ceddc57f70e678a6f56579f1c89197f (patch)
tree4b2d9919ea50526f2daa34daabfff4f4b1df506e /t
parent847ea6f773ddb5ba921ee1d9f1a0db4799687b1d (diff)
Add hook for per-row questionnaire override.
Diffstat (limited to 't')
-rw-r--r--t/app/model/questionnaire.t39
1 files changed, 37 insertions, 2 deletions
diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t
index 169895f95..d01185375 100644
--- a/t/app/model/questionnaire.t
+++ b/t/app/model/questionnaire.t
@@ -1,3 +1,14 @@
+package FixMyStreet::Cobrand::Tester;
+
+use parent 'FixMyStreet::Cobrand::Default';
+
+sub send_questionnaire {
+ my ($self, $row) = @_;
+ return $row->latitude == 1;
+}
+
+package main;
+
use FixMyStreet;
use FixMyStreet::TestMech;
@@ -27,7 +38,7 @@ my $problem = FixMyStreet::DB->resultset('Problem')->create(
my $mech = FixMyStreet::TestMech->new;
-for my $test (
+for my $test (
{
state => 'unconfirmed',
send_email => 0,
@@ -89,7 +100,7 @@ for my $test (
send_email => 1,
},
) {
- subtest "correct questionnaire behviour for state $test->{state}" => sub {
+ subtest "correct questionnaire behaviour for state $test->{state}" => sub {
$problem->discard_changes;
$problem->state( $test->{state} );
$problem->send_questionnaire( 1 );
@@ -108,4 +119,28 @@ for my $test (
}
}
+for my $test (
+ { latitude => 2, emails => 0, },
+ { latitude => 1, emails => 1, },
+) {
+ subtest "test cobrand questionnaire send override, expecting $test->{emails} email" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'tester',
+ }, sub {
+ $problem->latitude($test->{latitude});
+ $problem->send_questionnaire(1);
+ $problem->update;
+ $problem->questionnaires->delete;
+
+ $mech->email_count_is(0);
+ FixMyStreet::DB->resultset('Questionnaire')->send_questionnaires( { site => 'tester' } );
+ $mech->email_count_is($test->{emails});
+ $mech->clear_emails_ok();
+
+ $problem->discard_changes;
+ is $problem->send_questionnaire, 0;
+ };
+ };
+}
+
done_testing();