aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/app/controller/report_inspect.t6
-rw-r--r--t/open311/getservicerequests.t70
3 files changed, 75 insertions, 2 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index 8dd10c53d..1e94bb3e6 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -30,6 +30,7 @@ my @PLACES = (
[ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ],
+ [ 'BR1 3UH', 51.402096, 0.015784, 2482, 'Bromley Council', 'LBO' ],
[ '?', 50.78301, -0.646929 ],
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],
[ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ],
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 39dd57444..5447c744e 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -613,7 +613,11 @@ FixMyStreet::override_config {
subtest "test saved-at setting" => sub {
$report->comments->delete;
$mech->get_ok("/report/$report_id");
- my $now = DateTime->now->subtract(days => 1);
+ # set the timezone on this so the date comparison below doesn't fail due to mismatched
+ # timezones
+ my $now = DateTime->now(
+ time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone
+ )->subtract(days => 1);
$mech->submit_form(button => 'save', form_id => 'report_inspect_form',
fields => { include_update => 1, public_update => 'An update', saved_at => $now->epoch });
$report->discard_changes;
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t
index 878c178ef..f8795bd61 100644
--- a/t/open311/getservicerequests.t
+++ b/t/open311/getservicerequests.t
@@ -6,6 +6,7 @@ use_ok( 'Open311' );
use_ok( 'Open311::GetServiceRequests' );
use DateTime;
use DateTime::Format::W3CDTF;
+use Test::MockObject::Extends;
my $mech = FixMyStreet::TestMech->new;
@@ -151,7 +152,6 @@ for my $test (
};
my $after_count = FixMyStreet::DB->resultset('Problem')->count;
- warn $count;
is $count, $after_count, "problems not created";
my $with_text = FixMyStreet::DB->resultset('Problem')->search( {
@@ -258,6 +258,74 @@ for my $test (
};
}
+for my $test (
+ {
+ desc => 'convert easting/northing to lat/long',
+ subs => { lat => 168935, long => 540315 },
+ expected => { lat => 51.402096, long => 0.015784 },
+ },
+) {
+ subtest $test->{desc} => sub {
+ my $xml = prepare_xml( $test->{subs} );
+ my $o = Open311->new(
+ jurisdiction => 'mysociety',
+ endpoint => 'http://example.com',
+ test_mode => 1,
+ test_get_returns => { 'requests.xml' => $xml}
+ );
+
+ my $update = Open311::GetServiceRequests->new(
+ system_user => $user,
+ convert_latlong => 1,
+ );
+
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $update->create_problems( $o, $body );
+ };
+
+ my $p = FixMyStreet::DB->resultset('Problem')->search(
+ { external_id => 123456 }
+ )->first;
+
+ ok $p, 'problem created';
+ is $p->latitude, $test->{expected}->{lat}, 'correct latitude';
+ is $p->longitude, $test->{expected}->{long}, 'correct longitude';
+
+ $p->delete;
+ };
+}
+
+subtest "check options passed through from body" => sub {
+ my $xml = prepare_xml( {} );
+
+ $body->update( {
+ send_method => 'Open311',
+ fetch_problems => 1,
+ comment_user_id => $user->id,
+ endpoint => 'http://open311.localhost/',
+ convert_latlong => 1,
+ api_key => 'KEY',
+ jurisdiction => 'test',
+ } );
+
+ my $o = Open311::GetServiceRequests->new();
+
+ my $props = {};
+
+ $o = Test::MockObject::Extends->new($o);
+ $o->mock('create_problems', sub {
+ my $self = shift;
+
+ $props->{convert_latlong} = $self->convert_latlong;
+ } );
+
+ $o->fetch();
+
+ ok $props->{convert_latlong}, "convert latlong set"
+};
+
sub prepare_xml {
my $replacements = shift;