aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin.t29
-rw-r--r--t/app/controller/admin_permissions.t7
-rw-r--r--t/app/controller/alert_new.t3
-rw-r--r--t/app/controller/auth.t3
-rw-r--r--t/app/controller/auth_social.t1
-rw-r--r--t/app/controller/council.t7
-rw-r--r--t/app/controller/index.t2
-rw-r--r--t/app/controller/json.t2
-rw-r--r--t/app/controller/moderate.t10
-rw-r--r--t/app/controller/my.t5
-rw-r--r--t/app/controller/my_planned.t4
-rw-r--r--t/app/controller/page_not_found.t11
-rw-r--r--t/app/controller/questionnaire.t10
-rw-r--r--t/app/controller/report_as_other.t5
-rw-r--r--t/app/controller/report_display.t4
-rw-r--r--t/app/controller/report_import.t4
-rw-r--r--t/app/controller/report_inspect.t2
-rw-r--r--t/app/controller/report_interest_count.t3
-rw-r--r--t/app/controller/report_new.t4
-rw-r--r--t/app/controller/report_new_mobile.t1
-rw-r--r--t/app/controller/report_new_open311.t4
-rw-r--r--t/app/controller/report_updates.t13
-rw-r--r--t/app/controller/reports.t7
-rw-r--r--t/app/controller/rss.t2
24 files changed, 14 insertions, 129 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index 07759197e..4384123bd 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -18,11 +18,7 @@ $mech->create_contact_ok( body_id => $oxford->id, category => 'Graffiti', email
my $bromley = $mech->create_body_ok(2482, 'Bromley Council');
-my $user3 = $mech->create_user_ok('test3@example.com', name => 'Test User 2');
-
-if ( $user3 ) {
- $mech->delete_user( $user3 );
-}
+my $user3;
my $dt = DateTime->new(
year => 2011,
@@ -154,16 +150,6 @@ $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 => $body->id, category => [ 'test category', 'test/category' ] }
- );
- $contact->delete_all;
-
- my $history = FixMyStreet::App->model('DB::ContactsHistory')->search(
- { body_id => $body->id, category => [ 'test category', 'test/category' ] }
- );
- $history->delete_all;
-
$mech->get_ok('/admin/body/' . $body->id);
$mech->submit_form_ok( { with_fields => {
@@ -1542,15 +1528,4 @@ subtest "response priorities can't be viewed across councils" => sub {
};
};
-END {
- $mech->delete_user( $user );
- $mech->delete_user( $user2 );
- $mech->delete_user( $user3 );
- $mech->delete_user( $superuser );
- $mech->delete_user( 'test4@example.com' );
- $mech->delete_body( $oxfordshire );
- $mech->delete_body( $oxford );
- $mech->delete_body( $bromley );
- $mech->delete_body( $westminster );
- done_testing();
-}
+done_testing();
diff --git a/t/app/controller/admin_permissions.t b/t/app/controller/admin_permissions.t
index f30777d16..0997e1e38 100644
--- a/t/app/controller/admin_permissions.t
+++ b/t/app/controller/admin_permissions.t
@@ -11,13 +11,6 @@ my $oxfordshireuser = $mech->create_user_ok('counciluser@example.com', name => '
my $bromley = $mech->create_body_ok(2482, 'Bromley Council');
-END {
- $mech->delete_user( $user );
- $mech->delete_user( $user2 );
- $mech->delete_user( $superuser );
- $mech->delete_user( $oxfordshireuser );
-}
-
my $dt = DateTime->new(
year => 2011,
month => 04,
diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t
index f7d35f9a0..ddf881f4d 100644
--- a/t/app/controller/alert_new.t
+++ b/t/app/controller/alert_new.t
@@ -1,5 +1,6 @@
use FixMyStreet::TestMech;
use FixMyStreet::App;
+use FixMyStreet::Script::Alerts;
my $mech = FixMyStreet::TestMech->new;
@@ -434,7 +435,7 @@ subtest "Test normal alert signups and that alerts are sent" => sub {
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',
}, sub {
- FixMyStreet::App->model('DB::AlertType')->email_alerts();
+ FixMyStreet::Script::Alerts::send();
};
# TODO Note the below will fail if the db has an existing alert that matches
$mech->email_count_is(3);
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index d1e313df2..388216a1f 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -6,11 +6,8 @@ my $mech = FixMyStreet::TestMech->new;
my $test_email = 'test@example.com';
my $test_email2 = 'test@example.net';
my $test_password = 'foobar';
-$mech->delete_user($test_email);
END {
- $mech->delete_user($test_email);
- $mech->delete_user($test_email2);
done_testing();
}
diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t
index 7a82fc813..726d264bd 100644
--- a/t/app/controller/auth_social.t
+++ b/t/app/controller/auth_social.t
@@ -251,6 +251,5 @@ for my $tw_state ( 'refused', 'existing UID', 'no email' ) {
};
END {
- $mech->delete_problems_for_body('2345');
done_testing();
}
diff --git a/t/app/controller/council.t b/t/app/controller/council.t
index 11898995a..41398ae61 100644
--- a/t/app/controller/council.t
+++ b/t/app/controller/council.t
@@ -1,14 +1,9 @@
-use strict;
-use warnings;
-use Test::More;
+use FixMyStreet::Test;
-
-use Catalyst::Test 'FixMyStreet::App';
use_ok( 'FixMyStreet::App::Controller::Council' );
TODO: {
local $TODO = 'need to write some tests for this';
-
}
done_testing();
diff --git a/t/app/controller/index.t b/t/app/controller/index.t
index 654ebfcce..be4da6034 100644
--- a/t/app/controller/index.t
+++ b/t/app/controller/index.t
@@ -88,7 +88,5 @@ subtest "prefilters /around if user has categories" => sub {
};
END {
- $mech->delete_problems_for_body( 2651 );
- $mech->delete_body($oxon);
done_testing();
}
diff --git a/t/app/controller/json.t b/t/app/controller/json.t
index f7410dbd0..8ee472f5d 100644
--- a/t/app/controller/json.t
+++ b/t/app/controller/json.t
@@ -111,6 +111,4 @@ is_deeply #
],
"correct response";
-$mech->delete_user($user);
-
done_testing();
diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t
index a4a7f3cb6..9ba1ba3df 100644
--- a/t/app/controller/moderate.t
+++ b/t/app/controller/moderate.t
@@ -11,9 +11,6 @@ my $body = $mech->create_body_ok( $BROMLEY_ID, 'Bromley Council' );
my $dt = DateTime->now;
my $user = $mech->create_user_ok('test-moderation@example.com', name => 'Test User');
-$user->user_body_permissions->delete_all;
-$user->discard_changes;
-
my $user2 = $mech->create_user_ok('test-moderation2@example.com', name => 'Test User 2');
sub create_report {
@@ -343,11 +340,4 @@ subtest 'And do it as a superuser' => sub {
$mech->content_contains('Moderated by a FixMyStreet administrator');
};
-$update->delete;
-$update2->delete;
-$report->moderation_original_data->delete;
-$report->delete;
-$report2->delete;
-$mech->delete_user($user);
-
done_testing();
diff --git a/t/app/controller/my.t b/t/app/controller/my.t
index 47539ba55..8b4a25c26 100644
--- a/t/app/controller/my.t
+++ b/t/app/controller/my.t
@@ -63,8 +63,3 @@ is $problems[2]->discard_changes->anonymous, 1, 'Other user problem made anonymo
is $update[0]->discard_changes->anonymous, 1, 'User update made anonymous';
done_testing();
-
-END {
- $mech->delete_user($user);
- $mech->delete_user($other_user);
-}
diff --git a/t/app/controller/my_planned.t b/t/app/controller/my_planned.t
index 9e9ac06a2..51ea0297e 100644
--- a/t/app/controller/my_planned.t
+++ b/t/app/controller/my_planned.t
@@ -78,7 +78,3 @@ subtest "POSTing multiple problems to my/planned/change adds all to shortlist" =
};
done_testing();
-
-END {
- $mech->delete_user($user);
-}
diff --git a/t/app/controller/page_not_found.t b/t/app/controller/page_not_found.t
index 3c2bc3c3d..30a24df09 100644
--- a/t/app/controller/page_not_found.t
+++ b/t/app/controller/page_not_found.t
@@ -1,11 +1,6 @@
-use strict;
-use warnings;
+use FixMyStreet::TestMech;
-use Test::More tests => 4;
-
-use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App';
-
-my $mech = Test::WWW::Mechanize::Catalyst->new;
+my $mech = FixMyStreet::TestMech->new;
# homepage ok
$mech->get_ok('/');
@@ -16,3 +11,5 @@ my $res = $mech->get($path_to_404);
ok !$res->is_success(), "want a bad response";
is $res->code, 404, "got 404";
$mech->content_contains($path_to_404);
+
+done_testing();
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index b046cec9b..c6d112df7 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -5,15 +5,6 @@ use FixMyStreet::App::Controller::Questionnaire;
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
-# Make sure there's no outstanding questionnaire emails to be sent
-FixMyStreet::App->model('DB::Questionnaire')->send_questionnaires( {
- site => 'fixmystreet'
-} );
-$mech->clear_emails_ok;
-
-# create a test user and report
-$mech->delete_user('test@example.com');
-
my $user = $mech->create_user_ok('test@example.com', name => 'Test User');
my $dt = DateTime->now()->subtract( weeks => 5 );
@@ -455,5 +446,4 @@ FixMyStreet::override_config {
is $plain->header('Content-Type'), 'text/plain; charset="utf-8"', 'email is in right encoding';
};
-$mech->delete_user('test@example.com');
done_testing();
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 96c6df239..86c2deb93 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -121,11 +121,6 @@ subtest "Body user, has permission to add update as another (existing) user" =>
done_testing();
-END {
- $mech->delete_body($body);
- $mech->delete_user($_) for @users;
-}
-
sub start_report {
my $permission = shift;
$_->delete for $user->user_body_permissions;
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index a8c618d49..bcdf612be 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -6,8 +6,6 @@ use DateTime;
my $mech = FixMyStreet::TestMech->new;
-# create a test user and report
-$mech->delete_user('test@example.com');
my $user = $mech->create_user_ok('test@example.com', name => 'Test User');
my $user2 = $mech->create_user_ok('test2@example.com', name => 'Other User');
@@ -579,7 +577,5 @@ subtest "check brackets don't appear when username and report name are the same"
};
END {
- $mech->delete_user('test@example.com');
- $mech->delete_body($westminster);
done_testing();
}
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index 25875b38a..47113198e 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -382,7 +382,3 @@ subtest "Submit a correct entry (with location) to cobrand" => sub {
};
done_testing();
-
-END {
- $mech->delete_body($body);
-}
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index a0407cb32..e3d24e9a9 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -274,7 +274,5 @@ FixMyStreet::override_config {
END {
- $mech->delete_body($oxon);
- $mech->delete_body($brum);
done_testing();
}
diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t
index bd9660dea..04f567615 100644
--- a/t/app/controller/report_interest_count.t
+++ b/t/app/controller/report_interest_count.t
@@ -15,8 +15,6 @@ use DateTime;
my $mech = FixMyStreet::TestMech->new;
-# create a test user and report
-$mech->delete_user('test@example.com');
my $user = $mech->create_user_ok('test@example.com', name => 'Test User');
my $dt = DateTime->new(
@@ -128,6 +126,5 @@ subtest 'check support details not shown if not enabled in cobrand' => sub {
};
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 0deef8196..52bf6da3e 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1671,7 +1671,3 @@ subtest "inspectors get redirected directly to the report page" => sub {
};
done_testing();
-
-END {
- $mech->delete_body($_) foreach @bodies;
-}
diff --git a/t/app/controller/report_new_mobile.t b/t/app/controller/report_new_mobile.t
index 7f71a2786..296007ce3 100644
--- a/t/app/controller/report_new_mobile.t
+++ b/t/app/controller/report_new_mobile.t
@@ -36,6 +36,5 @@ subtest "Check signed up for alert when logged in" => sub {
};
END {
- $mech->delete_user('user@example.org');
done_testing();
}
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 4c3fefc56..9a4a81182 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -172,7 +172,3 @@ foreach my $test (
}
done_testing();
-
-END {
- $mech->delete_body($body);
-}
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 2a20320bc..81174181c 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -5,10 +5,6 @@ use DateTime;
my $mech = FixMyStreet::TestMech->new;
-# create a test user and report
-$mech->delete_user('commenter@example.com');
-$mech->delete_user('test@example.com');
-
my $user = $mech->create_user_ok('test@example.com', name => 'Test User');
my $user2 = $mech->create_user_ok('commenter@example.com', name => 'Commenter');
@@ -816,7 +812,7 @@ subtest "check comment with no status change has not status in meta" => sub {
$mech->get_ok("/report/$report_id");
$report->discard_changes;
- my @updates = $report->comments->all;
+ my @updates = $report->comments->search(undef, { order_by => ['created', 'id'] })->all;
is scalar @updates, 2, 'correct number of updates';
my $update = pop @updates;
@@ -849,7 +845,7 @@ subtest "check comment with no status change has not status in meta" => sub {
$mech->get_ok("/report/$report_id");
$report->discard_changes;
- @updates = $report->comments->search(undef, { order_by => 'created' })->all;;
+ @updates = $report->comments->search(undef, { order_by => ['created', 'id'] })->all;
is scalar @updates, 3, 'correct number of updates';
@@ -879,7 +875,7 @@ subtest "check comment with no status change has not status in meta" => sub {
$mech->get_ok("/report/$report_id");
$report->discard_changes;
- @updates = $report->comments->search(undef, { order_by => 'created' })->all;;
+ @updates = $report->comments->search(undef, { order_by => ['created', 'id'] })->all;;
is scalar @updates, 4, 'correct number of updates';
$update = pop @updates;
@@ -1883,7 +1879,4 @@ subtest 'check cannot answer other user\'s creator fixed questionnaire' => sub {
$mech->content_contains( "I'm afraid we couldn't locate your problem in the database." )
};
-ok $comment->delete, 'deleted comment';
-$mech->delete_user('commenter@example.com');
-$mech->delete_user('test@example.com');
done_testing();
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 8e226de8c..209266940 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -11,10 +11,6 @@ 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;
my $body_slash_id = $mech->create_body_ok(10000, 'Electricity/Gas Council')->id;
-$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, $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');
@@ -83,7 +79,8 @@ $fife_problems[10]->update( {
});
# Run the cron script that makes the data for /reports so we don't get an error.
-system( "bin/update-all-reports" );
+use FixMyStreet::Script::UpdateAllReports;
+FixMyStreet::Script::UpdateAllReports::generate();
# check that we can get the page
$mech->get_ok('/reports');
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t
index 2258c9f5b..5ec7bfae7 100644
--- a/t/app/controller/rss.t
+++ b/t/app/controller/rss.t
@@ -193,6 +193,4 @@ subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" =
$mech->content_contains($expected2, 'cobrand area report point to cobrand url');
};
-$mech->delete_user( $user1 );
-
done_testing();