diff options
-rw-r--r-- | t/app/controller/report_inspect.t | 12 | ||||
-rw-r--r-- | templates/web/base/report/_state_select_field.html | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 9d2ae0b0f..e1723b0cd 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -227,13 +227,23 @@ FixMyStreet::override_config { is $report->get_extra_metadata('traffic_information'), 'Signs and Cones', 'report data changed'; }; - subtest "No action scheduled without the right permission" => sub { + subtest "Action scheduled only shown appropriately" => sub { $report->update({ state => 'confirmed' }); $mech->get_ok("/report/$report_id"); $mech->content_lacks('action scheduled'); + # If the report is already in that state, though, we should show it + $report->update({ state => 'action scheduled' }); + $mech->get_ok("/report/$report_id"); + $mech->content_unlike(qr/<optgroup label="Scheduled">\s*<option value="action scheduled">Action Scheduled<\/option>/); + $mech->content_contains('<option selected value="action scheduled">Action Scheduled</option>'); + $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); $mech->get_ok("/report/$report_id"); + $mech->content_like(qr/<optgroup label="Scheduled">\s*<option selected value="action scheduled">Action Scheduled<\/option>/); + + $report->update({ state => 'confirmed' }); + $mech->get_ok("/report/$report_id"); $mech->content_like(qr/<optgroup label="Scheduled">\s*<option value="action scheduled">Action Scheduled<\/option>/); }; diff --git a/templates/web/base/report/_state_select_field.html b/templates/web/base/report/_state_select_field.html index 9b3ed18df..adec1ff06 100644 --- a/templates/web/base/report/_state_select_field.html +++ b/templates/web/base/report/_state_select_field.html @@ -2,10 +2,19 @@ [% IF include_empty %] <option value="">---</option> [% END %] +[% SET found = 0 ~%] +[% FOREACH group IN state_groups ~%] + [% FOREACH state IN group.1 ~%] + [% SET found = 1 IF state == current_state ~%] + [% END ~%] +[% END ~%] +[% IF NOT found ~%] + <option selected value="[% current_state %]">[% state_pretty.$current_state %]</option> +[% END ~%] [% FOREACH group IN state_groups %] <optgroup label="[% group.0 %]"> [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state == current_state %] value="[% state %]">[% state_pretty.$state %]</option> + <option [% 'selected ' IF state == current_state %]value="[% state %]">[% state_pretty.$state %]</option> [% END %] </optgroup> [% END %] |