aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-06-07 15:32:27 +0100
committerStruan Donald <struan@exo.org.uk>2018-06-11 10:32:53 +0100
commitd8c4befc47afee2da94dbc2411a849f14cd1a7f7 (patch)
tree123927066bfd6ba0022b8a9fa60cdbf97010b1f5 /t
parentcfd510fdaa9839e01162c68ce09163f0ac9dbb30 (diff)
include automated field when editing contacts
Display fields that are automatically filled in the contact editing form otherwise the data is lost. Also include the automated field in the form. Fixes #2136
Diffstat (limited to 't')
-rw-r--r--t/app/controller/admin/reportextrafields.t56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/app/controller/admin/reportextrafields.t b/t/app/controller/admin/reportextrafields.t
index fb06665f4..4549eeadf 100644
--- a/t/app/controller/admin/reportextrafields.t
+++ b/t/app/controller/admin/reportextrafields.t
@@ -120,6 +120,34 @@ FixMyStreet::override_config {
$contact->update;
};
+ subtest 'check contact updating does not remove server_set' => sub {
+ $contact->set_extra_fields(({ code => 'POT', automated => 'server_set' }));
+ $contact->update;
+
+ $mech->get_ok("/admin/body/" . $body->id . "/" . $contact->category);
+ $mech->submit_form_ok( { with_fields => {
+ email => 'test4@example.com',
+ note => 'test4 note',
+ } } );
+
+ $mech->content_like(qr'test4@example.com's);
+
+ $contact->discard_changes;
+ my $meta_data = $contact->get_extra_fields;
+ is $contact->email, 'test4@example.com', 'contact updated';
+ is_deeply $meta_data, [ {
+ order => 0,
+ datatype => 'string',
+ datatype_description => '',
+ description => '',
+ required => 'false',
+ variable => 'true',
+ code => 'POT',
+ automated => 'server_set'
+ } ], "automated fields not unset";
+ };
+
+
subtest 'Create and update new ReportExtraFields' => sub {
my $extra_fields = [];
@@ -181,11 +209,39 @@ FixMyStreet::override_config {
{ name => "name1", key => "key1" },
]
};
+
$object->discard_changes;
is_deeply $object->get_extra_fields, $extra_fields, 'new list field was added';
is $object->language, "en-gb", "Correct language was set";
$mech->get_ok("/admin/reportextrafields/" . $object->id);
+ $mech->submit_form_ok({ with_fields => {
+ "metadata[2].order" => "3",
+ "metadata[2].code" => "automated_test",
+ "metadata[2].required" => undef,
+ "metadata[2].notice" => "",
+ "metadata[2].description" => "",
+ "metadata[2].datatype_description" => "",
+ "metadata[2].datatype" => "string",
+ "metadata[2].automated" => "server_set",
+ }});
+
+ push @$extra_fields, {
+ order => "3",
+ code => "automated_test",
+ required => "false",
+ variable => "true",
+ description => "",
+ datatype_description => "",
+ datatype => "string",
+ automated => "server_set",
+ };
+
+ $object->discard_changes;
+ is_deeply $object->get_extra_fields, $extra_fields, 'new automated field was added';
+ is $object->language, "en-gb", "Correct language was set";
+
+ $mech->get_ok("/admin/reportextrafields/" . $object->id);
$mech->submit_form_ok( { with_fields => {
"metadata[1].values[1].key" => "key2",
"metadata[1].values[1].name" => "name2",