aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_new.t4
-rw-r--r--t/app/model/problem.t36
-rw-r--r--t/open311/getupdates.t9
-rw-r--r--t/open311/populate-service-list.t20
4 files changed, 33 insertions, 36 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 2993eddac..84258f338 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1453,6 +1453,10 @@ subtest "test SeeSomething" => sub {
is $mech->uri->path, '/report/new', 'stays on report/new page';
$mech->content_contains( 'Your report has been sent', 'use report created template' );
}
+
+ $user->alerts->delete;
+ $user->problems->delete;
+ $user->delete;
};
}
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index fa8cf89ae..24ed959af 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -168,6 +168,10 @@ $problem->insert;
my $tz_local = DateTime::TimeZone->new( name => 'local' );
+my $body = FixMyStreet::App->model('DB::Body')->new({
+ name => 'Edinburgh City Council'
+});
+
for my $test (
{
desc => 'request older than problem ignored',
@@ -175,9 +179,6 @@ for my $test (
request => {
updated_datetime => DateTime::Format::W3CDTF->new()->format_datetime( DateTime->now()->set_time_zone( $tz_local )->subtract( days => 2 ) ),
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 0,
},
{
@@ -188,9 +189,6 @@ for my $test (
status => 'open',
status_notes => 'this is an update from the council',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
state => 'confirmed',
mark_fixed => 0,
@@ -204,9 +202,6 @@ for my $test (
status => 'closed',
status_notes => 'the council have fixed this',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
state => 'fixed',
mark_fixed => 1,
@@ -220,9 +215,6 @@ for my $test (
status => 'open',
status_notes => 'the council do not think this is fixed',
},
- council => {
- name => 'Edinburgh City Council',
- },
created => 1,
start_state => 'fixed',
state => 'fixed',
@@ -239,7 +231,7 @@ for my $test (
$problem->update;
my $w3c = DateTime::Format::W3CDTF->new();
- my $ret = $problem->update_from_open311_service_request( $test->{request}, $test->{council}, $user );
+ my $ret = $problem->update_from_open311_service_request( $test->{request}, $body, $user );
is $ret, $test->{created}, 'return value';
return unless $test->{created};
@@ -399,9 +391,6 @@ for my $body (
}
# Let's make some contacts to send things to!
-FixMyStreet::App->model('DB::Contact')->search( {
- email => { 'like', '%example.com' },
-} )->delete;
my @contacts;
for my $contact ( {
body_id => 2651, # Edinburgh
@@ -760,13 +749,14 @@ subtest 'check reports from abuser not sent' => sub {
ok $abuse->delete(), 'user removed from abuse table';
};
+END {
+ $problem->comments->delete if $problem;
+ $problem->delete if $problem;
+ $mech->delete_user( $user ) if $user;
-$problem->comments->delete;
-$problem->delete;
-$mech->delete_user( $user );
+ foreach (@contacts) {
+ $_->delete;
+ }
-foreach (@contacts) {
- $_->delete;
+ done_testing();
}
-
-done_testing();
diff --git a/t/open311/getupdates.t b/t/open311/getupdates.t
index 4376e2f4b..7dc7ff164 100644
--- a/t/open311/getupdates.t
+++ b/t/open311/getupdates.t
@@ -15,6 +15,9 @@ my $user = FixMyStreet::App->model('DB::User')->find_or_create(
}
);
+my $body = FixMyStreet::App->model('DB::Body')->new( {
+ name => 'Test Body',
+} );
my $updates = Open311::GetUpdates->new( system_user => $user );
ok $updates, 'created object';
@@ -99,7 +102,7 @@ for my $test (
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } );
- ok $updates->update_reports( [ 638344 ], $o, { name => 'Test Council' } );
+ ok $updates->update_reports( [ 638344 ], $o, $body );
is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344', 'get url';
is $problem->comments->count, $test->{comment_count}, 'added a comment';
@@ -174,7 +177,7 @@ subtest 'update with two requests' => sub {
my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } );
- ok $updates->update_reports( [ 638344,638345 ], $o, { name => 'Test Council' } );
+ ok $updates->update_reports( [ 638344,638345 ], $o, $body );
is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344%2C638345', 'get url';
is $problem->comments->count, 1, 'added a comment to first problem';
@@ -228,7 +231,7 @@ subtest 'test translation of auto-added comment from old-style Open311 update' =
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixamingata' ],
}, sub {
- ok $updates->update_reports( [ 638346 ], $o, { name => 'Test Council' } );
+ ok $updates->update_reports( [ 638346 ], $o, $body );
};
is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638346', 'get url';
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index f33fc97b4..9fd18b607 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -14,7 +14,7 @@ use_ok( 'Open311::PopulateServiceList' );
use_ok( 'Open311' );
-my $processor = Open311::PopulateServiceList->new( council_list => [] );
+my $processor = Open311::PopulateServiceList->new();
ok $processor, 'created object';
my $body = FixMyStreet::App->model('DB::Body')->find_or_create( {
@@ -38,7 +38,7 @@ subtest 'check basic functionality' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
$processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -64,7 +64,7 @@ subtest 'check non open311 contacts marked as deleted' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
$processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -95,7 +95,7 @@ subtest 'check email changed if matching category' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
$processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -128,7 +128,7 @@ subtest 'check category name changed if updated' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
$processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -177,7 +177,7 @@ subtest 'check conflicting contacts not changed' => sub {
my $service_list = get_xml_simple_object( get_standard_xml() );
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
$processor->_current_body( $body );
$processor->process_services( $service_list );
@@ -198,7 +198,7 @@ subtest 'check conflicting contacts not changed' => sub {
};
subtest 'check meta data population' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
@@ -377,7 +377,7 @@ for my $test (
},
) {
subtest $test->{desc} => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $services_xml = '<?xml version="1.0" encoding="utf-8"?>
<services>
@@ -434,7 +434,7 @@ for my $test (
}
subtest 'check attribute ordering' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
@@ -536,7 +536,7 @@ subtest 'check attribute ordering' => sub {
};
subtest 'check bromely skip code' => sub {
- my $processor = Open311::PopulateServiceList->new( council_list => [] );
+ my $processor = Open311::PopulateServiceList->new();
my $meta_xml = '<?xml version="1.0" encoding="utf-8"?>
<service_definition>