aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-04-30 13:56:31 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-05-06 16:09:29 +0100
commit730d25ae7218d731590b322d4f419a7df6d4e4fb (patch)
tree17a609759d5fb9ee49e216d485949cd94aa86845 /t/app/controller
parent683b188b288fe43526e1649c784fa44435559655 (diff)
Add ability to disallow updates in a category.
Add a tickbox to the category admin, and do not allow updates on reports made in those selected categories.
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin/bodies.t11
-rw-r--r--t/app/controller/report_updates.t33
2 files changed, 32 insertions, 12 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t
index c73a90da1..7ec7aed75 100644
--- a/t/app/controller/admin/bodies.t
+++ b/t/app/controller/admin/bodies.t
@@ -261,6 +261,17 @@ subtest 'open311 protection editing' => sub {
is $contact->get_extra_metadata('open311_protect'), 1, 'Open311 protect flag set';
};
+subtest 'updates disabling' => sub {
+ $mech->get_ok('/admin/body/' . $body->id . '/test%20category');
+ $mech->submit_form_ok( { with_fields => {
+ updates_disallowed => 1,
+ note => 'Disabling updates',
+ } } );
+ $mech->content_contains('Values updated');
+ my $contact = $body->contacts->find({ category => 'test category' });
+ is $contact->get_extra_metadata('updates_disallowed'), 1, 'Updates disallowed flag set';
+};
+
}; # END of override wrap
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 07ee48587..e8ab1cc85 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -22,6 +22,8 @@ my $user2 = $mech->create_user_ok('commenter@example.com', name => 'Commenter');
my $body = $mech->create_body_ok(2504, 'Westminster City Council');
+my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Other', email => 'other' );
+
my $dt = DateTime->new(
year => 2011,
month => 04,
@@ -1893,6 +1895,18 @@ for my $test (
};
}
+$mech->log_in_ok( $report->user->email );
+
+my %standard_fields = (
+ name => $report->user->name,
+ update => 'update text',
+ photo1 => '',
+ photo2 => '',
+ photo3 => '',
+ may_show_name => 1,
+ add_alert => 1,
+);
+
for my $test (
{
desc => 'update confirmed without marking as fixed leaves state unchanged',
@@ -2094,18 +2108,6 @@ for my $test (
},
) {
subtest $test->{desc} => sub {
- $mech->log_in_ok( $report->user->email );
-
- my %standard_fields = (
- name => $report->user->name,
- update => 'update text',
- photo1 => '',
- photo2 => '',
- photo3 => '',
- may_show_name => 1,
- add_alert => 1,
- );
-
my %expected_fields = (
%standard_fields,
%{ $test->{expected_form_fields} },
@@ -2178,4 +2180,11 @@ FixMyStreet::override_config {
};
};
+subtest 'check disabling of updates per category' => sub {
+ $contact->set_extra_metadata( updates_disallowed => 1 );
+ $contact->update;
+ $mech->get_ok("/report/$report_id");
+ $mech->content_lacks('Provide an update');
+};
+
done_testing();