aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2014-12-11 16:42:53 +0000
committerMatthew Somerville <matthew@mysociety.org>2014-12-12 12:41:31 +0000
commit43c98742ee85c73c4783451ceeea28108bb793c6 (patch)
tree40ced5bfa4a7b6c0328da62f8332cdc06a6637ea
parent4edc79829ebf2f6dcce11185e929a2a592a3f5ed (diff)
By default, use area-based alerts.
The body-based alert only works if the body ID matches the MapIt ID. This fixes #959. Further work needs to be done to enable proper body-based alerts that work properly in all circumstances. Consequently, factor out fixed body IDs from many tests. Also fix a couple of tests not overriding geocoder correctly.
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/SeeSomething.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm2
-rw-r--r--perllib/FixMyStreet/TestMech.pm33
-rw-r--r--t/app/controller/admin.t60
-rw-r--r--t/app/controller/alert.t1
-rw-r--r--t/app/controller/alert_new.t6
-rw-r--r--t/app/controller/around.t8
-rw-r--r--t/app/controller/dashboard.t14
-rw-r--r--t/app/controller/index.t7
-rw-r--r--t/app/controller/json.t2
-rw-r--r--t/app/controller/moderate.t4
-rw-r--r--t/app/controller/report_display.t29
-rw-r--r--t/app/controller/report_import.t4
-rw-r--r--t/app/controller/report_interest_count.t17
-rw-r--r--t/app/controller/report_new.t46
-rw-r--r--t/app/controller/report_new_open311.t4
-rw-r--r--t/app/controller/report_updates.t16
-rw-r--r--t/app/controller/reports.t22
-rw-r--r--t/app/model/problem.t62
-rw-r--r--t/cobrand/bromley.t6
-rw-r--r--t/cobrand/fixamingata.t2
-rw-r--r--t/cobrand/fixmybarangay.t22
-rw-r--r--t/cobrand/seesomething.t2
-rw-r--r--t/cobrand/zurich.t38
-rw-r--r--templates/web/fixmybarangay/alert/index.html8
27 files changed, 224 insertions, 198 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 2c4f73df3..10ef30c90 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -208,7 +208,7 @@ sub rss_area_ward : Path('/rss/area') : Args(2) {
$url .= '/' . $c->cobrand->short_name( $c->stash->{ward} ) if $c->stash->{ward};
$c->stash->{qs} = "/$url";
- if ($c->stash->{area}{type} ne 'DIS' && $c->stash->{area}{type} ne 'CTY') {
+ if ($c->cobrand->moniker eq 'fixmystreet' && $c->stash->{area}{type} ne 'DIS' && $c->stash->{area}{type} ne 'CTY') {
# UK-specific types - two possibilites are the same for one-tier councils, so redirect one to the other
# With bodies, this should presumably redirect if only one body covers
# the area, and then it will need that body's name (rather than
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 1ba6af139..ec7a8a81d 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -633,10 +633,10 @@ sub council_rss_alert_options {
( $_->{id_name} = $_->{short_name} ) =~ tr/+/_/;
push @options, {
type => 'council',
- id => sprintf( 'council:%s:%s', $_->{id}, $_->{id_name} ),
+ id => sprintf( 'area:%s:%s', $_->{id}, $_->{id_name} ),
text => sprintf( _('Problems within %s'), $_->{name}),
rss_text => sprintf( _('RSS feed of problems within %s'), $_->{name}),
- uri => $c->uri_for( '/rss/reports/' . $_->{short_name} ),
+ uri => $c->uri_for( '/rss/area/' . $_->{short_name} ),
};
}
diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
index af386429c..5e6d3a8cd 100644
--- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm
+++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
@@ -86,6 +86,7 @@ sub admin_stats {
my %filters = ();
+ # XXX The below lookup assumes a body ID === MapIt area ID
my %councils =
map {
my $name = $_->name;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index ecea34ddf..65930a092 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -1,6 +1,8 @@
package FixMyStreet::Cobrand::UKCouncils;
use base 'FixMyStreet::Cobrand::UK';
+# XXX Things using this cobrand base assume that a body ID === MapIt area ID
+
use strict;
use warnings;
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index 5b063ebe5..72a6810bc 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -534,6 +534,17 @@ sub get_ok_json {
return decode_json( $res->content );
}
+sub delete_body {
+ my $mech = shift;
+ my $body = shift;
+
+ $mech->delete_problems_for_body($body->id);
+ $body->contacts->delete;
+ $mech->delete_user($_) for $body->users;
+ $body->body_areas->delete;
+ $body->delete;
+}
+
sub delete_problems_for_body {
my $mech = shift;
my $body = shift;
@@ -542,6 +553,7 @@ sub delete_problems_for_body {
if ( $reports ) {
for my $r ( $reports->all ) {
$r->comments->delete;
+ $r->questionnaires->delete;
}
$reports->delete;
}
@@ -549,16 +561,21 @@ sub delete_problems_for_body {
sub create_body_ok {
my $self = shift;
- my ( $id, $name ) = @_;
-
- my $params = { id => $id, name => $name };
- my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params);
- $body->update($params); # Make sure
- ok $body, "found/created user for $id $name";
+ my ( $area_id, $name, %extra ) = @_;
+
+ my $body = FixMyStreet::App->model('DB::Body');
+ my $params = { name => $name };
+ if ($extra{id}) {
+ $body = $body->update_or_create({ %$params, id => $extra{id} }, { key => 'primary' });
+ } else {
+ $body = $body->find_or_create($params);
+ }
+ ok $body, "found/created body $name";
+ $body->body_areas->delete;
FixMyStreet::App->model('DB::BodyArea')->find_or_create({
- area_id => $id,
- body_id => $id,
+ area_id => $area_id,
+ body_id => $body->id,
});
return $body;
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 1757e386f..9ff5b5c90 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -155,23 +155,23 @@ FixMyStreet::override_config {
}, sub {
my $body = $mech->create_body_ok(2650, 'Aberdeen City Council');
-$mech->get_ok('/admin/body/2650');
+$mech->get_ok('/admin/body/' . $body->id);
$mech->content_contains('Aberdeen City Council');
$mech->content_like(qr{AB\d\d});
$mech->content_contains("http://www.example.org/around");
subtest 'check contact creation' => sub {
my $contact = FixMyStreet::App->model('DB::Contact')->search(
- { body_id => 2650, category => [ 'test category', 'test/category' ] }
+ { body_id => $body->id, category => [ 'test category', 'test/category' ] }
);
$contact->delete_all;
my $history = FixMyStreet::App->model('DB::ContactsHistory')->search(
- { body_id => 2650, category => [ 'test category', 'test/category' ] }
+ { body_id => $body->id, category => [ 'test category', 'test/category' ] }
);
$history->delete_all;
- $mech->get_ok('/admin/body/2650');
+ $mech->get_ok('/admin/body/' . $body->id);
$mech->submit_form_ok( { with_fields => {
category => 'test category',
@@ -201,12 +201,12 @@ subtest 'check contact creation' => sub {
note => 'test/note',
non_public => 'on',
} } );
- $mech->get_ok('/admin/body_edit/2650/test/category');
+ $mech->get_ok('/admin/body_edit/' . $body->id . '/test/category');
};
subtest 'check contact editing' => sub {
- $mech->get_ok('/admin/body_edit/2650/test%20category');
+ $mech->get_ok('/admin/body_edit/' . $body->id .'/test%20category');
$mech->submit_form_ok( { with_fields => {
email => 'test2@example.com',
@@ -219,7 +219,7 @@ subtest 'check contact editing' => sub {
$mech->content_contains( '<td>test2 note' );
$mech->content_contains( 'Private:&nbsp;No' );
- $mech->get_ok('/admin/body_edit/2650/test%20category');
+ $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category');
$mech->submit_form_ok( { with_fields => {
email => 'test2@example.com',
note => 'test2 note',
@@ -228,29 +228,29 @@ subtest 'check contact editing' => sub {
$mech->content_contains( 'Private:&nbsp;Yes' );
- $mech->get_ok('/admin/body_edit/2650/test%20category');
+ $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category');
$mech->content_contains( '<td><strong>test2@example.com' );
};
subtest 'check contact updating' => sub {
- $mech->get_ok('/admin/body_edit/2650/test%20category');
+ $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category');
$mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>No}s);
- $mech->get_ok('/admin/body/2650');
+ $mech->get_ok('/admin/body/' . $body->id);
$mech->form_number( 1 );
$mech->tick( 'confirmed', 'test category' );
$mech->submit_form_ok({form_number => 1});
$mech->content_like(qr'test2@example.com</td>[^<]*<td>\s*Confirmed:&nbsp;Yes's);
- $mech->get_ok('/admin/body_edit/2650/test%20category');
+ $mech->get_ok('/admin/body_edit/' . $body->id . '/test%20category');
$mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>Yes}s);
};
$body->update({ send_method => undef });
subtest 'check open311 configuring' => sub {
- $mech->get_ok('/admin/body/2650');
+ $mech->get_ok('/admin/body/' . $body->id);
$mech->content_lacks('Council contacts configured via Open311');
$mech->form_number(3);
@@ -268,7 +268,7 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Council contacts configured via Open311');
$mech->content_contains('Configuration updated - contacts will be generated automatically later');
- my $conf = FixMyStreet::App->model('DB::Body')->find( 2650 );
+ my $conf = FixMyStreet::App->model('DB::Body')->find( $body->id );
is $conf->endpoint, 'http://example.com/open311', 'endpoint configured';
is $conf->api_key, 'api key', 'api key configured';
is $conf->jurisdiction, 'mySociety', 'jurisdiction configures';
@@ -288,14 +288,14 @@ subtest 'check open311 configuring' => sub {
$mech->content_contains('Configuration updated');
- $conf = FixMyStreet::App->model('DB::Body')->find( 2650 );
+ $conf = FixMyStreet::App->model('DB::Body')->find( $body->id );
is $conf->endpoint, 'http://example.org/open311', 'endpoint updated';
is $conf->api_key, 'new api key', 'api key updated';
is $conf->jurisdiction, 'open311', 'jurisdiction configures';
};
subtest 'check text output' => sub {
- $mech->get_ok('/admin/body/2650?text=1');
+ $mech->get_ok('/admin/body/' . $body->id . '?text=1');
is $mech->content_type, 'text/plain';
$mech->content_contains('test category');
};
@@ -851,7 +851,9 @@ for my $test (
};
}
-$mech->create_body_ok(2504, 'Westminster City Council');
+my $westminster = $mech->create_body_ok(2504, 'Westminster City Council');
+$report->bodies_str($westminster->id);
+$report->update;
for my $test (
{
@@ -871,8 +873,8 @@ for my $test (
update_fixed => 0,
update_reopen => 0,
update_state => undef,
- user_body => 2504,
- content => 'user is from same council as problem - 2504',
+ user_body => $westminster->id,
+ content => 'user is from same council as problem - ' . $westminster->id,
},
{
desc => 'update changed problem state',
@@ -881,7 +883,7 @@ for my $test (
update_fixed => 0,
update_reopen => 0,
update_state => 'planned',
- user_body => 2504,
+ user_body => $westminster->id,
content => 'Update changed problem state to planned',
},
{
@@ -1096,7 +1098,7 @@ subtest 'show flagged entries' => sub {
$mech->content_contains( $user->email );
};
-$mech->create_body_ok(2509, 'Haringey Borough Council');
+my $haringey = $mech->create_body_ok(2509, 'Haringey Borough Council');
subtest 'user search' => sub {
$mech->get_ok('/admin/users');
@@ -1110,9 +1112,9 @@ subtest 'user search' => sub {
$mech->content_like( qr{user_edit/$u_id">Edit</a>} );
- $user->from_body(2509);
+ $user->from_body($haringey->id);
$user->update;
- $mech->get_ok('/admin/users?search=2509' );
+ $mech->get_ok('/admin/users?search=' . $haringey->id );
$mech->content_contains('Haringey');
};
@@ -1131,7 +1133,7 @@ is $log_entries->count, 0, 'no admin log entries';
$user->flagged( 0 );
$user->update;
-$mech->create_body_ok(2607, 'Southend-on-Sea Borough Council');
+my $southend = $mech->create_body_ok(2607, 'Southend-on-Sea Borough Council');
for my $test (
{
@@ -1139,7 +1141,7 @@ for my $test (
fields => {
name => 'Test User',
email => 'test@example.com',
- body => 2509,
+ body => $haringey->id,
flagged => undef,
},
changes => {
@@ -1153,7 +1155,7 @@ for my $test (
fields => {
name => 'Changed User',
email => 'test@example.com',
- body => 2509,
+ body => $haringey->id,
flagged => undef,
},
changes => {
@@ -1167,11 +1169,11 @@ for my $test (
fields => {
name => 'Changed User',
email => 'changed@example.com',
- body => 2509,
+ body => $haringey->id,
flagged => undef,
},
changes => {
- body => 2607,
+ body => $southend->id,
},
log_count => 3,
log_entries => [qw/edit edit edit/],
@@ -1181,7 +1183,7 @@ for my $test (
fields => {
name => 'Changed User',
email => 'changed@example.com',
- body => 2607,
+ body => $southend->id,
flagged => undef,
},
changes => {
@@ -1195,7 +1197,7 @@ for my $test (
fields => {
name => 'Changed User',
email => 'changed@example.com',
- body => 2607,
+ body => $southend->id,
flagged => 'on',
},
changes => {
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index 6fab4d3e3..9189f5e97 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -15,6 +15,7 @@ $mech->content_contains('html class="no-js" lang="en-gb"');
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
MAPIT_URL => 'http://mapit.mysociety.org/',
+ GEOCODER => '',
}, sub {
$mech->get_ok('/alert/list');
$mech->title_like(qr/^Local RSS feeds and email alerts/);
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index 14cf32d7c..115bb181a 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -349,7 +349,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
},
{
fields => {
- feed => 'council:2651:City_of_Edinburgh',
+ feed => 'area:2651:City_of_Edinburgh',
}
},
) {
@@ -383,7 +383,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
my $report_time = '2011-03-01 12:00:00';
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'EH1 1BB',
- bodies_str => '2651',
+ bodies_str => '1',
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Testing',
@@ -451,7 +451,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
my $count;
for (@emails) {
$count++ if $_->body =~ /The following updates have been left on this report:/;
- $count++ if $_->body =~ /The following new FixMyStreet reports have been sent to City of\s+Edinburgh\s+Council:/;
+ $count++ if $_->body =~ /The following new FixMyStreet reports have been added in City of\s+Edinburgh\s+Council:/;
$count++ if $_->body =~ /The following FixMyStreet reports have been made within the area you\s+specified:/;
$count++ if $_->body =~ /\s+-\s+Testing/;
}
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 892231ef1..df4f18660 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -54,8 +54,12 @@ foreach my $test (
{
subtest "test bad pc value '$test->{pc}'" => sub {
$mech->get_ok('/');
- $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
- "bad location" );
+ FixMyStreet::override_config {
+ GEOCODER => '',
+ }, sub {
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "bad location" );
+ };
is_deeply $mech->page_errors, $test->{errors},
"expected errors for pc '$test->{pc}'";
is_deeply $mech->pc_alternatives, $test->{pc_alternatives},
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 4e62028b5..3829873e5 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -13,7 +13,7 @@ my $test_pass = 'password';
my $test_council = 2651;
my $test_ward = 20723;
-$mech->create_body_ok($test_council, 'City of Edinburgh Council');
+my $body = $mech->create_body_ok($test_council, 'City of Edinburgh Council');
$mech->delete_user( $test_user );
my $user = FixMyStreet::App->model('DB::User')->create( {
@@ -44,7 +44,7 @@ FixMyStreet::override_config {
is $mech->status, '404', 'If not council user get 404';
- $user->from_body( $test_council );
+ $user->from_body( $body->id );
$user->update;
$mech->log_out_ok;
@@ -55,7 +55,7 @@ FixMyStreet::override_config {
$mech->content_contains( 'City of Edinburgh' );
- FixMyStreet::App->model('DB::Contact')->search( { body_id => $test_council } )
+ FixMyStreet::App->model('DB::Contact')->search( { body_id => $body->id } )
->delete;
delete_problems();
@@ -64,7 +64,7 @@ FixMyStreet::override_config {
for my $contact ( @cats ) {
FixMyStreet::App->model('DB::Contact')->create(
{
- body_id => $test_council,
+ body_id => $body->id,
category => $contact,
email => "$contact\@example.org",
confirmed => 1,
@@ -638,7 +638,7 @@ sub make_problem {
confirmed => $args->{conf_dt},
whensent => $args->{conf_dt},
lastupdate => $args->{mark_dt} || $args->{conf_dt},
- bodies_str => $test_council,
+ bodies_str => $body->id,
postcode => 'EH99 1SP',
latitude => '51',
longitude => '1',
@@ -692,10 +692,10 @@ sub check_report_counts {
sub delete_problems {
FixMyStreet::App->model('DB::Comment')
- ->search( { 'problem.bodies_str' => $test_council }, { join => 'problem' } )
+ ->search( { 'problem.bodies_str' => $body->id }, { join => 'problem' } )
->delete;
FixMyStreet::App->model('DB::Problem')
- ->search( { bodies_str => $test_council } )->delete();
+ ->search( { bodies_str => $body->id } )->delete();
}
done_testing;
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 308dd2c32..346ccb2e1 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -63,8 +63,6 @@ subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub {
}
};
-$mech->delete_problems_for_body( 2651 );
-
my $problem_rs = FixMyStreet::App->model('DB::Problem');
my $num = $problem_rs->count;
@@ -82,4 +80,7 @@ ok $mech->get('/report/' . $edinburgh_problems[2]->id);
is $mech->res->code, 403, 'page forbidden';
is $problem_rs->count, $num+5;
-done_testing();
+END {
+ $mech->delete_problems_for_body( 2651 );
+ done_testing();
+}
diff --git a/t/app/controller/json.t b/t/app/controller/json.t
index 405a84821..b2cea674f 100644
--- a/t/app/controller/json.t
+++ b/t/app/controller/json.t
@@ -49,7 +49,7 @@ my $body = $mech->create_body_ok(2501, 'Wandsworth Borough Council');
my $problem_args = {
postcode => 'sw1a 1aa',
- bodies_str => '2501',
+ bodies_str => $body->id,
areas => ',105164,11806,11827,2247,2501,34817,42011,66045,70786,8519,',
category => 'test category',
title => 'Test title',
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index 82e178f9b..84e8670b7 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -24,7 +24,7 @@ sub create_report {
FixMyStreet::App->model('DB::Problem')->create(
{
postcode => 'BR1 3SB',
- bodies_str => $BROMLEY_ID,
+ bodies_str => $body->id,
areas => ",$BROMLEY_ID,",
category => 'Other',
title => 'Good bad good',
@@ -64,7 +64,7 @@ subtest 'Auth' => sub {
$mech->get_ok($REPORT_URL);
$mech->content_lacks('Moderat');
- $user->update({ from_body => $BROMLEY_ID });
+ $user->update({ from_body => $body->id });
$mech->get_ok($REPORT_URL);
$mech->content_lacks('Moderat');
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 07e8caa9b..002cdc1e5 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -470,33 +470,33 @@ subtest "Zurich banners are displayed correctly" => sub {
};
};
-$mech->create_body_ok(2504, 'Westminster City Council');
-$mech->create_body_ok(2505, 'Camden Borough Council');
+my $body_westminster = $mech->create_body_ok(2504, 'Westminster City Council');
+my $body_camden = $mech->create_body_ok(2505, 'Camden Borough Council');
for my $test (
{
desc => 'no state dropdown if user not from authority',
from_body => undef,
no_state => 1,
- report_body => '2504',
+ report_body => $body_westminster->id,
},
{
desc => 'state dropdown if user from authority',
- from_body => 2504,
+ from_body => $body_westminster->id,
no_state => 0,
- report_body => '2504',
+ report_body => $body_westminster->id,
},
{
desc => 'no state dropdown if user not from same body as problem',
- from_body => 2505,
+ from_body => $body_camden->id,
no_state => 1,
- report_body => '2504',
+ report_body => $body_westminster->id,
},
{
desc => 'state dropdown if user from authority and problem sent to multiple bodies',
- from_body => 2504,
+ from_body => $body_westminster->id,
no_state => 0,
- report_body => '2504,2506',
+ report_body => $body_westminster->id . ',2506',
},
) {
subtest $test->{desc} => sub {
@@ -518,10 +518,7 @@ for my $test (
};
}
-$report->discard_changes;
-$report->bodies_str( 2504 );
-$report->update;
-
-# tidy up
-$mech->delete_user('test@example.com');
-done_testing();
+END {
+ $mech->delete_user('test@example.com');
+ done_testing();
+}
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index 4dcc7e939..e5e9e2899 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -17,6 +17,8 @@ ok -e $sample_file, "sample file $sample_file exists";
FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }
+$mech->create_body_ok(2504, 'Westminster City Council');
+
# submit an empty report to import - check we get all errors
subtest "Test creating bad partial entries" => sub {
@@ -121,7 +123,7 @@ subtest "Submit a correct entry" => sub {
"check only pc field is shown";
FixMyStreet::override_config {
- ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ],
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
$mech->submit_form_ok(
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index 9ca05e81b..506b50edd 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -54,7 +54,7 @@ ok $report, "created test report - $report_id";
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixmybarangay' ],
}, sub {
- $mech->create_body_ok(2504, 'Westminster City Council');
+ my $body = $mech->create_body_ok(2504, 'Westminster City Council');
for my $test (
{
@@ -64,13 +64,13 @@ FixMyStreet::override_config {
},
{
desc => 'from body user can increment supported count',
- from_body => 2504,
+ from_body => $body->id,
support_string => 'No supporters',
updated_support => '1 supporter'
},
{
desc => 'correct grammar for more than one supporter',
- from_body => 2504,
+ from_body => $body->id,
support_string => '1 supporter',
updated_support => '2 supporters'
},
@@ -129,10 +129,7 @@ subtest 'check support details not shown if not enabled in cobrand' => sub {
$mech->content_lacks( '1 supporter' );
};
-$report->discard_changes;
-$report->bodies_str( 2504 );
-$report->update;
-
-# tidy up
-$mech->delete_user('test@example.com');
-done_testing();
+END {
+ $mech->delete_user('test@example.com');
+ done_testing();
+}
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 44e075f1e..67e899102 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -43,16 +43,20 @@ my %contact_params = (
note => 'Created for test',
);
+my %body_ids;
for my $body (
- { id => 2651, name => 'City of Edinburgh Council' },
- { id => 2226, name => 'Gloucestershire County Council' },
- { id => 2326, name => 'Cheltenham Borough Council' },
- { id => 2482, name => 'Bromley Council' },
- { id => 2227, name => 'Hampshire County Council' },
- { id => 2333, name => 'Hart Council' },
- { id => 2504, name => 'Westminster City Council' },
+ { area_id => 2651, name => 'City of Edinburgh Council' },
+ { area_id => 2226, name => 'Gloucestershire County Council' },
+ { area_id => 2326, name => 'Cheltenham Borough Council' },
+ { area_id => 2504, name => 'Westminster City Council' },
+ # The next three have fixed IDs because bits of the code rely on
+ # the body ID === MapIt area ID.
+ { area_id => 2482, name => 'Bromley Council', id => 2482 },
+ { area_id => 2227, name => 'Hampshire County Council', id => 2227 },
+ { area_id => 2333, name => 'Hart Council', id => 2333 },
) {
- $mech->create_body_ok($body->{id}, $body->{name});
+ my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name}, id => $body->{id});
+ $body_ids{$body->{area_id}} = $body_obj->id;
}
# Let's make some contacts to send things to!
@@ -61,43 +65,43 @@ FixMyStreet::App->model('DB::Contact')->search( {
} )->delete;
my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2651, # Edinburgh
+ body_id => $body_ids{2651}, # Edinburgh
category => 'Street lighting',
email => 'highways@example.com',
} );
my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2226, # Gloucestershire
+ body_id => $body_ids{2226}, # Gloucestershire
category => 'Potholes',
email => 'potholes@example.com',
} );
my $contact3 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2326, # Cheltenham
+ body_id => $body_ids{2326}, # Cheltenham
category => 'Trees',
email => 'trees@example.com',
} );
my $contact4 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2482, # Bromley
+ body_id => $body_ids{2482}, # Bromley
category => 'Trees',
email => 'trees@example.com',
} );
my $contact5 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2651, # Edinburgh
+ body_id => $body_ids{2651}, # Edinburgh
category => 'Trees',
email => 'trees@example.com',
} );
my $contact6 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2333, # Hart
+ body_id => $body_ids{2333}, # Hart
category => 'Trees',
email => 'trees@example.com',
} );
my $contact7 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2227, # Hampshire
+ body_id => $body_ids{2227}, # Hampshire
category => 'Street lighting',
email => 'highways@example.com',
} );
@@ -586,7 +590,7 @@ foreach my $test (
is $mech->get( '/report/' . $report->id )->code, 404, "report not found";
# Check the report has been assigned appropriately
- is $report->bodies_str, 2651;
+ is $report->bodies_str, $body_ids{2651};
# receive token
my $email = $mech->get_email;
@@ -750,7 +754,7 @@ subtest "test report creation for a user who is signing in as they report" => su
is $mech->uri->path, "/report/" . $report->id, "redirected to report page";
# Check the report has been assigned appropriately
- is $report->bodies_str, 2651;
+ is $report->bodies_str, $body_ids{2651};
# check that no emails have been sent
$mech->email_count_is(0);
@@ -846,7 +850,7 @@ foreach my $test (
ok $report, "Found the report";
# Check the report has been assigned appropriately
- is $report->bodies_str, $test->{council};
+ is $report->bodies_str, $body_ids{$test->{council}};
# check that we got redirected to /report/
is $mech->uri->path, "/report/" . $report->id, "redirected to report page";
@@ -1289,7 +1293,7 @@ subtest "test Hart" => sub {
ok $report, "Found the report";
# Check the report has been assigned appropriately
- is $report->bodies_str, $test->{council};
+ is $report->bodies_str, $body_ids{$test->{council}};
if ( $test->{redirect} ) {
is $mech->uri->path, "/report/" . $report->id, "redirected to report page";
@@ -1353,10 +1357,10 @@ subtest "test SeeSomething" => sub {
my $cobrand = FixMyStreet::Cobrand::SeeSomething->new();
- $mech->create_body_ok(2535, 'Sandwell Borough Council');
+ my $body_ss = $mech->create_body_ok(2535, 'Sandwell Borough Council', id => 2535);
my $bus_contact = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2535,
+ body_id => $body_ss->id,
category => 'Bus',
email => 'bus@example.com',
non_public => 1,
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 4745d92cd..a274d918b 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -29,7 +29,7 @@ my %contact_params = (
# Let's make some contacts to send things to!
my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2651, # Edinburgh
+ body_id => $body->id, # Edinburgh
category => 'Street lighting',
email => '100',
extra => [ { description => 'Lamppost number', code => 'number', required => 'True' },
@@ -40,7 +40,7 @@ my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
} );
my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 2651, # Edinburgh
+ body_id => $body->id, # Edinburgh
category => 'Graffiti Removal',
email => '101',
} );
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 99c53ef01..64ed91ac0 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -23,6 +23,8 @@ my $user2 =
->find_or_create( { email => 'commenter@example.com', name => 'Commenter' } );
ok $user2, "created comment user";
+my $body = $mech->create_body_ok(2504, 'Westminster City Council');
+
my $dt = DateTime->new(
year => 2011,
month => 04,
@@ -35,7 +37,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- bodies_str => '2504',
+ bodies_str => $body->id,
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
@@ -513,12 +515,10 @@ subtest 'check non authority user cannot change set state' => sub {
is $report->state, 'confirmed', 'state unchanged';
};
-$mech->create_body_ok(2504, 'Westminster City Council');
-
for my $state ( qw/unconfirmed hidden partial/ ) {
subtest "check that update cannot set state to $state" => sub {
$mech->log_in_ok( $user->email );
- $user->from_body( 2504 );
+ $user->from_body( $body->id );
$user->update;
$mech->get_ok("/report/$report_id");
@@ -668,7 +668,7 @@ for my $test (
state => 'fixed',
},
state => 'fixed - council',
- report_bodies => '2504,2505',
+ report_bodies => $body->id . ',2505',
},
) {
subtest $test->{desc} => sub {
@@ -679,7 +679,7 @@ for my $test (
}
$mech->log_in_ok( $user->email );
- $user->from_body( 2504 );
+ $user->from_body( $body->id );
$user->update;
$mech->get_ok("/report/$report_id");
@@ -798,7 +798,7 @@ subtest "check comment with no status change has not status in meta" => sub {
my $update_meta = $mech->extract_update_metas;
unlike $update_meta->[1], qr/marked as/, 'update meta does not include state change';
- $user->from_body( 2504 );
+ $user->from_body( $body->id );
$user->update;
$mech->get_ok("/report/$report_id");
@@ -905,7 +905,7 @@ $user->from_body(undef);
$user->update;
$report->state('confirmed');
-$report->bodies_str('2504');
+$report->bodies_str($body->id);
$report->update;
for my $test (
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 36af2f36a..1b4fc3526 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -9,17 +9,17 @@ use DateTime;
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
$mech->create_body_ok(2514, 'Birmingham City Council');
-$mech->create_body_ok(2651, 'City of Edinburgh Council');
-$mech->create_body_ok(2504, 'Westminster City Council');
-$mech->create_body_ok(2649, 'Fife Council');
+my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id;
+my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id;
+my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id;
-$mech->delete_problems_for_body( 2504 );
-$mech->delete_problems_for_body( 2651 );
-$mech->delete_problems_for_body( 2649 );
+$mech->delete_problems_for_body( $body_west_id );
+$mech->delete_problems_for_body( $body_edin_id );
+$mech->delete_problems_for_body( $body_fife_id );
-my @edinburgh_problems = $mech->create_problems_for_body(3, 2651, 'All reports');
-my @westminster_problems = $mech->create_problems_for_body(5, 2504, 'All reports');
-my @fife_problems = $mech->create_problems_for_body(15, 2649, 'All reports');
+my @edinburgh_problems = $mech->create_problems_for_body(3, $body_edin_id, 'All reports');
+my @westminster_problems = $mech->create_problems_for_body(5, $body_west_id, 'All reports');
+my @fife_problems = $mech->create_problems_for_body(15, $body_fife_id, 'All reports');
is scalar @westminster_problems, 5, 'correct number of westminster problems created';
is scalar @edinburgh_problems, 3, 'correct number of edinburgh problems created';
@@ -114,7 +114,7 @@ FixMyStreet::override_config {
$mech->title_like(qr/Westminster City Council/);
$mech->content_contains('Westminster City Council');
-$mech->content_contains('All reports Test 3 for 2504', 'problem to be marked non public visible');
+$mech->content_contains('All reports Test 3 for ' . $body_west_id, 'problem to be marked non public visible');
my $problems = $mech->extract_problem_list;
is scalar @$problems, 5, 'correct number of problems displayed';
@@ -185,7 +185,7 @@ FixMyStreet::override_config {
$problems = $mech->extract_problem_list;
is scalar @$problems, 4, 'only public problems are displayed';
-$mech->content_lacks('All reports Test 3 for 2504', 'non public problem is not visible');
+$mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible');
$mech->get_ok('/reports');
$stats = $mech->extract_report_stats;
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 96c2771da..6ad933db8 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -377,52 +377,54 @@ my %contact_params = (
note => 'Created for test',
);
+my %body_ids;
for my $body (
- { id => 2651, name => 'City of Edinburgh Council' },
- { id => 2226, name => 'Gloucestershire County Council' },
- { id => 2326, name => 'Cheltenham Borough Council' },
- { id => 2333, name => 'Hart Council' },
- { id => 2227, name => 'Hampshire County Council' },
- { id => 14279, name => 'Ballymoney Borough Council' },
- { id => 2636, name => 'Isle of Wight Council' },
- { id => 2649, name => 'Fife Council' },
+ { area_id => 2651, name => 'City of Edinburgh Council' },
+ { area_id => 2226, name => 'Gloucestershire County Council' },
+ { area_id => 2326, name => 'Cheltenham Borough Council' },
+ { area_id => 2333, name => 'Hart Council' },
+ { area_id => 2227, name => 'Hampshire County Council' },
+ { area_id => 14279, name => 'Ballymoney Borough Council' },
+ { area_id => 2636, name => 'Isle of Wight Council' },
+ { area_id => 2649, name => 'Fife Council' },
) {
- $mech->create_body_ok($body->{id}, $body->{name});
+ my $aid = $body->{area_id};
+ $body_ids{$aid} = $mech->create_body_ok($aid, $body->{name}, id => $body->{id})->id;
}
# Let's make some contacts to send things to!
my @contacts;
for my $contact ( {
- body_id => 2651, # Edinburgh
+ body_id => $body_ids{2651}, # Edinburgh
category => 'potholes',
email => 'test@example.org',
}, {
- body_id => 2226, # Gloucestershire
+ body_id => $body_ids{2226}, # Gloucestershire
category => 'potholes',
email => '2226@example.org',
}, {
- body_id => 2326, # Cheltenham
+ body_id => $body_ids{2326}, # Cheltenham
category => 'potholes',
email => '2326@example.org',
}, {
- body_id => 2333, # Hart
+ body_id => $body_ids{2333}, # Hart
category => 'potholes',
email => 'trees@example.com',
}, {
- body_id => 2227, # Hampshire
+ body_id => $body_ids{2227}, # Hampshire
category => 'potholes',
email => 'highways@example.com',
}, {
- body_id => 14279, # Ballymoney
+ body_id => $body_ids{14279}, # Ballymoney
category => 'Street lighting',
email => 'roads.western@drdni.example.org',
}, {
- body_id => 14279, # Ballymoney
+ body_id => $body_ids{14279}, # Ballymoney
category => 'Graffiti',
email => 'highways@example.com',
}, {
confirmed => 0,
- body_id => 2636, # Isle of Wight
+ body_id => $body_ids{2636}, # Isle of Wight
category => 'potholes',
email => '2636@example.com',
} ) {
@@ -442,13 +444,13 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear City of Edinburgh Council',
to => qr'City of Edinburgh Council',
- body => 2651,
+ body => $body_ids{2651},
}, {
%common,
desc => 'no email sent if no unsent problems',
unset_whendef => 0,
email_count => 0,
- body => 2651,
+ body => $body_ids{2651},
}, {
%common,
desc => 'email to two tier council',
@@ -456,7 +458,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Cheltenham Borough Council.*Gloucestershire County Council',
dear => qr'Dear Cheltenham Borough Council and Gloucestershire County',
- body => '2226,2326',
+ body => $body_ids{2226} . ',' . $body_ids{2326},
multiple => 1,
}, {
%common,
@@ -465,7 +467,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Gloucestershire County Council" <2226@example',
dear => qr'Dear Gloucestershire County Council,',
- body => '2226|2649',
+ body => $body_ids{2226} . '|' . $body_ids{2649},
missing => qr'problem might be the responsibility of Fife.*Council'ms,
}, {
%common,
@@ -474,7 +476,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Hart Council',
dear => qr'Dear Hart Council,',
- body => '2333',
+ body => $body_ids{2333},
cobrand => 'hart',
url => 'hart.',
}, {
@@ -484,7 +486,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Hampshire County Council" <highways@example',
dear => qr'Dear Hampshire County Council,',
- body => '2227',
+ body => $body_ids{2227},
cobrand => 'hart',
url => 'www.',
}, {
@@ -494,7 +496,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Ballymoney Borough Council',
to => qr'Ballymoney Borough Council',
- body => 14279,
+ body => $body_ids{14279},
category => 'Graffiti',
}, {
%common,
@@ -503,7 +505,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Roads Service \(Western\)',
to => qr'Roads Service \(Western\)" <roads',
- body => 14279,
+ body => $body_ids{14279},
category => 'Street lighting',
}, {
%common,
@@ -511,7 +513,7 @@ foreach my $test ( {
unset_whendef => 1,
stays_unsent => 1,
email_count => 0,
- body => 2636,
+ body => $body_ids{2636},
},
) {
subtest $test->{ desc } => sub {
@@ -586,7 +588,7 @@ subtest 'check can set mutiple emails as a single contact' => sub {
};
my $contact = {
- body_id => 2651, # Edinburgh
+ body_id => $body_ids{2651}, # Edinburgh
category => 'trees',
email => '2636@example.com,2636-2@example.com',
};
@@ -639,7 +641,7 @@ subtest 'check can turn on report sent email alerts' => sub {
$problem->discard_changes;
$problem->update( {
- bodies_str => 2651,
+ bodies_str => $body_ids{2651},
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
whensent => undef,
@@ -684,7 +686,7 @@ subtest 'check iOS app store test reports not sent' => sub {
$problem->discard_changes;
$problem->update( {
- bodies_str => 2651,
+ bodies_str => $body_ids{2651},
title => 'App store test',
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
@@ -713,7 +715,7 @@ subtest 'check reports from abuser not sent' => sub {
$problem->discard_changes;
$problem->update( {
- bodies_str => 2651,
+ bodies_str => $body_ids{2651},
title => 'Report',
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 91a7038ec..6437ba3bd 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -7,9 +7,9 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
-my $body = $mech->create_body_ok( 2482, 'Bromley' );
+my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
-my @reports = $mech->create_problems_for_body( 1, 2482, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
cobrand => 'bromley',
user => $user,
});
@@ -38,5 +38,5 @@ $mech->content_contains( 'marked as no further action' );
# Clean up
$mech->delete_user($user);
-$mech->delete_problems_for_body( 2482 );
+$mech->delete_problems_for_body( $body->id );
done_testing();
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index daa7a2e8f..105847576 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -32,7 +32,7 @@ FixMyStreet::App->model('DB::Contact')->find_or_create({
note => 'Note',
});
-my @reports = $mech->create_problems_for_body( 1, 1, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
cobrand => 'fixamingata',
latitude => '55.605833',
longitude => '13.035833',
diff --git a/t/cobrand/fixmybarangay.t b/t/cobrand/fixmybarangay.t
index b996fa0a6..a431ca62b 100644
--- a/t/cobrand/fixmybarangay.t
+++ b/t/cobrand/fixmybarangay.t
@@ -22,16 +22,16 @@ $mech->content_like( qr/FixMyBarangay/ );
# Set up bodies
-my $luz = $mech->create_body_ok( 1, 'Bgy Luz' );
+my $luz = $mech->create_body_ok( 1, 'Bgy Luz', id => 1 );
$luz->update( { send_method => 'Email' } );
-my $bsn = $mech->create_body_ok( 2, 'Bgy BSN' );
+my $bsn = $mech->create_body_ok( 2, 'Bgy BSN', id => 2 );
$bsn->update( { send_method => 'Email' } );
my $dps = $mech->create_body_ok( 3, 'DPS' );
$dps->update( { send_method => 'Open311', endpoint => 'http://dps.endpoint.example.com', jurisdiction => 'FMB', api_key => 'test' } );
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => 3 });
-FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => 3 });
+FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 1, body_id => $dps->id });
+FixMyStreet::App->model('DB::BodyArea')->find_or_create({ area_id => 2, body_id => $dps->id });
# Create contacts for these bodies
# TODO: log in as a Bgy user, and create a report using the front end,
@@ -49,26 +49,26 @@ FixMyStreet::App->model('DB::Contact')->search( {
} )->delete;
my $contact1 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 1,
+ body_id => $luz->id,
category => 'Streetlight (BGY)',
email => 'bgy@example.com',
} );
my $contact2 = FixMyStreet::App->model('DB::Contact')->find_or_create( {
%contact_params,
- body_id => 3,
+ body_id => $dps->id,
category => 'Streetlight (DPS)',
email => 'LIGHT',
} );
# Create a couple of reports
-my @reports = $mech->create_problems_for_body( 1, 1, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $luz->id, 'Test', {
cobrand => 'fixmybarangay',
category => 'Streetlight (BGY)',
});
my $luz_report = $reports[0];
-@reports = $mech->create_problems_for_body( 1, 3, 'Test', {
+@reports = $mech->create_problems_for_body( 1, $dps->id, 'Test', {
cobrand => 'fixmybarangay',
category => 'Streetlight (DPS)',
});
@@ -101,7 +101,7 @@ is $dps_report->send_method_used, 'Open311', 'DPS report sent via Open311';
is $dps_report->external_id, 248, 'DPS report has right external ID';
my $fmb_test_email = 'luz_test_user@example.com';
-my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => 1, password => 'fmbsecret' } );
+my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $fmb_test_email, from_body => $luz->id, password => 'fmbsecret' } );
ok $user, "test user does exist";
$mech->log_out_ok;
@@ -132,8 +132,8 @@ is $luz_report->state, 'hidden', 'should be hidden';
$mech->delete_user($fmb_test_email);
-$mech->delete_problems_for_body( 1 );
-$mech->delete_problems_for_body( 3 );
+$mech->delete_problems_for_body( $luz->id );
+$mech->delete_problems_for_body( $dps->id );
ok $mech->host("www.fixmystreet.com"), "change host back";
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
index 1c36925e4..57a8a11ed 100644
--- a/t/cobrand/seesomething.t
+++ b/t/cobrand/seesomething.t
@@ -20,7 +20,7 @@ $db->resultset('Problem')->delete;
my $user = $mech->create_user_ok( $EMAIL );
-my $body = $mech->create_body_ok( 2520, 'Coventry City Council' );
+my $body = $mech->create_body_ok( 2520, 'Coventry City Council', id => 2520 );
$mech->create_body_ok( 2522, 'Dudley Borough Council' );
$mech->create_body_ok( 2514, 'Birmingham City Council' );
$mech->create_body_ok( 2546, 'Walsall Borough Council' );
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index e8cf3bee3..8dbc43464 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -71,13 +71,6 @@ $external_body->send_method( 'Zurich' );
$external_body->endpoint( 'external_body@example.org' );
$external_body->update;
-sub cleanup {
- $mech->delete_problems_for_body( $division->id );
- $mech->delete_problems_for_body( $subdivision->id );
- $mech->delete_user( 'dm1@example.org' );
- $mech->delete_user( 'sdm1@example.org' );
-}
-
sub get_export_rows_count {
my $mech = shift;
FixMyStreet::override_config {
@@ -93,8 +86,6 @@ sub get_export_rows_count {
return;
}
-cleanup();
-
my $EXISTING_REPORT_COUNT = 0;
subtest "set up superuser" => sub {
@@ -105,7 +96,7 @@ subtest "set up superuser" => sub {
$mech->log_out_ok;
};
-my @reports = $mech->create_problems_for_body( 1, 2, 'Test', {
+my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -131,7 +122,7 @@ FixMyStreet::override_config {
$user->update;
$mech->get_ok( '/admin' );
is $mech->uri->path, '/my', "got sent to /my";
- $user->from_body( 2 );
+ $user->from_body( $division->id );
$user->update;
$mech->get_ok( '/admin' );
@@ -325,10 +316,10 @@ FixMyStreet::override_config {
# Original description
$mech->submit_form_ok( { with_fields => { detail => 'Edited details text.' } } );
$mech->content_contains( 'Edited details text.' );
- $mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
+ $mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for ' . $division->id . ' Detail&rdquo;' );
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { body_subdivision => 3, send_rejected_email => 1 } } );
+ $mech->submit_form_ok( { with_fields => { body_subdivision => $subdivision->id, send_rejected_email => 1 } } );
$mech->get_ok( '/report/' . $report->id );
$mech->content_contains('In Bearbeitung');
@@ -351,7 +342,7 @@ FixMyStreet::override_config {
$mech->get_ok( '/admin' );
};
is $mech->uri->path, '/my', "got sent to /my";
-$user->from_body( 3 );
+$user->from_body( $subdivision->id );
$user->update;
FixMyStreet::override_config {
@@ -431,7 +422,7 @@ like $email->body, qr/FINAL UPDATE/, 'body looks correct';
$mech->clear_emails_ok;
# Assign directly to planned, don't confirm email
-@reports = $mech->create_problems_for_body( 1, 2, 'Second', {
+@reports = $mech->create_problems_for_body( 1, $division->id, 'Second', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -465,7 +456,7 @@ $mech->email_count_is(0);
# Report assigned to third party
-@reports = $mech->create_problems_for_body( 1, 2, 'Third', {
+@reports = $mech->create_problems_for_body( 1, $division->id, 'Third', {
state => 'unconfirmed',
confirmed => undef,
cobrand => 'zurich',
@@ -476,7 +467,7 @@ FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
}, sub {
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { body_external => 4 } } );
+ $mech->submit_form_ok( { with_fields => { body_external => $external_body->id } } );
$mech->get_ok( '/report/' . $report->id );
};
$mech->content_contains('Beantwortet');
@@ -499,7 +490,7 @@ FixMyStreet::override_config {
$mech->content_contains( 'report_edit/' . $report->id );
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { with_fields => { state => 'unconfirmed' } } );
- $mech->submit_form_ok( { with_fields => { body_external => 4, third_personal => 1 } } );
+ $mech->submit_form_ok( { with_fields => { body_external => $external_body->id, third_personal => 1 } } );
$mech->get_ok( '/report/' . $report->id );
};
$mech->content_contains('Beantwortet');
@@ -604,7 +595,7 @@ subtest "phone number is not mandatory for reports from mobile apps" => sub {
subtest "problems can't be assigned to deleted bodies" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
- $user->from_body( 1 );
+ $user->from_body( $zurich->id );
$user->update;
$report->state( 'confirmed' );
$report->update;
@@ -619,7 +610,7 @@ subtest "problems can't be assigned to deleted bodies" => sub {
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->content_lacks( $external_body->name );
};
- $user->from_body( 2 );
+ $user->from_body( $division->id );
$user->update;
$mech->log_out_ok;
};
@@ -681,7 +672,12 @@ subtest "test admin_log" => sub {
};
END {
- cleanup();
+ $mech->delete_body($subdivision);
+ $mech->delete_body($division);
+ $mech->delete_body($zurich);
+ $mech->delete_body($external_body);
+ $mech->delete_user( 'dm1@example.org' );
+ $mech->delete_user( 'sdm1@example.org' );
ok $mech->host("www.fixmystreet.com"), "change host back";
done_testing();
}
diff --git a/templates/web/fixmybarangay/alert/index.html b/templates/web/fixmybarangay/alert/index.html
index 8e2ce7518..58c4080e8 100644
--- a/templates/web/fixmybarangay/alert/index.html
+++ b/templates/web/fixmybarangay/alert/index.html
@@ -13,14 +13,14 @@ FixMyBarangay has a RSS feeds and email alerts for local problems.
[% END %]
[% options = [ {
- id => 'council:1:Luz',
+ id => 'area:1:Luz',
text => 'Luz',
- uri => '/rss/reports/Luz'
+ uri => '/rss/area/Luz'
},
{
- id => 'council:2:Basak_San_Nicolas',
+ id => 'area:2:Basak_San_Nicolas',
text => 'Basak San Nicolas'
- uri => '/rss/reports/Basak+San_Nicolas'
+ uri => '/rss/area/Basak+San_Nicolas'
} ];
%]