[Rt-commit] rt branch, 4.4/serialize-json-initialdata, updated. rt-4.4.1-357-g0f6da4e
Shawn Moore
shawn at bestpractical.com
Mon Mar 20 17:30:59 EDT 2017
The branch, 4.4/serialize-json-initialdata has been updated
via 0f6da4e08f74651dd293198901ce28f70b3b5e1c (commit)
via 45826dd54cf810885e0d42b5ad2f9e87caf666f6 (commit)
from e0725da3922b124cbcc9994eec4ff11c465d907d (commit)
Summary of changes:
lib/RT/Migrate/Serializer/JSON.pm | 23 ++++++++++++++++++++---
t/api/initialdata-roundtrip.t | 27 +++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 45826dd54cf810885e0d42b5ad2f9e87caf666f6
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Mon Mar 20 21:19:01 2017 +0000
Fix serialized OCFs for queues
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index dd35607..d9fdcca 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -301,9 +301,14 @@ sub CanonicalizeObjects {
my $self = shift;
$self->_CanonicalizeManyToMany(
- object_class => 'RT::ObjectCustomField',
- object_primary_ref => 'CustomField',
- primary_class => 'RT::CustomField',
+ object_class => 'RT::ObjectCustomField',
+ object_primary_ref => 'CustomField',
+ primary_class => 'RT::CustomField',
+ canonicalize_object => sub {
+ ref($_->{ObjectId})
+ ? $self->_GetSerializedByRef($_->{ObjectId})->{Name}
+ : $_->{ObjectId};
+ },
);
$self->_CanonicalizeManyToMany(
commit 0f6da4e08f74651dd293198901ce28f70b3b5e1c
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Mon Mar 20 21:30:44 2017 +0000
Roundtrip CFVs (with tests)
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index d9fdcca..e7e2a7a 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -312,6 +312,18 @@ sub CanonicalizeObjects {
);
$self->_CanonicalizeManyToMany(
+ object_class => 'RT::CustomFieldValue',
+ object_primary_ref => 'CustomField',
+ primary_class => 'RT::CustomField',
+ primary_key => 'Values',
+ canonicalize_object => sub {
+ my %object = %$_;
+ delete @object{qw/id CustomField Created LastUpdated Creator LastUpdatedBy/};
+ return \%object;
+ },
+ );
+
+ $self->_CanonicalizeManyToMany(
object_class => 'RT::ObjectClass',
object_primary_ref => 'Class',
primary_class => 'RT::Class',
diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 9903a7f..48c4079 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -52,6 +52,20 @@ my @tests = (
($ok, $msg) = $cf->AddToObject($features);
ok($ok, $msg);
+
+ ($ok, $msg) = $cf->AddValue(Name => '0.1', Description => 'Prototype', SortOrder => '1');
+ ok($ok, $msg);
+
+ ($ok, $msg) = $cf->AddValue(Name => '1.0', Description => 'Gold', SortOrder => '10');
+ ok($ok, $msg);
+
+ # these next two are intentionally added in an order different from their SortOrder
+ ($ok, $msg) = $cf->AddValue(Name => '2.0', Description => 'Remaster', SortOrder => '20');
+ ok($ok, $msg);
+
+ ($ok, $msg) = $cf->AddValue(Name => '1.1', Description => 'Gold Bugfix', SortOrder => '11');
+ ok($ok, $msg);
+
},
present => sub {
my $bugs = RT::Queue->new(RT->SystemUser);
@@ -79,6 +93,19 @@ my @tests = (
my $general = RT::Queue->new(RT->SystemUser);
$general->Load('General');
ok(!$cf->IsAdded($general->Id), 'CF is not on General queue');
+
+ my @values = map { {
+ Name => $_->Name,
+ Description => $_->Description,
+ SortOrder => $_->SortOrder,
+ } } @{ $cf->Values->ItemsArrayRef };
+
+ is_deeply(\@values, [
+ { Name => '0.1', Description => 'Prototype', SortOrder => '1' },
+ { Name => '1.0', Description => 'Gold', SortOrder => '10' },
+ { Name => '1.1', Description => 'Gold Bugfix', SortOrder => '11' },
+ { Name => '2.0', Description => 'Remaster', SortOrder => '20' },
+ ], 'CF values');
},
},
);
-----------------------------------------------------------------------
More information about the rt-commit
mailing list