aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-12-13 18:53:25 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-12-15 00:11:06 +0000
commitf05dc118efd45e0df7f3e8d04366f732440f4fd6 (patch)
treeecac77e56cb7c9d5b9c59ae7bfd6392123d9b279 /t
parent9fb130a0ab1bd36e977439b7697fba5fec5b1f00 (diff)
Update tests for new names of things and bodies needing to exist.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/dashboard.t8
-rw-r--r--t/app/controller/json.t6
-rw-r--r--t/app/controller/report_display.t16
-rw-r--r--t/app/controller/report_interest_count.t8
-rw-r--r--t/app/controller/report_new.t12
-rw-r--r--t/app/controller/report_updates.t2
-rw-r--r--t/app/controller/rss.t2
-rw-r--r--t/app/model/alert_type.t8
-rw-r--r--t/app/model/problem.t60
-rw-r--r--t/app/sendreport/email.t10
-rw-r--r--t/cobrand/closest.t2
-rw-r--r--t/cobrand/get_body_sender.t34
-rw-r--r--t/cobrand/get_council_sender.t30
-rw-r--r--t/map/tilma/original.t2
-rw-r--r--t/open311/getservicerequestupdates.t4
-rw-r--r--t/open311/populate-service-list.t69
16 files changed, 141 insertions, 132 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 307943abd..5a8465edc 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -12,6 +12,8 @@ my $test_pass = 'password';
my $test_council = 2651;
my $test_ward = 20723;
+$mech->create_body_ok($test_council, 'City of Edinburgh Council');
+
$mech->delete_user( $test_user );
my $user = FixMyStreet::App->model('DB::User')->create( {
email => $test_user,
@@ -578,7 +580,7 @@ sub make_problem {
confirmed => $args->{conf_dt},
whensent => $args->{conf_dt},
lastupdate => $args->{mark_dt} || $args->{conf_dt},
- council => $test_council,
+ bodies_str => $test_council,
postcode => 'EH99 1SP',
latitude => '51',
longitude => '1',
@@ -632,10 +634,10 @@ sub check_report_counts {
sub delete_problems {
FixMyStreet::App->model('DB::Comment')
- ->search( { 'problem.council' => $test_council }, { join => 'problem' } )
+ ->search( { 'problem.bodies_str' => $test_council }, { join => 'problem' } )
->delete;
FixMyStreet::App->model('DB::Problem')
- ->search( { council => $test_council } )->delete();
+ ->search( { bodies_str => $test_council } )->delete();
}
done_testing;
diff --git a/t/app/controller/json.t b/t/app/controller/json.t
index e8f9c0e09..405a84821 100644
--- a/t/app/controller/json.t
+++ b/t/app/controller/json.t
@@ -45,6 +45,8 @@ is_deeply #
# put an entry in the database for this test
my $user = $mech->create_user_ok('test@example.com');
+my $body = $mech->create_body_ok(2501, 'Wandsworth Borough Council');
+
my $problem_args = {
postcode => 'sw1a 1aa',
bodies_str => '2501',
@@ -86,7 +88,7 @@ is_deeply #
'category' => 'test category',
'confirmed' => '2000-01-01 12:01:00',
'lastupdate' => '2000-01-01 12:00:00',
- 'council' => 'Wandsworth Borough Council',
+ 'bodies_str' => 'Wandsworth Borough Council',
'detail' => 'Test detail',
'id' => $problem->id,
'name' => 'Test Name',
@@ -103,7 +105,7 @@ is_deeply #
'category' => 'test category',
'confirmed' => '2000-01-01 12:02:00',
'lastupdate' => '2000-01-01 12:00:00',
- 'council' => 'Wandsworth Borough Council',
+ 'bodies_str' => 'Wandsworth Borough Council',
'detail' => 'Test detail',
'id' => $anon_problem->id,
'name' => '',
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index b20fe4077..4c7b33f73 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -33,7 +33,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
@@ -350,25 +350,25 @@ for my $test (
desc => 'no state dropdown if user not from authority',
from_body => 0,
no_state => 1,
- report_council => '2504',
+ report_body => '2504',
},
{
desc => 'state dropdown if user from authority',
from_body => 2504,
no_state => 0,
- report_council => '2504',
+ report_body => '2504',
},
{
- desc => 'no state dropdown if user not from same council as problem',
+ desc => 'no state dropdown if user not from same body as problem',
from_body => 2505,
no_state => 1,
- report_council => '2504',
+ report_body => '2504',
},
{
- desc => 'state dropdown if user from authority and problem sent to multiple councils',
+ desc => 'state dropdown if user from authority and problem sent to multiple bodies',
from_body => 2504,
no_state => 0,
- report_council => '2504,2506',
+ report_body => '2504,2506',
},
) {
subtest $test->{desc} => sub {
@@ -377,7 +377,7 @@ for my $test (
$user->update;
$report->discard_changes;
- $report->bodies_str( $test->{report_council} );
+ $report->bodies_str( $test->{report_body} );
$report->update;
$mech->get_ok("/report/$report_id");
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index 788d2c473..d0e0054c4 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -33,7 +33,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
@@ -61,12 +61,12 @@ SKIP: {
unless FixMyStreet::Cobrand->exists('fixmybarangay');
for my $test (
{
- desc => 'if not from council then no supporter button',
+ desc => 'if not from body then no supporter button',
from_body => 0,
support_string => 'No supporters',
},
{
- desc => 'from council user can increment supported count',
+ desc => 'from body user can increment supported count',
from_body => 2504,
support_string => 'No supporters',
updated_support => '1 supporter'
@@ -104,7 +104,7 @@ SKIP: {
};
}
- subtest 'check non council user cannot increment support count' => sub {
+ subtest 'check non body user cannot increment support count' => sub {
ok $mech->host('fixmybarangay.com'), 'changed to fixmybarangay';
$report->discard_changes;
$report->interest_count(1);
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 323abfa18..f6a7b0824 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -33,6 +33,18 @@ my %contact_params = (
whenedited => \'current_timestamp',
note => 'Created for test',
);
+
+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 => 2240, name => 'Staffordshire County Council' },
+ { id => 2434, name => 'Lichfield District Council' },
+) {
+ $mech->create_body_ok($body->{id}, $body->{name});
+}
+
# Let's make some contacts to send things to!
FixMyStreet::App->model('DB::Contact')->search( {
email => { 'like', '%example.com' },
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 2d49d3eef..fe1c27199 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -35,7 +35,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t
index 77e2c7ee1..e683806cd 100644
--- a/t/app/controller/rss.t
+++ b/t/app/controller/rss.t
@@ -17,7 +17,7 @@ my $user1 = FixMyStreet::App->model('DB::User')
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'eh1 1BB',
- council => '2651',
+ bodies_str => '2651',
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Testing',
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index c592e9d3f..ba48300b2 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -39,7 +39,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
@@ -345,7 +345,7 @@ my $ward_alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- council => '2434',
+ bodies_str => '2434',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'council report',
@@ -369,7 +369,7 @@ my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- council => '2240',
+ bodies_str => '2240',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'county report',
@@ -393,7 +393,7 @@ my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_c
my $report_outside_district = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'WS13 6YY',
- council => '2221',
+ bodies_str => '2221',
areas => ',105255,11806,11828,2247,2504,7117,',
category => 'Other',
title => 'outside district report',
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index baec6baf0..ec82a3a4e 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -44,7 +44,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your name',
}
},
@@ -56,7 +56,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below',
}
},
@@ -68,7 +68,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
name => 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below',
}
},
@@ -80,7 +80,7 @@ for my $test (
errors => {
title => 'Please enter a subject',
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
@@ -90,7 +90,7 @@ for my $test (
},
errors => {
detail => 'Please enter some details',
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
@@ -99,22 +99,22 @@ for my $test (
detail => 'Some information about the problem',
},
errors => {
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
- desc => 'incorrectly formatted council',
+ desc => 'incorrectly formatted body',
changed => {
- council => 'my council',
+ bodies_str => 'my body',
},
errors => {
- council => 'No council selected',
+ bodies => 'No council selected',
}
},
{
- desc => 'correctly formatted council',
+ desc => 'correctly formatted body',
changed => {
- council => '1001',
+ bodies_str => '1001',
},
errors => {
}
@@ -355,6 +355,20 @@ my %contact_params = (
whenedited => \'ms_current_timestamp()',
note => 'Created for test',
);
+
+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' },
+) {
+ $mech->create_body_ok($body->{id}, $body->{name});
+}
+
# Let's make some contacts to send things to!
FixMyStreet::App->model('DB::Contact')->search( {
email => { 'like', '%example.com' },
@@ -410,13 +424,13 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear City of Edinburgh Council',
to => qr'City of Edinburgh Council',
- council => 2651,
+ body => 2651,
}, {
%common,
desc => 'no email sent if no unsent problems',
unset_whendef => 0,
email_count => 0,
- council => 2651,
+ body => 2651,
}, {
%common,
desc => 'email to two tier council',
@@ -424,7 +438,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Gloucestershire County Council.*Cheltenham Borough Council',
dear => qr'Dear Gloucestershire County Council and Cheltenham Borough',
- council => '2226,2326',
+ body => '2226,2326',
multiple => 1,
}, {
%common,
@@ -433,7 +447,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Gloucestershire County Council" <2226@example',
dear => qr'Dear Gloucestershire County Council,',
- council => '2226|2649',
+ body => '2226|2649',
missing => qr'problem might be the responsibility of Fife.*Council'ms,
}, {
%common,
@@ -442,7 +456,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Lichfield District Council',
dear => qr'Dear Lichfield District Council,',
- council => '2434',
+ body => '2434',
cobrand => 'lichfielddc',
url => 'lichfielddc.',
}, {
@@ -452,7 +466,7 @@ foreach my $test ( {
email_count => 1,
to => qr'Staffordshire County Council" <highways@example',
dear => qr'Dear Staffordshire County Council,',
- council => '2240',
+ body => '2240',
cobrand => 'lichfielddc',
url => '',
}, {
@@ -462,7 +476,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Ballymoney Borough Council',
to => qr'Ballymoney Borough Council',
- council => 14279,
+ body => 14279,
category => 'Graffiti',
}, {
%common,
@@ -471,7 +485,7 @@ foreach my $test ( {
email_count => 1,
dear => qr'Dear Roads Service \(Western\)',
to => qr'Roads Service \(Western\)" <roads',
- council => 14279,
+ body => 14279,
category => 'Street lighting',
}, {
%common,
@@ -479,7 +493,7 @@ foreach my $test ( {
unset_whendef => 1,
stays_unsent => 1,
email_count => 0,
- council => 2636,
+ body => 2636,
},
) {
subtest $test->{ desc } => sub {
@@ -497,7 +511,7 @@ foreach my $test ( {
$problem->discard_changes;
$problem->update( {
- council => $test->{ council },
+ bodies_str => $test->{ body },
state => 'confirmed',
confirmed => \'ms_current_timestamp()',
whensent => $test->{ unset_whendef } ? undef : \'ms_current_timestamp()',
@@ -519,9 +533,9 @@ foreach my $test ( {
like $email->body, $test->{ dear }, 'Salutation looks correct';
if ( $test->{multiple} ) {
- like $email->body, qr/This email has been sent to several councils /, 'multiple council text correct';
+ like $email->body, qr/This email has been sent to several councils /, 'multiple body text correct';
} elsif ( $test->{ missing } ) {
- like $email->body, $test->{ missing }, 'missing council information correct';
+ like $email->body, $test->{ missing }, 'missing body information correct';
}
if ( $test->{url} ) {
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t
index 04b3854cc..17abd6243 100644
--- a/t/app/sendreport/email.t
+++ b/t/app/sendreport/email.t
@@ -14,6 +14,10 @@ use mySociety::Locale;
my $e = FixMyStreet::SendReport::Email->new();
+my $params = { id => 1000, area_id => 1000, name => 'Council of the Thousand' };
+my $body = FixMyStreet::App->model('DB::Body')->find_or_create($params);
+ok $body, "found/created body";
+
my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
email => 'council@example.com',
body_id => 1000,
@@ -26,7 +30,7 @@ my $contact = FixMyStreet::App->model('DB::Contact')->find_or_create(
);
my $row = FixMyStreet::App->model('DB::Problem')->new( {
- council => '1000',
+ bodies_str => '1000',
category => 'category',
} );
@@ -47,7 +51,7 @@ foreach my $test ( {
count => undef,
add_council => 1,
unconfirmed => 1,
- expected_note => 'Council 1000 deleted',
+ expected_note => 'Body 1000 deleted',
},
{
desc => 'unconfirmed contact note uses note from contact table',
@@ -62,7 +66,7 @@ foreach my $test ( {
my $e = FixMyStreet::SendReport::Email->new;
$contact->update( { confirmed => 0 } ) if $test->{unconfirmed};
$contact->update( { note => $test->{note} } ) if $test->{note};
- $e->add_council( 1000, { name => 'test council' } ) if $test->{add_council};
+ $e->add_body( $body ) if $test->{add_council};
is $e->build_recipient_list( $row, {} ), $test->{count}, 'correct recipient list count';
if ( $test->{unconfirmed} ) {
diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t
index 464c95e67..ab97694c9 100644
--- a/t/cobrand/closest.t
+++ b/t/cobrand/closest.t
@@ -29,7 +29,7 @@ my $dt = DateTime->new(
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
diff --git a/t/cobrand/get_body_sender.t b/t/cobrand/get_body_sender.t
new file mode 100644
index 000000000..8475f5eed
--- /dev/null
+++ b/t/cobrand/get_body_sender.t
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use mySociety::Locale;
+use FixMyStreet::App;
+
+use_ok 'FixMyStreet::Cobrand';
+
+mySociety::Locale::gettext_domain( 'FixMyStreet' );
+
+my $c = FixMyStreet::Cobrand::FixMyStreet->new();
+
+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,
+ name => 'Body of a Thousand',
+});
+is_deeply $c->get_body_sender( $body ), { method => 'Email' }, 'defaults to email';
+
+$body->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
+is $c->get_body_sender( $body )->{ method }, 'TestMethod', 'uses send_method in preference to Email';
+
+$body->delete;
+
+done_testing();
diff --git a/t/cobrand/get_council_sender.t b/t/cobrand/get_council_sender.t
deleted file mode 100644
index c05864d8a..000000000
--- a/t/cobrand/get_council_sender.t
+++ /dev/null
@@ -1,30 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-
-use mySociety::Locale;
-use FixMyStreet::App;
-
-use_ok 'FixMyStreet::Cobrand';
-
-mySociety::Locale::gettext_domain( 'FixMyStreet' );
-
-my $c = FixMyStreet::Cobrand::FixMyStreet->new();
-
-
-is_deeply $c->get_council_sender( '1000', { type => 'DIS' } ), { method => 'Email' }, 'defaults to email';
-is_deeply $c->get_council_sender( '1000', { type => 'LBO' } ), { method=> 'London' }, 'returns london report it if London borough';
-
-my $conf = FixMyStreet::App->model('DB::Body')->find_or_create(
- area_id => 1000,
- endpoint => '',
- send_method => 'TestMethod'
-);
-
-is $c->get_council_sender( '1000', { type => 'LBO' } )->{ method }, 'TestMethod', 'uses send_method in preference to London';
-is $c->get_council_sender( '1000', { type => 'DIS' } )->{ method }, 'TestMethod', 'uses send_method in preference to Email';
-
-$conf->delete;
-
-done_testing();
diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t
index 04c4d578c..cd3bc623e 100644
--- a/t/map/tilma/original.t
+++ b/t/map/tilma/original.t
@@ -32,7 +32,7 @@ my $dt = DateTime->now();
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create(
{
postcode => 'SW1A 1AA',
- council => '2504',
+ bodies_str => '2504',
areas => ',105255,11806,11828,2247,2504,',
category => 'Other',
title => 'Test 2',
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index aba811e58..40868cfdd 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -123,7 +123,7 @@ my $problem = $problem_rs->new(
lastupdate => DateTime->now()->subtract( days => 1 ),
anonymous => 1,
external_id => time(),
- council => 2482,
+ bodies_str => 2482,
}
);
@@ -273,7 +273,7 @@ my $problem2 = $problem_rs->new(
lastupdate => DateTime->now(),
anonymous => 1,
external_id => $problem->external_id,
- council => 2651,
+ bodies_str => 2651,
}
);
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index ec6c175f9..ae5879896 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -17,19 +17,24 @@ use_ok( 'Open311' );
my $processor = Open311::PopulateServiceList->new( council_list => [] );
ok $processor, 'created object';
-
+my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
+ id => 1,
+ name => 'Body Numero Uno',
+ area_id => 1
+} );
+my $bromley = FixMyStreet::App->model('DB::Body')->find_or_create( {
+ id => 2482,
+ name => 'Bromley Council',
+ area_id => 2482
+} );
subtest 'check basic functionality' => sub {
FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->delete();
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
@@ -54,12 +59,8 @@ subtest 'check non open311 contacts marked as deleted' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
my $contact_count = FixMyStreet::App->model('DB::Contact')->search( { body_id => 1 } )->count();
@@ -89,12 +90,8 @@ subtest 'check email changed if matching category' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -126,12 +123,8 @@ subtest 'check category name changed if updated' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -179,12 +172,8 @@ subtest 'check conflicting contacts not changed' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
my $processor = Open311::PopulateServiceList->new( council_list => [] );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
$contact->discard_changes;
@@ -243,12 +232,8 @@ subtest 'check meta data population' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 2482
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $bromley );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -432,12 +417,8 @@ for my $test (
my $service_list = get_xml_simple_object( $services_xml );
$service_list = { service => [ $service_list->{ service } ] };
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -505,12 +486,8 @@ subtest 'check attribute ordering' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 1
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -611,12 +588,8 @@ subtest 'check bromely skip code' => sub {
test_get_returns => { 'services/100.xml' => $meta_xml }
);
- my $council = FixMyStreet::App->model('DB::Body')->new( {
- area_id => 2482
- } );
-
$processor->_current_open311( $o );
- $processor->_current_council( $council );
+ $processor->_current_body( $bromley );
$processor->_current_service( { service_code => 100 } );
$processor->_add_meta_to_contact( $contact );
@@ -636,9 +609,7 @@ subtest 'check bromely skip code' => sub {
is_deeply $contact->extra, $extra, 'only non std bromley meta data saved';
- $council->area_id(1);
-
- $processor->_current_council( $council );
+ $processor->_current_body( $body );
$processor->_add_meta_to_contact( $contact );
$extra = [