Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Commit

rt branch, 4.0/time-fields-on-merge, created. rt-4.0.6-250-gce5520a

 

 

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded


ruz at bestpractical

Jul 25, 2012, 1:16 PM

Post #1 of 1 (64 views)
Permalink
rt branch, 4.0/time-fields-on-merge, created. rt-4.0.6-250-gce5520a

The branch, 4.0/time-fields-on-merge has been created
at ce5520aa140d236b0cfe7259cf1e326db9de8616 (commit)

- Log -----------------------------------------------------------------
commit ce5520aa140d236b0cfe7259cf1e326db9de8616
Author: Ruslan Zakirov <ruz [at] bestpractical>
Date: Thu Jul 26 00:10:32 2012 +0400

don't record transactions for Time* fields on merge

1) merge shouldn't generate any transactions except merge
2) recording Time* change transaction mess numbers in history.
As target ticket gets all transactions from both sides then
history is already correct. Yes, numbers in the history are
strange, for example you can have two txns saying time worked
was changed from 0 to X and from 0 to Y, but the difference
is what's important and is correct.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 1a3514c..3f2bdf5 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -2771,12 +2771,13 @@ sub _MergeInto {

# Update time fields
foreach my $type (qw(TimeEstimated TimeWorked TimeLeft)) {
-
- my $mutator = "Set$type";
- $MergeInto->$mutator(
- ( $MergeInto->$type() || 0 ) + ( $self->$type() || 0 ) );
-
+ $MergeInto->_Set(
+ Field => $type,
+ Value => ( $MergeInto->$type() || 0 ) + ( $self->$type() || 0 ),
+ RecordTransaction => 0,
+ );
}
+
#add all of this ticket's watchers to that ticket.
foreach my $watcher_type (qw(Requestors Cc AdminCc)) {

diff --git a/t/ticket/merge.t b/t/ticket/merge.t
index d06d541..3b92429 100644
--- a/t/ticket/merge.t
+++ b/t/ticket/merge.t
@@ -5,7 +5,7 @@ use warnings;


use RT;
-use RT::Test tests => '29';
+use RT::Test tests => '44';


# validate that when merging two tickets, the comments from both tickets
@@ -135,3 +135,46 @@ ok $user && $user->id, 'loaded or created user';
($status,$msg) = $t->MergeInto($t2->id);
ok($status, "Merged tickets: $msg");
}
+
+# check Time* fields after merge
+{
+ my @tickets;
+ my @values = (
+ { Worked => 11, Estimated => 17, Left => 6 },
+ { Worked => 7, Estimated => 12, Left => 5 },
+ );
+
+ for my $i (0 .. 1) {
+ my $t = RT::Ticket->new(RT->SystemUser);
+ $t->Create( Queue => 'general');
+ ok ($t->id);
+ push @tickets, $t;
+
+ foreach my $field ( keys %{ $values[ $i ] } ) {
+ my $method = "SetTime$field";
+ my ($status, $msg) = $t->$method( $values[ $i ]{ $field } );
+ ok $status, "changed $field on the ticket"
+ or diag "error: $msg";
+ }
+ }
+
+ my ($status, $msg) = $tickets[1]->MergeInto($tickets[0]->id);
+ ok($status,$msg);
+
+ my $t = RT::Ticket->new(RT->SystemUser);
+ $t->Load( $tickets[0]->id );
+ foreach my $field ( keys %{ $values[0] } ) {
+ my $method = "Time$field";
+ my $expected = 0;
+ $expected += $_->{ $field } foreach @values;
+ is $t->$method, $expected, "correct value";
+
+ my $from_history = 0;
+ my $txns = $t->Transactions;
+ while ( my $txn = $txns->Next ) {
+ next unless $txn->Type eq 'Set' && $txn->Field eq $method;
+ $from_history += $txn->NewValue - $txn->OldValue;
+ }
+ is $from_history, $expected, "history is correct";
+ }
+}

-----------------------------------------------------------------------
_______________________________________________
Rt-commit mailing list
Rt-commit [at] lists
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.