diff options
author | Struan Donald <struan@exo.org.uk> | 2011-06-15 16:53:28 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-06-15 16:53:28 +0100 |
commit | 7b2fb6cd9934fae59d89cfeabf5260a54713c26f (patch) | |
tree | a1cc6474a0f72175e333ca89cfa13c77b24c9695 | |
parent | 33074d2d554990621d6941f9c7bf02b7a8ffb18a (diff) |
update report display to handle new statuses
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 15 | ||||
-rw-r--r-- | t/app/controller/report_display.t | 49 | ||||
-rw-r--r-- | t/app/model/problem.t | 44 | ||||
-rw-r--r-- | templates/web/default/report/display.html | 2 |
4 files changed, 109 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 366024c7c..3e82e3784 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -284,6 +284,21 @@ sub get_photo_params { return $photo; } +sub is_open { + my $self = shift; + + my %open_states = ( + unconfirmed => 1, + partial => 1, + confirmed => 1, + 'planned' => 1, + 'investigating' => 1, + 'in progress' => 1, + ); + + return exists $open_states{ $self->state } ? 1 : 0; +} + =head2 meta_line Returns a string to be used on a problem report page, describing some of the diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 1f857a387..746f68cf6 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -119,6 +119,55 @@ subtest "test a good report" => sub { is $update_form->value($_), $fields{$_}, "$_ value" for keys %fields; }; +for my $test ( + { + state => 'confirmed', + display => 1, + }, + { + state => 'investigating', + display => 1, + }, + { + state => 'planned', + display => 1, + }, + { + state => 'in progress', + display => 1, + }, + { + state => 'fixed', + display => 0, + }, + { + state => 'fixed - council', + display => 0, + }, + { + state => 'fixed - user', + display => 0, + }, + { + state => 'will not fix', + display => 0, + }, +) { + subtest "check fixed checkbox display for state $test->{state}" => sub { + $report->state( $test->{state} ); + $report->update; + $mech->get_ok("/report/$report_id"); + + my $update_form = $mech->form_name('updateForm'); + + if ( $test->{display} ) { + ok defined $update_form->find_input('#form_fixed', 'checkbox'), "fixed checkbox display"; + } else { + is $update_form->find_input('#form_fixed', 'checkbox'), undef, "fixed checkbox display"; + } + }; +} + foreach my $meta ( { anonymous => 'f', diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 1b8804fce..5a5eb2520 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -152,4 +152,48 @@ for my $test ( }; } +for my $test ( + { + state => 'unconfirmed', + is_open => 1, + }, + { + state => 'confirmed', + is_open => 1, + }, + { + state => 'investigating', + is_open => 1, + }, + { + state => 'planned', + is_open => 1, + }, + { + state => 'in progress', + is_open => 1, + }, + { + state => 'fixed', + is_open => 0, + }, + { + state => 'fixed - council', + is_open => 0, + }, + { + state => 'fixed - user', + is_open => 0, + }, + { + state => 'will not fix', + is_open => 0, + }, +) { + subtest $test->{state} . ' is open/closed' => sub { + $problem->state( $test->{state} ); + is $problem->is_open, $test->{is_open}, 'is_open'; + }; +} + done_testing(); diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html index 1f4456086..89e2b6df2 100644 --- a/templates/web/default/report/display.html +++ b/templates/web/default/report/display.html @@ -105,7 +105,7 @@ </div> - [% IF problem.state != 'fixed' %] + [% IF problem.is_open %] <div class="checkbox"> <input type="checkbox" name="fixed" id="form_fixed" value="1"[% fixed %]> <label for="form_fixed">[% loc('This problem has been fixed') %]</label> |