aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-03 17:19:42 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-03 17:42:24 +0100
commit5b3824c84f0ade0d8ac9258eb30379f8d7e11023 (patch)
tree56a53d3b4dde623447f0d89d1b3c5ea248660522
parent39c1b648b30e67ceb8912a35b386eb4ee23857b8 (diff)
Allow closed->fixed transition in questionnaire, and spot closed problems in response text (fix #269).
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm2
-rw-r--r--t/app/controller/questionnaire.t26
-rw-r--r--templates/web/default/questionnaire/completed.html4
3 files changed, 28 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index f0cc72e07..46d6350d7 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -157,6 +157,8 @@ sub submit_standard : Private {
my $new_state = '';
$new_state = 'fixed - user' if $c->stash->{been_fixed} eq 'Yes' &&
FixMyStreet::DB::Result::Problem->open_states()->{$old_state};
+ $new_state = 'fixed - user' if $c->stash->{been_fixed} eq 'Yes' &&
+ FixMyStreet::DB::Result::Problem->closed_states()->{$old_state};
$new_state = 'confirmed' if $c->stash->{been_fixed} eq 'No' &&
FixMyStreet::DB::Result::Problem->fixed_states()->{$old_state};
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 3475307fb..3a6a3d6ad 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -190,6 +190,25 @@ foreach my $test (
# update => 'Dummy', Error for not setting this tested below
},
},
+ {
+ desc => 'Closed report, said fixed, reported before, no update, no further questionnaire',
+ problem_state => 'closed',
+ fields => {
+ been_fixed => 'Yes',
+ reported => 'Yes',
+ another => 'No',
+ },
+ },
+ {
+ desc => 'Closed report, said not fixed, reported before, no update, no further questionnaire',
+ problem_state => 'closed',
+ fields => {
+ been_fixed => 'No',
+ reported => 'Yes',
+ another => 'No',
+ },
+ lastupdate_static => 1,
+ },
) {
subtest $test->{desc} => sub {
$report->state ( $test->{problem_state} );
@@ -224,7 +243,8 @@ foreach my $test (
$result = 'fixed'
if $test->{fields}{been_fixed} eq 'Yes'
&& $test->{problem_state} eq 'fixed';
- $result = 'confirmed' if $test->{fields}{been_fixed} eq 'No';
+ $result = 'confirmed' if $test->{fields}{been_fixed} eq 'No' && $test->{problem_state} ne 'closed';
+ $result = 'closed' if $test->{fields}{been_fixed} eq 'No' && $test->{problem_state} eq 'closed';
$result = 'unknown' if $test->{fields}{been_fixed} eq 'Unknown';
my $another = 0;
@@ -234,10 +254,12 @@ foreach my $test (
$mech->content_like( qr/<title>[^<]*Questionnaire/m );
$mech->content_contains( 'glad to hear it&rsquo;s been fixed' )
if $result =~ /fixed/;
+ $mech->content_lacks( 'glad to hear it&rsquo;s been fixed' )
+ if $result !~ /fixed/;
$mech->content_contains( 'get some more information about the status of your problem' )
if $result eq 'unknown';
$mech->content_contains( "sorry to hear that" )
- if $result eq 'confirmed';
+ if $result eq 'confirmed' || $result eq 'closed';
# Check the database has the right information
$report->discard_changes;
diff --git a/templates/web/default/questionnaire/completed.html b/templates/web/default/questionnaire/completed.html
index a125d48bd..52c20652c 100644
--- a/templates/web/default/questionnaire/completed.html
+++ b/templates/web/default/questionnaire/completed.html
@@ -10,12 +10,12 @@
get some more information about the status of your problem, please come back to the
site and leave an update.</p>') %]
-[% ELSIF new_state == 'confirmed' OR (!new_state AND problem.is_open) %]
+[% ELSIF new_state == 'confirmed' OR (!new_state AND problem.is_open) OR (!new_state AND problem.is_closed) %]
[% INCLUDE 'questionnaire/completed-open.html' %]
[% advert_outcome = 0 %]
-[% ELSE %]
+[% ELSIF been_fixed == 'Yes' %]
[% loc('<p style="font-size:150%">Thank you very much for filling in our questionnaire; glad to hear it&rsquo;s been fixed.</p>') %]