aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/peterborough.t
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand/peterborough.t')
-rw-r--r--t/cobrand/peterborough.t81
1 files changed, 80 insertions, 1 deletions
diff --git a/t/cobrand/peterborough.t b/t/cobrand/peterborough.t
index 5d07acb9f..f7e45f190 100644
--- a/t/cobrand/peterborough.t
+++ b/t/cobrand/peterborough.t
@@ -64,7 +64,7 @@ subtest "extra update params are sent to open311" => sub {
test_get_returns => { 'servicerequestupdates.xml' => $test_res },
);
- my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { external_id => 1, category => 'Trees' });
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { external_id => 1, category => 'Trees', whensent => DateTime->now });
my $c = FixMyStreet::DB->resultset('Comment')->create({
problem => $p, user => $p->user, anonymous => 't', text => 'Update text',
@@ -81,4 +81,83 @@ subtest "extra update params are sent to open311" => sub {
};
};
+subtest "bartec report with no gecode handled correctly" => sub {
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => 'peterborough',
+ }, sub {
+ my $contact = $mech->create_contact_ok(body_id => $peterborough->id, category => 'Bins', email => 'Bartec-Bins');
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { category => 'Bins', latitude => 52.5608, longitude => 0.2405, cobrand => 'peterborough' });
+
+ my $test_data = FixMyStreet::Script::Reports::send();
+
+ $p->discard_changes;
+ ok $p->whensent, 'Report marked as sent';
+
+ my $req = $test_data->{test_req_used};
+ my $cgi = CGI::Simple->new($req->content);
+ is $cgi->param('attribute[postcode]'), undef, 'postcode param not set';
+ is $cgi->param('attribute[house_no]'), undef, 'house_no param not set';
+ is $cgi->param('attribute[street]'), undef, 'street param not set';
+ };
+};
+
+subtest "extra bartec params are sent to open311" => sub {
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => 'peterborough',
+ }, sub {
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', {
+ category => 'Bins',
+ latitude => 52.5608,
+ longitude => 0.2405,
+ cobrand => 'peterborough',
+ geocode => {
+ resourceSets => [ {
+ resources => [ {
+ name => '12 A Street, XX1 1SZ',
+ address => {
+ addressLine => '12 A Street',
+ postalCode => 'XX1 1XZ'
+ }
+ } ]
+ } ]
+ },
+ extra => {
+ _fields => [
+ { name => 'site_code', value => '12345', },
+ ],
+ },
+ } );
+
+ my $test_data = FixMyStreet::Script::Reports::send();
+
+ $p->discard_changes;
+ ok $p->whensent, 'Report marked as sent';
+
+ my $req = $test_data->{test_req_used};
+ my $cgi = CGI::Simple->new($req->content);
+ is $cgi->param('attribute[postcode]'), 'XX1 1XZ', 'postcode param sent';
+ is $cgi->param('attribute[house_no]'), '12', 'house_no param sent';
+ is $cgi->param('attribute[street]'), 'A Street', 'street param sent';
+ };
+};
+
+subtest 'Dashboard CSV extra columns' => sub {
+ my $staffuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User',
+ from_body => $peterborough, password => 'password');
+ $mech->log_in_ok( $staffuser->email );
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => 'peterborough',
+ }, sub {
+ $mech->get_ok('/dashboard?export=1');
+ };
+ $mech->content_contains('"Reported As",USRN,"Nearest address"');
+ $mech->content_contains('peterborough,,12345,"12 A Street, XX1 1SZ"');
+};
+
+
done_testing;