aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/questionnaire.t9
-rw-r--r--t/app/controller/report_display.t49
-rw-r--r--t/app/controller/report_updates.t34
3 files changed, 90 insertions, 2 deletions
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index e56734bfc..af99a058e 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -204,7 +204,12 @@ foreach my $test (
}
my $result;
- $result = 'fixed' if $test->{fields}{been_fixed} eq 'Yes';
+ $result = 'fixed - user'
+ if $test->{fields}{been_fixed} eq 'Yes'
+ && $test->{problem_state} ne 'fixed';
+ $result = 'fixed'
+ if $test->{fields}{been_fixed} eq 'Yes'
+ && $test->{problem_state} eq 'fixed';
$result = 'confirmed' if $test->{fields}{been_fixed} eq 'No';
$result = 'unknown' if $test->{fields}{been_fixed} eq 'Unknown';
@@ -214,7 +219,7 @@ foreach my $test (
# Check the right HTML page has been returned
$mech->content_like( qr/<title>[^<]*Questionnaire/m );
$mech->content_contains( 'glad to hear it&rsquo;s been fixed' )
- if $result eq '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" )
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 1f857a387..49b524b44 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -235,6 +235,30 @@ for my $test (
banner_text => 'This problem has been fixed.',
fixed => 1
},
+ {
+ description => 'user fixed report',
+ date => DateTime->now,
+ state => 'fixed - user',
+ banner_id => 'fixed',
+ banner_text => 'This problem has been fixed.',
+ fixed => 1
+ },
+ {
+ description => 'council fixed report',
+ date => DateTime->now,
+ state => 'fixed - council',
+ banner_id => 'fixed',
+ banner_text => 'This problem has been fixed.',
+ fixed => 1
+ },
+ {
+ description => 'closed report',
+ date => DateTime->now,
+ state => 'closed',
+ banner_id => 'closed',
+ banner_text => 'This problem has been closed.',
+ fixed => 0
+ },
) {
subtest "banner for $test->{description}" => sub {
$report->confirmed( $test->{date}->ymd . ' ' . $test->{date}->hms );
@@ -260,6 +284,31 @@ for my $test (
};
}
+for my $test (
+ {
+ desc => 'no state dropdown if user not from authority',
+ from_authority => 0,
+ },
+ {
+ desc => 'state dropdown if user from authority',
+ from_authority => 1,
+ },
+) {
+ subtest $test->{desc} => sub {
+ $mech->log_in_ok( $user->email );
+ $user->from_authority( $test->{from_authority} );
+ $user->update;
+
+ $mech->get_ok("/report/$report_id");
+ my $fields = $mech->visible_form_values( 'updateForm' );
+ if ( $test->{from_authority} ) {
+ ok $fields->{state};
+ } else {
+ ok !$fields->{state};
+ }
+ };
+}
+
# tidy up
$mech->delete_user('test@example.com');
done_testing();
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 92c0ac567..5d14a893f 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -382,6 +382,40 @@ for my $test (
};
}
+$report->state('confirmed');
+$report->update;
+
+subtest 'check non authority user cannot change set state' => sub {
+ $mech->log_in_ok( $user->email );
+ $user->from_authority( 0 );
+ $user->update;
+
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok( {
+ form_number => 2,
+ fields => {
+ submit_update => 1,
+ id => $report_id,
+ name => $user->name,
+ rznvy => $user->email,
+ may_show_name => 1,
+ add_alert => 0,
+ photo => '',
+ update => 'this is a forbidden update',
+ state => 'fixed - council',
+ },
+ },
+ 'submitted with state',
+ );
+
+ is $mech->uri->path, "/report/update", "at /report/update";
+
+ my $errors = $mech->page_errors;
+ is_deeply $errors, [ 'There was a problem with your update. Please try again.' ], 'error message';
+
+ is $report->state, 'confirmed', 'state unchanged';
+};
+
for my $test (
{
desc => 'submit update for register user',