[Bps-public-commit] rt-extension-repeatticket branch, master, updated. 26467b4d0693c5de3bbd14ff3ed26c53b2e09af2

? sunnavy sunnavy at bestpractical.com
Tue May 21 10:54:36 EDT 2013


The branch, master has been updated
       via  26467b4d0693c5de3bbd14ff3ed26c53b2e09af2 (commit)
       via  2f2ed60d1dc3e2eb455effb0aadac0c0a1ff3ea7 (commit)
      from  f6175807eb0c2fa2234eb68e1fad937c0b834776 (commit)

Summary of changes:
 lib/RT/Extension/RepeatTicket.pm | 12 +++++++
 t/cf.t                           | 76 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
 create mode 100644 t/cf.t

- Log -----------------------------------------------------------------
commit 2f2ed60d1dc3e2eb455effb0aadac0c0a1ff3ea7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 21 21:57:24 2013 +0800

    cf tests

diff --git a/t/cf.t b/t/cf.t
new file mode 100644
index 0000000..88ab2ce
--- /dev/null
+++ b/t/cf.t
@@ -0,0 +1,64 @@
+use strict;
+use warnings;
+
+use RT::Extension::RepeatTicket::Test tests => undef;
+
+use_ok('RT::Extension::RepeatTicket');
+require_ok('bin/rt-repeat-ticket');
+
+my $cf = RT::CustomField->new(RT->SystemUser);
+ok( $cf->Create( Name => 'foo', Queue => 0, Type => 'Freeform' ) );
+
+my ( $baseurl, $m ) = RT::Test->started_ok();
+
+ok( $m->login( 'root', 'password' ), 'logged in' );
+
+$m->submit_form_ok({
+    form_name => 'CreateTicketInQueue',
+    fields    => {
+       'Queue' => 'General' },
+    }, 'Click to create ticket');
+
+$m->content_contains('Enable Recurrence');
+
+diag "Create a ticket with a recurrence in the General queue.";
+
+my $day = DateTime->today;
+
+$m->submit_form_ok(
+    {
+        form_name => 'TicketCreate',
+        fields    => {
+            'Subject' => 'test cf values',
+            'Object-RT::Ticket--CustomField-' . $cf->id . '-Value' => 'bar',
+            'repeat-coexistent-number'                             => 2,
+            'repeat-enabled'                                       => 1,
+            'repeat-type'                                          => 'daily',
+            'repeat-details-daily'                                 => 'day',
+            'repeat-details-daily-day'                             => 1,
+        },
+    },
+    'Create'
+);
+
+$m->text_like( qr/Ticket\s(\d+)\screated in queue/);
+
+my $ticket_id = $m->content =~ /Ticket\s(\d+)\screated in queue/;
+ok( $ticket_id, "Created ticket with id: $ticket_id" );
+my $ticket = RT::Ticket->new(RT->SystemUser);
+$ticket->Load($ticket_id);
+
+my $tomorrow = $day->clone->add( days => 1 );
+ok(!(RT::Repeat::Ticket::Run->run('-date=' . $tomorrow->ymd)),
+   'Ran recurrence script for two weeks from now: ' . $tomorrow->ymd );
+my $second = $ticket_id + 1;
+ok( $m->goto_ticket($second), "Recurrence ticket $second created.");
+
+my $ticket2 = RT::Ticket->new( RT->SystemUser );
+$ticket2->Load($second);
+is( $ticket2->FirstCustomFieldValue('Original Ticket'),
+    $ticket_id, 'Original Ticket is set' );
+is( $ticket2->FirstCustomFieldValue('foo'), 'bar', 'cf foo is cloned' );
+
+undef $m;
+done_testing;

commit 26467b4d0693c5de3bbd14ff3ed26c53b2e09af2
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 21 22:51:13 2013 +0800

    set "Original Ticket" for the original ticket itself too
    
    and unset if repeat is disabled

diff --git a/lib/RT/Extension/RepeatTicket.pm b/lib/RT/Extension/RepeatTicket.pm
index 31afae5..81a9c88 100644
--- a/lib/RT/Extension/RepeatTicket.pm
+++ b/lib/RT/Extension/RepeatTicket.pm
@@ -65,6 +65,18 @@ sub SetRepeatAttribute {
     );
 
     ProcessTransactions($ticket, \%old, \%repeat_args) if $old_attr;
+    if ( $content->{'repeat-enabled'} ) {
+        $ticket->AddCustomFieldValue(
+            Field => 'Original Ticket',
+            Value => $ticket->id,
+        );
+    }
+    else {
+        $ticket->DeleteCustomFieldValue(
+            Field => 'Original Ticket',
+            Value => $ticket->id,
+        );
+    }
 
     my ($attr) = $ticket->Attributes->Named('RepeatTicketSettings');
 
diff --git a/t/cf.t b/t/cf.t
index 88ab2ce..40e6667 100644
--- a/t/cf.t
+++ b/t/cf.t
@@ -47,6 +47,8 @@ my $ticket_id = $m->content =~ /Ticket\s(\d+)\screated in queue/;
 ok( $ticket_id, "Created ticket with id: $ticket_id" );
 my $ticket = RT::Ticket->new(RT->SystemUser);
 $ticket->Load($ticket_id);
+is( $ticket->FirstCustomFieldValue('Original Ticket'),
+    $ticket_id, 'Original Ticket is set' );
 
 my $tomorrow = $day->clone->add( days => 1 );
 ok(!(RT::Repeat::Ticket::Run->run('-date=' . $tomorrow->ymd)),
@@ -60,5 +62,15 @@ is( $ticket2->FirstCustomFieldValue('Original Ticket'),
     $ticket_id, 'Original Ticket is set' );
 is( $ticket2->FirstCustomFieldValue('foo'), 'bar', 'cf foo is cloned' );
 
+my ($attr) = $ticket->Attributes->Named('RepeatTicketSettings');
+ok( RT::Extension::RepeatTicket::SetRepeatAttribute(
+    $ticket,
+    %{ $attr->Content },
+    'repeat-enabled' => 0,
+));
+
+is( $ticket->FirstCustomFieldValue('Original Ticket'),
+    undef, 'Original Ticket is unset' );
+
 undef $m;
 done_testing;

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



More information about the Bps-public-commit mailing list