aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/reports.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-08-17 18:43:04 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-17 18:43:04 +0100
commite020fe9e36b96b447d992f0d4a5ff2eaea34fcf3 (patch)
treecb508c0cbe59776aacfe3ccf5dcda8f737ec6370 /t/app/controller/reports.t
parent9e7d7e358d098ff91f8585fe97b53a4b58bad46e (diff)
parent1c15d23b6950618d3518197352a3330390bd9c3e (diff)
Merge branch 'issues/forcouncils/187-all-reports-filter-by-substates'
Diffstat (limited to 't/app/controller/reports.t')
-rw-r--r--t/app/controller/reports.t79
1 files changed, 79 insertions, 0 deletions
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 9f28a6c89..f3958a0a5 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -277,6 +277,85 @@ subtest "it lists shortlisted reports" => sub {
};
};
+subtest "it allows body users to filter by subtypes" => sub {
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/'
+ }, sub {
+ my $body = FixMyStreet::App->model('DB::Body')->find( $body_edin_id );
+ my $user = $mech->log_in_ok( 'test@example.com' );
+ $user->update({ from_body => $body });
+
+ my ($investigating_problem) = $mech->create_problems_for_body(1, $body_edin_id, 'Investigating report');
+ my ($scheduled_problem) = $mech->create_problems_for_body(1, $body_edin_id, 'A Scheduled report');
+ my ($in_progress_problem) = $mech->create_problems_for_body(1, $body_edin_id, 'In progress report');
+
+ $investigating_problem->update({ state => 'investigating' });
+ $scheduled_problem->update({ state => 'action scheduled' });
+ $in_progress_problem->update({ state => 'in progress' });
+
+ $mech->get_ok('/reports/City+of+Edinburgh+Council');
+ $mech->content_contains('<option value="investigating">Investigating</option>');
+ $mech->content_contains('<option value="in progress">In progress</option>');
+ $mech->content_contains('<option value="action scheduled">Action scheduled</option>');
+ $mech->content_contains('<option value="unable to fix">No further action</option>');
+ $mech->content_contains('<option value="not responsible">Not responsible</option>');
+ $mech->content_contains('<option value="internal referral">Internal referral</option>');
+ $mech->content_contains('<option value="duplicate">Duplicate</option>');
+
+ $mech->get_ok('/reports/City+of+Edinburgh+Council?status=investigating');
+
+ $in_progress_problem->discard_changes();
+
+ $mech->content_contains('Investigating report');
+ $mech->content_lacks('In progress report');
+ $mech->content_lacks('A Scheduled report');
+
+ $mech->get_ok('/reports/City+of+Edinburgh+Council?status=in progress');
+
+ $mech->content_lacks('Investigating report');
+ $mech->content_contains('In progress report');
+ $mech->content_lacks('A Scheduled report');
+ };
+};
+
+subtest "it does not allow non body users to filter by subtypes" => sub {
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/'
+ }, sub {
+ my $user = $mech->log_in_ok( 'test@example.com' );
+ $user->update({ from_body => undef });
+
+ $mech->get_ok('/reports/City+of+Edinburgh+Council');
+ $mech->content_lacks('<option value="investigating">Investigating</option>');
+ $mech->content_lacks('<option value="in progress">In progress</option>');
+ $mech->content_lacks('<option value="action scheduled">Action scheduled</option>');
+ $mech->content_lacks('<option value="unable to fix">No further action</option>');
+ $mech->content_lacks('<option value="not responsible">Not responsible</option>');
+ $mech->content_lacks('<option value="internal referral">Internal referral</option>');
+ $mech->content_lacks('<option value="duplicate">Duplicate</option>');
+ };
+};
+
+subtest "it does not allow body users to filter subcategories for other bodies" => sub {
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/'
+ }, sub {
+ my $body = FixMyStreet::App->model('DB::Body')->find( $body_west_id );
+ my $user = $mech->log_in_ok( 'test@example.com' );
+ $user->update({ from_body => $body });
+
+ $mech->get_ok('/reports/City+of+Edinburgh+Council');
+
+ $mech->content_lacks('<option value="investigating">Investigating</option>');
+ $mech->content_lacks('<option value="in progress">In progress</option>');
+ $mech->content_lacks('<option value="action scheduled">Action scheduled</option>');
+ $mech->content_lacks('<option value="unable to fix">No further action</option>');
+ $mech->content_lacks('<option value="not responsible">Not responsible</option>');
+ $mech->content_lacks('<option value="internal referral">Internal referral</option>');
+ $mech->content_lacks('<option value="duplicate">Duplicate</option>');
+ };
+};
+
subtest "can use translated body name" => sub {
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',