diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/MapIt.pm | 1 | ||||
-rw-r--r-- | t/cobrand/highwaysengland.t | 53 |
2 files changed, 54 insertions, 0 deletions
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(); |