aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/my_planned.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-07-20 14:58:34 +0100
committerDave Arter <davea@mysociety.org>2016-08-22 10:36:01 +0100
commitbbb067ec5ddc88862be50819076bfe63c744122e (patch)
tree49a3e2fe62f45848495e41394e37c6536b4def44 /t/app/controller/my_planned.t
parentf3649ee94bb80e8b33f0eea8a817760475157b3b (diff)
Add user planned reports.
A user with the appropriate permission can add/remove reports from their list of planned reports using a button on a report page. The list can be viewed at /my/planned.
Diffstat (limited to 't/app/controller/my_planned.t')
-rw-r--r--t/app/controller/my_planned.t52
1 files changed, 52 insertions, 0 deletions
diff --git a/t/app/controller/my_planned.t b/t/app/controller/my_planned.t
new file mode 100644
index 000000000..25f82224e
--- /dev/null
+++ b/t/app/controller/my_planned.t
@@ -0,0 +1,52 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+$mech->get_ok('/my/planned');
+is $mech->uri->path, '/auth', "got sent to the sign in page";
+
+my $body = $mech->create_body_ok(2237, 'Oxfordshire');
+my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Test Title');
+
+$mech->get_ok($problem->url);
+$mech->content_lacks('Add to planned reports');
+$mech->content_lacks('Remove from planned reports');
+
+my $user = $mech->log_in_ok( 'test@example.com' );
+$user->update({ from_body => $body });
+$user->user_body_permissions->find_or_create({
+ body => $body,
+ permission_type => 'planned_reports',
+});
+
+$mech->get_ok('/my/planned');
+$mech->content_lacks('Test Title');
+
+$user->add_to_planned_reports($problem);
+$mech->get_ok('/my/planned');
+$mech->content_contains('Test Title');
+
+$user->remove_from_planned_reports($problem);
+$mech->get_ok('/my/planned');
+$mech->content_lacks('Test Title');
+
+$user->add_to_planned_reports($problem);
+$mech->get_ok('/my/planned');
+$mech->content_contains('Test Title');
+
+$mech->get_ok($problem->url);
+$mech->content_contains('Remove from planned reports');
+$mech->submit_form_ok({ with_fields => { change => 'remove' } });
+$mech->content_contains('Add to planned reports');
+$mech->submit_form_ok({ with_fields => { change => 'add' } });
+$mech->content_contains('Remove from planned reports');
+
+done_testing();
+
+END {
+ $mech->delete_user($user);
+}