diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-28 15:52:02 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-28 15:52:02 +0100 |
commit | 6798a63297e4954344eefbf51147a971f30b58d2 (patch) | |
tree | aff6cf7bc8f3e6de3271dcaccd81cebd8276e44e /t/cobrand | |
parent | 323d3a632453bfcd10360fe2c2b9e4d684f350c8 (diff) | |
parent | 8c8b62e2b3a8af1b1f6fafe4080296a3826b7c1e (diff) |
Merge branch 'bexley'
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/bexley.t | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t new file mode 100644 index 000000000..e6f400e3d --- /dev/null +++ b/t/cobrand/bexley.t @@ -0,0 +1,64 @@ +use CGI::Simple; +use Test::MockModule; +use FixMyStreet::TestMech; +use FixMyStreet::Script::Reports; + +use_ok 'FixMyStreet::Cobrand::Bexley'; + +my $ukc = Test::MockModule->new('FixMyStreet::Cobrand::UKCouncils'); +$ukc->mock('lookup_site_code', sub { + my ($self, $row, $buffer) = @_; + is $row->latitude, 51.408484, 'Correct latitude'; + return "Road ID"; +}); + +my $cobrand = FixMyStreet::Cobrand::Bexley->new; +like $cobrand->contact_email, qr/bexley/; +is $cobrand->on_map_default_status, 'open'; +is_deeply $cobrand->disambiguate_location->{bounds}, [ 51.408484, 0.074653, 51.515542, 0.2234676 ]; + +my $mech = FixMyStreet::TestMech->new; + +my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', { + send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' }); +$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxed vehicles', email => "ABAN"); + +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'bexley' ], + MAPIT_URL => 'http://mapit.uk/', + STAGING_FLAGS => { send_reports => 1, skip_checks => 0 }, +}, sub { + + subtest 'cobrand displays council name' => sub { + ok $mech->host("bexley.fixmystreet.com"), "change host to bexley"; + $mech->get_ok('/'); + $mech->content_contains('Bexley'); + }; + + subtest 'cobrand displays council name' => sub { + $mech->get_ok('/reports/Bexley'); + $mech->content_contains('Bexley'); + }; + + my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', { + category => 'Abandoned and untaxed vehicles', cobrand => 'bexley', + latitude => 51.408484, longitude => 0.074653, + }); + $report->set_extra_fields({ 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' }); + $report->update; + + subtest 'Server-side NSGRef included' => sub { + my $test_data = FixMyStreet::Script::Reports::send(); + my $req = $test_data->{test_req_used}; + my $c = CGI::Simple->new($req->content); + is $c->param('service_code'), 'ABAN'; + is $c->param('attribute[NSGRef]'), 'Road ID'; + + my $email = $mech->get_email; + like $email->header('To'), qr/"Bexley P1 email".*bexley/; + like $mech->get_text_body_from_email($email), qr/NSG Ref: Road ID/; + }; + +}; + +done_testing(); |