[Rt-commit] rt branch, 4.0/shred-object-custom-fields, created. rt-4.0.8-105-g5130331

Thomas Sibley trs at bestpractical.com
Fri Nov 2 18:23:41 EDT 2012


The branch, 4.0/shred-object-custom-fields has been created
        at  5130331c713e0297141a52c4f9c6466f4f9e9111 (commit)

- Log -----------------------------------------------------------------
commit 800c568df694030ad6ccc936bae103ff622d3de5
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Nov 2 15:18:49 2012 -0700

    Failing tests for shredding ObjectCustomFields when a CustomField is shredded

diff --git a/t/shredder/02cfs.t b/t/shredder/02cfs.t
new file mode 100644
index 0000000..91bd089
--- /dev/null
+++ b/t/shredder/02cfs.t
@@ -0,0 +1,50 @@
+
+use strict;
+use warnings;
+
+use Test::Deep;
+use File::Spec;
+use Test::More;
+use RT::Test ();
+BEGIN {
+    my $shredder_utils = RT::Test::get_relocatable_file('utils.pl',
+        File::Spec->curdir());
+    require $shredder_utils;
+}
+init_db();
+create_savepoint('clean');
+
+my $cf = RT::Test->load_or_create_custom_field(
+    Name        => "Favorite Color",
+    LookupType  => "RT::Queue-RT::Ticket",
+    Type        => "FreeformSingle",
+);
+ok $cf->id, "Created ticket CF";
+create_savepoint('clean_with_cf');
+
+diag 'global ticket custom field';
+{
+    my $global_queue = RT::Queue->new(RT->SystemUser);
+    my ($ok, $msg) = $cf->AddToObject($global_queue);
+    ok $ok, "Added ticket CF globally: $msg";
+
+	my $shredder = shredder_new();
+	$shredder->PutObjects( Objects => $cf );
+	$shredder->WipeoutAll;
+	cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
+}
+
+diag 'queue-specific ticket custom field';
+{
+    restore_savepoint('clean_with_cf');
+    my $general = RT::Test->load_or_create_queue( Name => 'General' );
+    my ($ok, $msg) = $cf->AddToObject($general);
+    ok $ok, "Added ticket CF to General queue: $msg";
+
+	my $shredder = shredder_new();
+	$shredder->PutObjects( Objects => $cf );
+	$shredder->WipeoutAll;
+	cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
+}
+
+done_testing;

commit 5130331c713e0297141a52c4f9c6466f4f9e9111
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Nov 2 15:22:36 2012 -0700

    Shred ObjectCustomFields when shredding a custom field

diff --git a/lib/RT/Shredder/CustomField.pm b/lib/RT/Shredder/CustomField.pm
index 43b759e..1cdbfed 100644
--- a/lib/RT/Shredder/CustomField.pm
+++ b/lib/RT/Shredder/CustomField.pm
@@ -73,6 +73,11 @@ sub __DependsOn
 # Custom field values
     push( @$list, $self->Values );
 
+# Applications of this CF
+    my $applied = RT::ObjectCustomFields->new( $self->CurrentUser );
+    $applied->LimitToCustomField( $self->Id );
+    push @$list, $applied;
+
 # Ticket custom field values
     my $objs = RT::ObjectCustomFieldValues->new( $self->CurrentUser );
     $objs->LimitToCustomField( $self->Id );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list