aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin/bodies.t25
-rw-r--r--t/app/model/extra.t25
2 files changed, 46 insertions, 4 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t
index a07f19494..75f0f606f 100644
--- a/t/app/controller/admin/bodies.t
+++ b/t/app/controller/admin/bodies.t
@@ -217,6 +217,24 @@ subtest 'check text output' => sub {
$mech->content_lacks('<body');
};
+subtest 'disable form message editing' => sub {
+ $mech->get_ok('/admin/body/' . $body->id . '/test%20category');
+ $mech->submit_form_ok( { with_fields => {
+ disable => 1,
+ disable_message => 'Please ring us!',
+ note => 'Adding emergency message',
+ } } );
+ $mech->content_contains('Values updated');
+ my $contact = $body->contacts->find({ category => 'test category' });
+ is_deeply $contact->get_extra_fields, [{
+ description => 'Please ring us!',
+ code => '_fms_disable_',
+ protected => 'true',
+ variable => 'false',
+ disable_form => 'true',
+ }], 'right message added';
+};
+
}; # END of override wrap
@@ -230,7 +248,7 @@ FixMyStreet::override_config {
}, sub {
subtest 'group editing works' => sub {
$mech->get_ok('/admin/body/' . $body->id);
- $mech->content_contains( 'group</strong> is used for the top-level category' );
+ $mech->content_contains('Parent categories');
$mech->submit_form_ok( { with_fields => {
category => 'grouped category',
@@ -247,7 +265,7 @@ FixMyStreet::override_config {
subtest 'group can be unset' => sub {
$mech->get_ok('/admin/body/' . $body->id);
- $mech->content_contains( 'group</strong> is used for the top-level category' );
+ $mech->content_contains('Parent categories');
$mech->submit_form_ok( { with_fields => {
category => 'grouped category',
@@ -270,12 +288,11 @@ FixMyStreet::override_config {
BASE_URL => 'http://www.example.org',
COBRAND_FEATURES => {
category_groups => { default => 1 },
- multiple_category_groups => { default => 1 },
}
}, sub {
subtest 'multi group editing works' => sub {
$mech->get_ok('/admin/body/' . $body->id);
- $mech->content_contains( 'group</strong> is used for the top-level category' );
+ $mech->content_contains('Parent categories');
# have to do this as a post as adding a second group requires
# javascript
diff --git a/t/app/model/extra.t b/t/app/model/extra.t
index 55accb086..970efc465 100644
--- a/t/app/model/extra.t
+++ b/t/app/model/extra.t
@@ -79,6 +79,31 @@ subtest 'Default hash layout' => sub {
is_deeply $contact->extra, { _fields => \@fields }, '(sanity check layout)';
};
+ subtest 'updating extra field' => sub {
+ my $contact = get_test_contact();
+ my @fields = ( { code => 'ABC', description => 'ABC', variable => 'false', }, { code => 'DEF', description => 'DEF', variable => 'true' } );
+ $contact->set_extra_fields(@fields);
+ is_deeply $contact->get_extra_fields, \@fields, 'extra fields set...';
+ my $new_field = { code => 'ABC', description => 'XYZ', variable => 'false' };
+ $contact->update_extra_field($new_field);
+ $fields[0] = $new_field;
+ is_deeply $contact->get_extra_fields, \@fields, 'extra fields changed';
+ $new_field = { code => 'GHI', description => 'GHI', variable => 'false' };
+ $contact->update_extra_field($new_field);
+ push @fields, $new_field;
+ is_deeply $contact->get_extra_fields, \@fields, 'extra fields changed';
+ };
+
+ subtest 'removing extra field' => sub {
+ my $contact = get_test_contact();
+ my @fields = ( { code => 'ABC', description => 'ABC', variable => 'false', }, { code => 'DEF', description => 'DEF', variable => 'true' } );
+ $contact->set_extra_fields(@fields);
+ is_deeply $contact->get_extra_fields, \@fields, 'extra fields set...';
+ $contact->remove_extra_field('DEF');
+ pop @fields;
+ is_deeply $contact->get_extra_fields(), \@fields, 'extra field removed';
+ };
+
subtest 'metadata' => sub {
my $contact = get_test_contact();
is_deeply $contact->get_extra_metadata, {}, 'No extra metadata';