aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-24 17:41:48 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-24 17:41:48 +0100
commit02de04c365b8d7e8323e556b6258c1c92ba672e6 (patch)
tree6d057fa6064cce7c42bff28f2d2c27c0fa48eb65
parent75508655346c12cb56c3e2ae521ed8919f228a9e (diff)
if the person who created the problem is marking it as fixed show
them a questionnaire directly ( no submission yet )
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm16
-rw-r--r--t/app/controller/report_updates.t92
-rw-r--r--templates/web/default/questionnaire/creator_fixed.html22
4 files changed, 123 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index c5258e7d0..8b804e421 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -215,6 +215,14 @@ sub display : Private {
$c->stash->{cobrand_form_elements} = $c->cobrand->form_elements('questionnaireForm');
}
+sub creator_fixed : Private {
+ my ( $self, $c ) = @_;
+
+ $c->stash->{template} = 'questionnaire/creator_fixed.html';
+
+ return 1;
+}
+
=head1 AUTHOR
Matthew Somerville
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 3d575f6a5..350024315 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -46,6 +46,8 @@ sub confirm : Private {
sub update_problem : Private {
my ( $self, $c ) = @_;
+ my $display_questionnaire = 0;
+
my $update = $c->stash->{update};
my $problem = $c->stash->{problem} || $update->problem;
@@ -54,8 +56,7 @@ sub update_problem : Private {
if ( $update->user->id == $problem->user->id ) {
$problem->send_questionnaire( 'f' );
- } else {
- $c->forward( 'ask_questionnaire' );
+ $display_questionnaire = 1;
}
}
@@ -64,14 +65,9 @@ sub update_problem : Private {
$c->stash->{problem} = $problem;
-
- return 1;
-}
-
-sub ask_questionnaire : Private {
- my ( $self, $c ) = @_;
-
- # FIXME send out questionnaire token here
+ if ( $display_questionnaire ) {
+ $c->detach('/questionnaire/creator_fixed');
+ }
return 1;
}
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 6e93a7d74..3815fb14f 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -448,8 +448,8 @@ for my $test (
{
desc => 'submit update for register user and mark fixed',
initial_values => {
- name => 'Test User',
- rznvy => 'test@example.com',
+ name => 'Commenter',
+ rznvy => 'commenter@example.com',
may_show_name => 1,
add_alert => 1,
photo => '',
@@ -458,7 +458,7 @@ for my $test (
},
fields => {
submit_update => 1,
- rznvy => 'test@example.com',
+ rznvy => 'commenter@example.com',
update => 'update from a registered user',
add_alert => 0,
fixed => 1,
@@ -480,7 +480,7 @@ for my $test (
$mech->clear_emails_ok();
- $mech->log_in_ok( $user->email );
+ $mech->log_in_ok( $test->{fields}->{rznvy} );
$mech->get_ok("/report/$report_id");
my $values = $mech->visible_form_values( 'updateForm' );
@@ -498,6 +498,10 @@ for my $test (
is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
+ if ( $mech->uri->path eq '/report/update' ) {
+ print $mech->content;
+ }
+
is $mech->extract_problem_banner->{text}, $test->{endstate_banner}, 'submitted banner';
$mech->email_count_is(0);
@@ -510,7 +514,7 @@ for my $test (
my $update = $report->comments->first;
ok $update, 'found update';
is $update->text, $results->{update}, 'update text';
- is $update->user->email, 'test@example.com', 'update user';
+ is $update->user->email, $test->{fields}->{rznvy}, 'update user';
is $update->state, 'confirmed', 'update confirmed';
is $update->anonymous, $test->{anonymous}, 'user anonymous';
@@ -522,6 +526,84 @@ for my $test (
};
}
+foreach my $test (
+ {
+ desc => 'reporter submit update mark fixed',
+ initial_values => {
+ name => 'Test User',
+ rznvy => 'test@example.com',
+ may_show_name => 1,
+ add_alert => 1,
+ photo => '',
+ update => '',
+ fixed => undef,
+ },
+ fields => {
+ submit_update => 1,
+ rznvy => 'test@example.com',
+ update => 'update from owner',
+ add_alert => 0,
+ fixed => 1,
+ },
+ changed => {
+ update => 'Update from owner'
+ },
+ initial_banner => '',
+ alert => 1, # we signed up for alerts before, do not unsign us
+ anonymous => 0,
+ },
+) {
+ subtest $test->{desc} => sub {
+ # clear out comments for this problem to make
+ # checking details easier later
+ ok( $_->delete, 'deleted comment ' . $_->id )
+ for $report->comments;
+
+ $report->discard_changes;
+ $report->state('confirmed');
+ $report->update;
+
+ $report->discard_changes;
+ print 'state is ' . $report->state . "\n";
+
+ $mech->clear_emails_ok();
+
+ $mech->log_in_ok( $test->{fields}->{rznvy} );
+ $mech->get_ok("/report/$report_id");
+
+ my $values = $mech->visible_form_values( 'updateForm' );
+
+ is_deeply $values, $test->{initial_values}, 'initial form values';
+
+ is $mech->extract_problem_banner->{text}, $test->{initial_banner}, 'initial banner';
+
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields},
+ },
+ 'submit update'
+ );
+
+ is $mech->uri->path, "/report/update", "display questionnaire";
+
+ $mech->content_contains("Thanks, glad to hear it's been fixed! Could we just ask if you have ever reported a problem to a council before?");
+
+ $mech->email_count_is(0);
+
+ my $results = {
+ %{ $test->{fields} },
+ %{ $test->{changed} },
+ };
+
+ my $update = $report->comments->first;
+ ok $update, 'found update';
+ is $update->text, $results->{update}, 'update text';
+ is $update->user->email, $test->{fields}->{rznvy}, 'update user';
+ is $update->state, 'confirmed', 'update confirmed';
+ is $update->anonymous, $test->{anonymous}, 'user anonymous';
+ };
+}
+
ok $comment->delete, 'deleted comment';
$mech->delete_user('commenter@example.com');
$mech->delete_user('test@example.com');
diff --git a/templates/web/default/questionnaire/creator_fixed.html b/templates/web/default/questionnaire/creator_fixed.html
new file mode 100644
index 000000000..ebf392dd5
--- /dev/null
+++ b/templates/web/default/questionnaire/creator_fixed.html
@@ -0,0 +1,22 @@
+[% INCLUDE 'header.html', title = loc('Confirmation') %]
+
+<form method="post" action="/questionnaire/submit" id="questionnaire">
+<input type="hidden" name="type" value="questionnaire">
+<input type="hidden" name="token" value="[% token | html %]">
+
+<p>
+[% loc("Thanks, glad to hear it's been fixed! Could we just ask if you have ever reported a problem to a council before?") %]
+</p>
+
+<p align="center">
+<input type="radio" name="reported" id="reported_yes" value="Yes"[% ' checked' IF reported == 'Yes' %]>
+<label for="reported_yes">[% loc('Yes') %]</label>
+<input type="radio" name="reported" id="reported_no" value="No"[% ' checked' IF reported == 'No' %]>
+<label for="reported_no">[% loc('No') %]</label>
+</p>
+
+<p><input type="submit" name="submit" value="[% loc('Submit') %]"></p>
+
+</form>
+
+[% INCLUDE 'footer.html' %]