[Rt-commit] r9304 - in rtir/branches/2.3-EXPERIMENTAL: . etc
etc/upgrade/2.3.9 lib/RT/Action lib/RT/Condition t
ruz at bestpractical.com
ruz at bestpractical.com
Sun Oct 14 21:31:09 EDT 2007
Author: ruz
Date: Sun Oct 14 21:31:08 2007
New Revision: 9304
Added:
rtir/branches/2.3-EXPERIMENTAL/etc/upgrade/2.3.9/
rtir/branches/2.3-EXPERIMENTAL/etc/upgrade/2.3.9/content
rtir/branches/2.3-EXPERIMENTAL/lib/RT/Action/RTIR_MergeIPs.pm
rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR_Merge.pm
Modified:
rtir/branches/2.3-EXPERIMENTAL/MANIFEST
rtir/branches/2.3-EXPERIMENTAL/META.yml
rtir/branches/2.3-EXPERIMENTAL/etc/initialdata
rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
rtir/branches/2.3-EXPERIMENTAL/t/013-custom-field-ip.t
Log:
* merge IPs on ticket merge
* bump version as we updated DB
Modified: rtir/branches/2.3-EXPERIMENTAL/MANIFEST
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/MANIFEST (original)
+++ rtir/branches/2.3-EXPERIMENTAL/MANIFEST Sun Oct 14 21:31:08 2007
@@ -1,7 +1,6 @@
CHANGES
etc/add_constituency
etc/initialdata
-etc/RTIR_Config.pm
etc/logo/gif/rtir-logo-badge-3d.gif
etc/logo/gif/rtir-logo-badge-shadow.gif
etc/logo/gif/rtir-logo-badge.gif
@@ -14,6 +13,7 @@
etc/logo/psd/rtir-logo-badge-shadow.psd
etc/logo/psd/rtir-logo-badge.psd
etc/logo/svg/rtir.svg
+etc/RTIR_Config.pm
etc/upgrade/1.0.3/content
etc/upgrade/1.1.1/content
etc/upgrade/1.1.3/content
@@ -28,6 +28,7 @@
etc/upgrade/2.1.1/content
etc/upgrade/2.1.3/content
etc/upgrade/2.3.0/content
+etc/upgrade/2.3.9/content
etc/upgrade/upgrade.pl
html/Callbacks/RTIR/autohandler/Default
html/Callbacks/RTIR/Elements/EditCustomField/EditComponentName
@@ -40,6 +41,7 @@
html/Callbacks/RTIR/Elements/SelectOwner/UpdateObjectList
html/Callbacks/RTIR/Elements/ShowCustomFields/MassageCustomFields
html/Callbacks/RTIR/Elements/Tabs/Default
+html/Callbacks/RTIR/NoAuth/css/3.5-default/titlebox.css/Default
html/Callbacks/RTIR/RTFM/Elements/Tabs/Default
html/Callbacks/RTIR/Search/Elements/PickBasics/Default
html/Callbacks/RTIR/Search/Elements/PickCFs/MassageCustomFields
@@ -157,6 +159,7 @@
lib/RT/Action/RTIR_ChangeChildOwnership.pm
lib/RT/Action/RTIR_ChangeParentOwnership.pm
lib/RT/Action/RTIR_FindIP.pm
+lib/RT/Action/RTIR_MergeIPs.pm
lib/RT/Action/RTIR_OpenParent.pm
lib/RT/Action/RTIR_ResolveChildren.pm
lib/RT/Action/RTIR_SetBlockState.pm
@@ -182,6 +185,7 @@
lib/RT/Condition/RTIR_CloseTicket.pm
lib/RT/Condition/RTIR_CustomerResponse.pm
lib/RT/Condition/RTIR_LinkingToIncident.pm
+lib/RT/Condition/RTIR_Merge.pm
lib/RT/Condition/RTIR_ReopenTicket.pm
lib/RT/Condition/RTIR_RequireConstituencyChange.pm
lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
Modified: rtir/branches/2.3-EXPERIMENTAL/META.yml
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/META.yml (original)
+++ rtir/branches/2.3-EXPERIMENTAL/META.yml Sun Oct 14 21:31:08 2007
@@ -28,4 +28,4 @@
Regexp::Common: 0
Regexp::Common::net::CIDR: 0
tests: t/*.t t/*/*.t
-version: 2.3.8
+version: 2.3.9
Modified: rtir/branches/2.3-EXPERIMENTAL/etc/initialdata
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/etc/initialdata (original)
+++ rtir/branches/2.3-EXPERIMENTAL/etc/initialdata Sun Oct 14 21:31:08 2007
@@ -311,6 +311,10 @@
Description => 'Set IP custom field from message content' , # loc
ExecModule => 'RTIR_FindIP',
},
+ { Name => 'RTIR merge IPs', # loc
+ Description => 'Merge multiple IPs on ticket merge' , # loc
+ ExecModule => 'RTIR_MergeIPs',
+ },
{ Name => 'RTIR Set Constituency', # loc
Description => 'Set and cascade Constituency custom field' , # loc
ExecModule => 'RTIR_SetConstituency',
@@ -373,6 +377,11 @@
ApplicableTransTypes => 'Create,AddLink',
ExecModule => 'RTIR_LinkingToIncident',
},
+ { Name => 'RTIR Merge', # loc
+ Description => 'Whenever ticket is merged into another one', # loc
+ ApplicableTransTypes => 'AddLink',
+ ExecModule => 'RTIR_Merge',
+ },
);
@Scrips = (
@@ -545,6 +554,12 @@
ScripAction => 'RTIR parse message for IPs',
Template => 'Blank' },
+ { Description => "MergeIPs",
+ Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
+ ScripCondition => 'RTIR Merge',
+ ScripAction => 'RTIR merge IPs',
+ Template => 'Blank' },
+
{ Description => "SetConstituency",
Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
ScripCondition => 'RTIR Require Constituency Change',
Added: rtir/branches/2.3-EXPERIMENTAL/etc/upgrade/2.3.9/content
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/etc/upgrade/2.3.9/content Sun Oct 14 21:31:08 2007
@@ -0,0 +1,24 @@
+ at ScripActions = (
+ { Name => 'RTIR merge IPs', # loc
+ Description => 'Merge multiple IPs on ticket merge' , # loc
+ ExecModule => 'RTIR_MergeIPs',
+ },
+);
+
+ at ScripConditions = (
+ { Name => 'RTIR Merge', # loc
+ Description => 'Whenever ticket is merged into another one', # loc
+ ApplicableTransTypes => 'AddLink',
+ ExecModule => 'RTIR_Merge',
+ },
+);
+
+ at Scrips = (
+ { Description => "MergeIPs",
+ Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
+ ScripCondition => 'RTIR Merge',
+ ScripAction => 'RTIR merge IPs',
+ Template => 'Blank',
+ },
+);
+
Added: rtir/branches/2.3-EXPERIMENTAL/lib/RT/Action/RTIR_MergeIPs.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/Action/RTIR_MergeIPs.pm Sun Oct 14 21:31:08 2007
@@ -0,0 +1,58 @@
+package RT::Action::RTIR_MergeIPs;
+
+use strict;
+use warnings;
+
+use base 'RT::Action::RTIR';
+
+=head2 Prepare
+
+Always run this.
+
+=cut
+
+sub Prepare { return 1 }
+
+=head2 Commit
+
+Change the ownership of children.
+
+=cut
+
+sub Commit {
+ my $self = shift;
+
+ my $txn = $self->TransactionObj;
+ my $uri = $txn->NewValue;
+
+ my $uri_obj = RT::URI->new( $self->CurrentUser );
+ my ($status) = $uri_obj->FromURI( $uri );
+ unless ( $status && $uri_obj->Resolver && $uri_obj->Scheme ) {
+ $RT::Logger->error( "Couldn't resolve '$uri' into a URI." );
+ return 1;
+ }
+
+ my $target = $uri_obj->Object;
+ return 1 if $target->id eq $txn->ObjectId;
+
+ my $source = RT::Ticket->new( $self->CurrentUser );
+ $source->LoadById( $txn->ObjectId );
+ my $values = $source->CustomFieldValues( '_RTIR_IP' );
+ while ( my $value = $values->Next ) {
+ my ($status, $msg) = $target->AddCustomFieldValue(
+ Value => $value->Content,
+ Field => '_RTIR_IP',
+ );
+ $RT::Logger->error("Couldn't add IP address: $msg")
+ unless $status;
+ }
+
+ return 1;
+}
+
+eval "require RT::Action::RTIR_MergeIPs_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_MergeIPs_Vendor.pm});
+eval "require RT::Action::RTIR_MergeIPs_Local";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_MergeIPs_Local.pm});
+
+1;
Added: rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR_Merge.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR_Merge.pm Sun Oct 14 21:31:08 2007
@@ -0,0 +1,28 @@
+package RT::Condition::RTIR_Merge;
+
+use strict;
+use warnings;
+
+use base 'RT::Condition::RTIR';
+
+=head2 IsApplicable
+
+If ticket has been merged.
+
+=cut
+
+sub IsApplicable {
+ my $self = shift;
+
+ my $txn = $self->TransactionObj;
+ return 0 unless $txn->Type eq 'AddLink';
+ return 0 unless $txn->Field eq 'MergedInto';
+ return 1;
+}
+
+eval "require RT::Condition::RTIR_Merge_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_Merge_Vendor.pm});
+eval "require RT::Condition::RTIR_Merge_Local";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_Merge_Local.pm});
+
+1;
Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm (original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm Sun Oct 14 21:31:08 2007
@@ -46,7 +46,7 @@
#
package RT::IR;
-our $VERSION = '2.3.8';
+our $VERSION = '2.3.9';
use warnings;
use strict;
Modified: rtir/branches/2.3-EXPERIMENTAL/t/013-custom-field-ip.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/013-custom-field-ip.t (original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/013-custom-field-ip.t Sun Oct 14 21:31:08 2007
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 430;
+use Test::More tests => 475;
require "t/rtir-test.pl";
@@ -545,3 +545,80 @@
is( $tickets->Count, 0, "didn't finnd ticket" ) or diag "but found ". $tickets->First->id;
}
+diag "merge ticket, IPs should be merged";
+{
+ my $incident_id = create_rtir_ticket_ok(
+ $agent, 'Incidents',
+ { Subject => "test" },
+ );
+ my $b1_id = create_block(
+ $agent, {
+ Subject => "test ip",
+ Incident => $incident_id,
+ },
+ { IP => '172.16.0.1' },
+ );
+ my $b2_id = create_block(
+ $agent, {
+ Subject => "test ip",
+ Incident => $incident_id,
+ },
+ { IP => '172.16.0.2' },
+ );
+
+ display_ticket($agent, $b1_id);
+ $agent->follow_link_ok({ text => 'Merge' }, "Followed merge link");
+ $agent->form_number(3);
+ $agent->field('SelectedTicket', $b2_id);
+ $agent->submit;
+ ok_and_content_like($agent, qr{Merge Successful}, 'Merge Successful');
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $b1_id );
+ ok $ticket->id, 'loaded ticket';
+ my $values = $ticket->CustomFieldValues('_RTIR_IP');
+ my %has = map { $_->Content => 1 } @{ $values->ItemsArrayRef };
+ is( scalar values %has, 2, "both IPs are there");
+ ok( $has{ '172.16.0.1' }, "has value" )
+ or diag "but has values ". join ", ", keys %has;
+ ok( $has{ '172.16.0.2' }, "has value" )
+ or diag "but has values ". join ", ", keys %has;
+}
+
+diag "merge ticket with the same IP";
+{
+ my $incident_id = create_rtir_ticket_ok(
+ $agent, 'Incidents',
+ { Subject => "test" },
+ );
+ my $b1_id = create_block(
+ $agent, {
+ Subject => "test ip",
+ Incident => $incident_id,
+ },
+ { IP => '172.16.0.1' },
+ );
+ my $b2_id = create_block(
+ $agent, {
+ Subject => "test ip",
+ Incident => $incident_id,
+ },
+ { IP => '172.16.0.1' },
+ );
+
+ display_ticket($agent, $b1_id);
+ $agent->follow_link_ok({ text => 'Merge' }, "Followed merge link");
+ $agent->form_number(3);
+ $agent->field('SelectedTicket', $b2_id);
+ $agent->submit;
+ ok_and_content_like($agent, qr{Merge Successful}, 'Merge Successful');
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $b1_id );
+ ok $ticket->id, 'loaded ticket';
+ my $values = $ticket->CustomFieldValues('_RTIR_IP');
+ my @has = map $_->Content, @{ $values->ItemsArrayRef };
+ is( scalar @has, 1, "only one IP") or diag "values: @has";
+ is( $has[0], '172.16.0.1', "has value" );
+}
+
More information about the Rt-commit
mailing list