aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2020-04-01 13:47:38 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-04-03 11:01:10 +0100
commit4590344c558a925408499be5a977b1ed94a22b1b (patch)
tree0d827a51f9633d21cbacd0037c64eea89fada2a3
parentd44c06c213bc73632893ab58421ab98b7058b913 (diff)
[HE] add a how did you hear about us question
-rw-r--r--perllib/FixMyStreet/Cobrand/HighwaysEngland.pm4
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/cobrand/highwaysengland.t53
-rw-r--r--templates/email/highwaysengland/submit.html4
-rw-r--r--templates/email/highwaysengland/submit.txt2
-rw-r--r--templates/web/highwaysengland/report/new/inline-tips.html13
6 files changed, 77 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
index d415635c1..54b0d09e3 100644
--- a/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
+++ b/perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
@@ -36,6 +36,10 @@ sub admin_allow_user {
return $user->from_body->name eq 'Highways England';
}
+sub report_form_extras {
+ ( { name => 'where_hear' } )
+}
+
sub enter_postcode_text { 'Enter a location, road name or postcode' }
sub example_places {
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index 3cbaec3b9..d49294a6a 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -43,6 +43,7 @@ my @PLACES = (
[ 'NN1 1NS', 52.236251, -0.892052, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ 'NN1 2NS', 52.238301, -0.889992, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ '?', 52.238827, -0.894970, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
+ [ '?', 52.23025, -1.015826, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ 'TW7 5JN', 51.482286, -0.328163, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.48111, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
[ '?', 51.482045, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ],
diff --git a/t/cobrand/highwaysengland.t b/t/cobrand/highwaysengland.t
index 3c7632563..f6400ea7c 100644
--- a/t/cobrand/highwaysengland.t
+++ b/t/cobrand/highwaysengland.t
@@ -1,11 +1,21 @@
use FixMyStreet::TestMech;
use FixMyStreet::App;
+use FixMyStreet::Script::Reports;
+use FixMyStreet::Cobrand::HighwaysEngland;
+use HighwaysEngland;
+use Test::MockModule;
+
+my $he_mock = Test::MockModule->new('HighwaysEngland');
+$he_mock->mock('database_file', sub { FixMyStreet->path_to('t/geocode/roads.sqlite'); });
# disable info logs for this test run
FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }
+my $he_mock_cobrand = Test::MockModule->new('FixMyStreet::Cobrand::HighwaysEngland');
+$he_mock_cobrand->mock('anonymous_account', sub { { email => 'anoncategory@example.org', name => 'Anonymous Category' } });
+
my $he = FixMyStreet::Cobrand::HighwaysEngland->new();
my $r = $he->geocode_postcode('M1');
@@ -14,4 +24,47 @@ ok $r->{error}, "searching for road only generates error";
$r = $he->geocode_postcode('m1');
ok $r->{error}, "searching for lowecase road only generates error";
+my $mech = FixMyStreet::TestMech->new;
+my $highways = $mech->create_body_ok(2234, 'Highways England');
+
+$mech->create_contact_ok(email => 'highways@example.com', body_id => $highways->id, category => 'Pothole');
+
+# Br1 3UH
+subtest "check where heard from saved" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'highwaysengland',
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( { with_fields => { pc => 'M1, J16', } }, "submit location" );
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
+ $mech->submit_form_ok(
+ {
+ button => 'report_anonymously',
+ with_fields => {
+ title => "Test Report for HE",
+ detail => 'Test report details.',
+ category => 'Pothole',
+ where_hear => 'Facebook',
+ }
+ },
+ "submit good details"
+ );
+ $mech->content_contains('Thank you');
+
+ my $report = FixMyStreet::DB->resultset("Problem")->first;
+ ok $report, "Found the report";
+ is $report->get_extra_metadata('where_hear'), 'Facebook', 'saved where hear';
+
+ $mech->clear_emails_ok;
+ FixMyStreet::Script::Reports::send();
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ like $mech->get_text_body_from_email($email), qr/Heard from: Facebook/, 'where hear included in email'
+
+ };
+};
+
+
done_testing();
diff --git a/templates/email/highwaysengland/submit.html b/templates/email/highwaysengland/submit.html
index ca35a782c..a5c17c694 100644
--- a/templates/email/highwaysengland/submit.html
+++ b/templates/email/highwaysengland/submit.html
@@ -40,6 +40,10 @@ of a local problem that they believe might require your attention.</p>
<strong>Section:</strong>
[% report.get_extra_field_value('sect_label') %]
</p>
+ <p style="[% secondary_p_style %]">
+ <strong>Heard from:</strong>
+ [% report.get_extra_metadata('where_hear') %]
+ </p>
[% END %]
diff --git a/templates/email/highwaysengland/submit.txt b/templates/email/highwaysengland/submit.txt
index c050fb7b2..aa32bd1be 100644
--- a/templates/email/highwaysengland/submit.txt
+++ b/templates/email/highwaysengland/submit.txt
@@ -27,6 +27,8 @@ Road: [% report.get_extra_field_value('road_name') %]
Section: [% report.get_extra_field_value('sect_label') %]
+Heard from: [% report.get_extra_metadata('where_hear') %]
+
View OpenStreetMap of this location: [% osm_url %]
[% closest_address %]----------
diff --git a/templates/web/highwaysengland/report/new/inline-tips.html b/templates/web/highwaysengland/report/new/inline-tips.html
new file mode 100644
index 000000000..ff0ef42f8
--- /dev/null
+++ b/templates/web/highwaysengland/report/new/inline-tips.html
@@ -0,0 +1,13 @@
+<label for="where_hear">How did you hear about us?</label>
+
+[%~ SET where_hear = report.get_extra_metadata('where_hear') %]
+<select class="form-control" name="where_hear" id="where_hear">
+<option value="">[% loc('-- Pick an option --') %]</option>
+<option value="Facebook"[% ' selected' IF 'Facebook' == where_hear %]>Facebook</option>
+<option value="Search engine"[% ' selected' IF 'Search engine' == where_hear %]>Search engine</option>
+<option value="Highways England website"[% ' selected' IF 'Highways England website' == where_hear %]>Highways England website</option>
+<option value="Twitter"[% ' selected' IF 'Twitter' == where_hear %]>Twitter</option>
+<option value="Word of mouth"[% ' selected' IF 'Word of mouth' == where_hear %]>Word of mouth</option>
+<option value="Through the post"[% ' selected' IF 'Through the post' == where_hear %]>Through the post</option>
+<option value="Other"[% ' selected' IF 'Other' == where_hear %]>Other</option>
+</select>