aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2015-02-13 17:12:21 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-03-20 20:30:40 +0000
commit6d9c719d25e2450ee2f31a5f305b603c2f451594 (patch)
treeafc3b450191ce752cbe3ee67450875dba73e052e /t/open311
parent10b3a899af00205e46e177509a0b4c13bf746299 (diff)
Add Extra role to ease use of {extra} field.
Historically, the extra field has been used in two different ways by different cobrands, both as a list (e.g. Open311 category fields) and a hash (e.g. the Zurich cobrand). This commit consolidates usage, adding an API to make use of the field easier and always returning a hash for the code to use. Fixes #1018.
Diffstat (limited to 't/open311')
-rw-r--r--t/open311/populate-service-list.t21
1 files changed, 11 insertions, 10 deletions
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index b343b206d..99663030a 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -254,14 +254,14 @@ subtest 'check meta data population' => sub {
$contact->discard_changes;
- is_deeply $contact->extra, $extra, 'meta data saved';
+ is_deeply $contact->get_extra_fields, $extra, 'meta data saved';
};
for my $test (
{
desc => 'check meta data added to existing contact',
has_meta => 1,
- orig_meta => undef,
+ orig_meta => [],
end_meta => [ {
variable => 'true',
code => 'type',
@@ -332,7 +332,7 @@ for my $test (
{
desc => 'check meta data removed',
has_meta => 0,
- end_meta => undef,
+ end_meta => [],
orig_meta => [ {
variable => 'true',
code => 'type',
@@ -363,8 +363,8 @@ for my $test (
{
desc => 'check empty meta data handled',
has_meta => 1,
- orig_meta => undef,
- end_meta => undef,
+ orig_meta => [],
+ end_meta => [],
meta_xml => '<?xml version="1.0" encoding="utf-8"?>
<service_definition>
<service_code>100</service_code>
@@ -408,7 +408,8 @@ for my $test (
}
);
- $contact->update( { extra => $test->{orig_meta} } );
+ $contact->set_extra_fields(@{$test->{orig_meta}});
+ $contact->update;
my $o = Open311->new(
jurisdiction => 'mysociety',
@@ -427,7 +428,7 @@ for my $test (
$contact->discard_changes;
- is_deeply $contact->extra, $test->{end_meta}, 'meta data saved';
+ is_deeply $contact->get_extra_fields, $test->{end_meta}, 'meta data saved';
};
}
@@ -530,7 +531,7 @@ subtest 'check attribute ordering' => sub {
$contact->discard_changes;
- is_deeply $contact->extra, $extra, 'meta data re-ordered correctly';
+ is_deeply $contact->get_extra_fields, $extra, 'meta data re-ordered correctly';
};
subtest 'check bromely skip code' => sub {
@@ -610,7 +611,7 @@ subtest 'check bromely skip code' => sub {
$contact->discard_changes;
- is_deeply $contact->extra, $extra, 'only non std bromley meta data saved';
+ is_deeply $contact->get_extra_fields, $extra, 'only non std bromley meta data saved';
$processor->_current_body( $body );
$processor->_add_meta_to_contact( $contact );
@@ -650,7 +651,7 @@ subtest 'check bromely skip code' => sub {
$contact->discard_changes;
- is_deeply $contact->extra, $extra, 'all meta data saved for non bromley';
+ is_deeply $contact->get_extra_fields, $extra, 'all meta data saved for non bromley';
};
sub get_standard_xml {