aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/sendreport
diff options
context:
space:
mode:
Diffstat (limited to 't/app/sendreport')
-rw-r--r--t/app/sendreport/angus.t7
-rw-r--r--t/app/sendreport/email.t12
-rw-r--r--t/app/sendreport/inspection_required.t24
-rw-r--r--t/app/sendreport/open311.t17
4 files changed, 17 insertions, 43 deletions
diff --git a/t/app/sendreport/angus.t b/t/app/sendreport/angus.t
index a19ee483a..41379b4ff 100644
--- a/t/app/sendreport/angus.t
+++ b/t/app/sendreport/angus.t
@@ -1,9 +1,4 @@
-use strict;
-use warnings;
-
-use FixMyStreet::DB;
-
-use Test::More;
+use FixMyStreet::Test;
use_ok("FixMyStreet::SendReport::Angus");
diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t
index 471145dcb..6b292725b 100644
--- a/t/app/sendreport/email.t
+++ b/t/app/sendreport/email.t
@@ -1,13 +1,7 @@
-use strict;
-use warnings;
-
-use Test::More;
-
use FixMyStreet;
use FixMyStreet::DB;
use FixMyStreet::SendReport::Email;
use FixMyStreet::TestMech;
-use mySociety::Locale;
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
@@ -61,7 +55,7 @@ foreach my $test ( {
) {
subtest $test->{desc} => sub {
my $e = FixMyStreet::SendReport::Email->new;
- $contact->update( { confirmed => 0 } ) if $test->{unconfirmed};
+ $contact->update( { state => 'unconfirmed' } ) if $test->{unconfirmed};
$contact->update( { note => $test->{note} } ) if $test->{note};
$e->add_body( $body ) if $test->{add_council};
is $e->build_recipient_list( $row, {} ), $test->{count}, 'correct recipient list count';
@@ -74,7 +68,3 @@ foreach my $test ( {
}
done_testing();
-
-END {
- $mech->delete_body($body);
-}
diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t
index f9d40d39f..c8cb30592 100644
--- a/t/app/sendreport/inspection_required.t
+++ b/t/app/sendreport/inspection_required.t
@@ -1,19 +1,16 @@
-use strict;
-use warnings;
-
-use Test::More;
-
use FixMyStreet;
use FixMyStreet::DB;
use FixMyStreet::TestMech;
use FixMyStreet::SendReport::Email;
-use mySociety::Locale;
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
+use_ok 'FixMyStreet::Cobrand';
+FixMyStreet::DB->schema->cobrand(FixMyStreet::Cobrand::FixMyStreet->new());
+
my $user = $mech->create_user_ok( 'user@example.com' );
-my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council', id => 2237 );
+my $body = $mech->create_body_ok( 2237, 'Oxfordshire County Council');
# $body->update({ send_method => 'Email' });
my $contact = $mech->create_contact_ok(
@@ -31,13 +28,13 @@ my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
});
my $report = $reports[0];
-subtest 'Report isn’t sent if uninspected' => sub {
+subtest "Report isn't sent if uninspected" => sub {
$mech->clear_emails_ok;
FixMyStreet::DB->resultset('Problem')->send_reports();
$mech->email_count_is( 0 );
- is $report->whensent, undef, 'Report hasn’t been sent';
+ is $report->whensent, undef, "Report hasn't been sent";
};
subtest 'Report is sent when inspected' => sub {
@@ -72,7 +69,7 @@ subtest 'Uninspected report is sent when made by trusted user' => sub {
is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected';
};
-subtest 'Uninspected report isn’t sent when user rep is too low' => sub {
+subtest "Uninspected report isn't sent when user rep is too low" => sub {
$mech->clear_emails_ok;
$report->whensent( undef );
$report->update;
@@ -88,7 +85,7 @@ subtest 'Uninspected report isn’t sent when user rep is too low' => sub {
$report->discard_changes;
$mech->email_count_is( 0 );
- is $report->whensent, undef, 'Report hasn’t been sent';
+ is $report->whensent, undef, "Report hasn't been sent";
};
subtest 'Uninspected report is sent when user rep is high enough' => sub {
@@ -104,8 +101,3 @@ subtest 'Uninspected report is sent when user rep is high enough' => sub {
};
done_testing();
-
-END {
- $mech->delete_user($user);
- $mech->delete_body($body);
-}
diff --git a/t/app/sendreport/open311.t b/t/app/sendreport/open311.t
index c4c17577c..32564dbd8 100644
--- a/t/app/sendreport/open311.t
+++ b/t/app/sendreport/open311.t
@@ -1,7 +1,5 @@
-use strict;
-use warnings;
+use FixMyStreet::Test;
-use Test::More;
use Test::Deep;
use Open311;
@@ -159,20 +157,19 @@ sub test_overrides {
FixMyStreet::override_config {
ALLOWED_COBRANDS => ['fixmystreet', 'oxfordshire', 'bromley', 'westberkshire', 'greenwich'],
}, sub {
- my $db = FixMyStreet::DB->storage->schema;
- $db->txn_begin;
+ my $db = FixMyStreet::DB->schema;
+ #$db->txn_begin;
my $params = { id => $input->{body_id}, name => $input->{body_name} };
my $body = $db->resultset('Body')->find_or_create($params);
- $body->body_areas->create({ area_id => $input->{body_id} });
+ $body->body_areas->find_or_create({ area_id => $input->{body_id} });
ok $body, "found/created body " . $input->{body_name};
$body->update({ can_be_devolved => 1 });
my $contact = $body->contacts->find_or_create(
- confirmed => 1,
+ state => 'confirmed',
email => 'ZZ',
category => 'ZZ',
- deleted => 0,
editor => 'test suite',
note => '',
whenedited => DateTime->now,
@@ -182,7 +179,7 @@ sub test_overrides {
);
$contact->update({ send_method => 'Open311', endpoint => 'http://example.com/open311' });
- my $user = $db->resultset('User')->create( {
+ my $user = $db->resultset('User')->find_or_create( {
name => 'Fred Bloggs',
email => TEST_USER_EMAIL,
password => 'dummy',
@@ -215,7 +212,7 @@ sub test_overrides {
or diag Dumper( Open311->_get_test_data );
Open311->_reset_test_data();
- $db->txn_rollback;
+ #$db->txn_rollback;
};
}
}