aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-12-14 19:07:08 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-12-19 14:43:26 +0000
commitddf9dbdbf6486c781ca4a5822614b0b7cee2c062 (patch)
tree09c12affc3390138b03292d3f90810287b4941d0 /t
parentda29e8a75eaa92e98807ad89d29d3d1f3c01bc14 (diff)
Allow bodies to span multiple area IDs, and areas can be covered by more than one body.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/admin.t4
-rw-r--r--t/app/controller/report_new_open311.t12
-rw-r--r--t/app/model/problem.t16
-rw-r--r--t/app/sendreport/email.t3
-rw-r--r--t/cobrand/get_body_sender.t10
-rw-r--r--t/open311/getservicerequestupdates.t14
-rw-r--r--t/open311/populate-service-list.t5
7 files changed, 37 insertions, 27 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index d759c1238..d8b721ca9 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -259,7 +259,7 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Configuration updated - contacts will be generated automatically later');
my $open311 =
- FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } );
+ FixMyStreet::App->model('DB::Body')->search( { 'body_areas.area_id' => 2650 }, { join => 'body_areas' } );
is $open311->count, 1, 'only one configuration';
my $conf = $open311->first;
@@ -283,7 +283,7 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Configuration updated');
$open311 =
- FixMyStreet::App->model('DB::Body')->search( { area_id => 2650 } );
+ FixMyStreet::App->model('DB::Body')->search( { 'body_areas.area_id' => 2650 }, { join => 'body_areas' } );
is $open311->count, 1, 'only one configuration';
$conf = $open311->first;
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index e9ada9f41..22d2d1f97 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -7,12 +7,12 @@ use Web::Scraper;
my $mech = FixMyStreet::TestMech->new;
-FixMyStreet::App->model('DB::Body')->find_or_create( {
- area_id => 2651,
- endpoint => 'http://example.com/open311',
- jurisdiction => 'mySociety',
- api_key => 'apikey',
-} );
+my $body = $mech->create_body_ok(2651, 'City of Edinburgh Council');
+$body->update({
+ endpoint => 'http://example.com/open311',
+ jurisdiction => 'mySociety',
+ api_key => 'apikey',
+});
my %contact_params = (
confirmed => 1,
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index ec82a3a4e..b2243fcf5 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -357,14 +357,14 @@ my %contact_params = (
);
for my $body (
- { id => 2651, area_id => 2651, name => 'City of Edinburgh Council' },
- { id => 2226, area_id => 2226, name => 'Gloucestershire County Council' },
- { id => 2326, area_id => 2326, name => 'Cheltenham Borough Council' },
- { id => 2434, area_id => 2434, name => 'Lichfield District Council' },
- { id => 2240, area_id => 2240, name => 'Staffordshire County Council' },
- { id => 14279, area_id => 14279, name => 'Ballymoney Borough Council' },
- { id => 2636, area_id => 2636, name => 'Isle of Wight Council' },
- { id => 2649, area_id => 2649, name => 'Fife Council' },
+ { id => 2651, name => 'City of Edinburgh Council' },
+ { id => 2226, name => 'Gloucestershire County Council' },
+ { id => 2326, name => 'Cheltenham Borough Council' },
+ { id => 2434, name => 'Lichfield District Council' },
+ { id => 2240, name => 'Staffordshire County Council' },
+ { id => 14279, name => 'Ballymoney Borough Council' },
+ { id => 2636, name => 'Isle of Wight Council' },
+ { id => 2649, name => 'Fife Council' },
) {
$mech->create_body_ok($body->{id}, $body->{name});
}
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t
index 17abd6243..106a31c42 100644
--- a/t/app/sendreport/email.t
+++ b/t/app/sendreport/email.t
@@ -14,7 +14,8 @@ use mySociety::Locale;
my $e = FixMyStreet::SendReport::Email->new();
-my $params = { id => 1000, area_id => 1000, name => 'Council of the Thousand' };
+# area id 1000
+my $params = { id => 1000, name => 'Council of the Thousand' };
my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params);
ok $body, "found/created body";
diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t
index 8475f5eed..245cb1a13 100644
--- a/t/cobrand/get_body_sender.t
+++ b/t/cobrand/get_body_sender.t
@@ -12,23 +12,27 @@ mySociety::Locale::gettext_domain( 'FixMyStreet' );
my $c = FixMyStreet::Cobrand::FixMyStreet->new();
+FixMyStreet::App->model('DB::BodyArea')->search( { body_id => 1000 } )->delete;
FixMyStreet::App->model('DB::Body')->search( { name => 'Body of a Thousand' } )->delete;
my $body = FixMyStreet::App->model('DB::Body')->find_or_create({
- area_id => 1000,
+ id => 1000,
name => 'Body of a Thousand',
});
+my $body_area = $body->body_areas->find_or_create({ area_id => 1000 });
+
is_deeply $c->get_body_sender( $body ), { method => 'Email' }, 'defaults to email';
-$body->area_id( 2481 ); # Croydon LBO
+$body_area->update({ area_id => 2481 }); # Croydon LBO
is_deeply $c->get_body_sender( $body ), { method => 'London' }, 'returns london report it if London borough';
$body->send_method( 'TestMethod' );
is $c->get_body_sender( $body )->{ method }, 'TestMethod', 'uses send_method in preference to London';
-$body->area_id( 1000 ); # Nothing
+$body_area->update({ area_id => 1000 }); # Nothing
is $c->get_body_sender( $body )->{ method }, 'TestMethod', 'uses send_method in preference to Email';
+$body_area->delete;
$body->delete;
done_testing();
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 40868cfdd..da23c944e 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -204,7 +204,7 @@ for my $test (
$problem->state( $test->{start_state} );
$problem->update;
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -243,7 +243,7 @@ foreach my $test (
$problem->comments->delete;
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -312,7 +312,7 @@ for my $test (
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $local_requests_xml } );
- my $council_details = { areaid => $test->{area_id} };
+ my $council_details = { areas => { $test->{area_id} => 1 } };
my $update = Open311::GetServiceRequestUpdates->new( system_user => $user );
$update->update_comments( $o, $council_details );
@@ -352,7 +352,7 @@ subtest 'using start and end date' => sub {
end_date => $end_dt,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
my $start = $start_dt . '';
@@ -412,7 +412,7 @@ subtest 'check that existing comments are not duplicated' => sub {
system_user => $user,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
@@ -473,7 +473,7 @@ foreach my $test ( {
system_user => $user,
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
@@ -525,7 +525,7 @@ foreach my $test ( {
suppress_alerts => $test->{suppress_alerts},
);
- my $council_details = { areaid => 2482 };
+ my $council_details = { areas => { 2482 => 1 } };
$update->update_comments( $o, $council_details );
$problem->discard_changes;
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index ae5879896..f33fc97b4 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -20,11 +20,16 @@ ok $processor, 'created object';
my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
id => 1,
name => 'Body Numero Uno',
+} );
+$body->body_areas->find_or_create({
area_id => 1
} );
+
my $bromley = FixMyStreet::App->model('DB::Body')->find_or_create( {
id => 2482,
name => 'Bromley Council',
+} );
+$bromley->body_areas->find_or_create({
area_id => 2482
} );