[Rt-commit] rt branch, 4.0/force-lc-ticket-type, created. rt-4.0.4-147-g9629e75

Jason May jasonmay at bestpractical.com
Tue Dec 20 15:54:44 EST 2011


The branch, 4.0/force-lc-ticket-type has been created
        at  9629e75d37d951944640bd77b7bb15e01e4a65c1 (commit)

- Log -----------------------------------------------------------------
commit ce2c3835df395f3f05f658ec51a1d87adedbc846
Author: Jason May <jasonmay at bestpractical.com>
Date:   Tue Dec 20 14:20:14 2011 -0500

    Force ticket types to be lowercase
    
    This makes comparisons easier and more robust.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 316fbff..9454ce6 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -472,7 +472,7 @@ sub Create {
         TimeWorked      => $args{'TimeWorked'},
         TimeEstimated   => $args{'TimeEstimated'},
         TimeLeft        => $args{'TimeLeft'},
-        Type            => $args{'Type'},
+        Type            => lc $args{'Type'},
         Starts          => $Starts->ISO,
         Started         => $Started->ISO,
         Resolved        => $Resolved->ISO,
@@ -717,6 +717,13 @@ sub Create {
     }
 }
 
+sub SetType {
+    my $self = shift;
+    my $value = shift;
+
+    # Force lowercase
+    return $self->_Set(Field => 'Type', Value => lc($value), @_);
+}
 
 
 
diff --git a/t/api/ticket.t b/t/api/ticket.t
index 92c8a85..b02aa68 100644
--- a/t/api/ticket.t
+++ b/t/api/ticket.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 87;
+use RT::Test tests => 88;
 
 
 {
@@ -254,3 +254,19 @@ ok(!$id,$msg);
 
 }
 
+diag("Test ticket types with different cases");
+{
+my $t = RT::Ticket->new(RT->SystemUser);
+$t->Create(
+    Queue => 'general',
+    Subject => 'type test 1',
+    Type => 'Ticket',
+);
+my $t2 = RT::Ticket->new(RT->SystemUser);
+$t2->Create(
+    Queue => 'general',
+    Subject => 'type test 2',
+    Type => 'ticket',
+);
+is($t->Type, $t2->Type, "Ticket types are lowercased, therefore identical");
+}

commit 9629e75d37d951944640bd77b7bb15e01e4a65c1
Author: Jason May <jasonmay at bestpractical.com>
Date:   Tue Dec 20 14:34:16 2011 -0500

    Add a script to retroactively canonicalize ticket types

diff --git a/etc/upgrade/canonicalize-ticket-type.pl b/etc/upgrade/canonicalize-ticket-type.pl
new file mode 100644
index 0000000..6c42132
--- /dev/null
+++ b/etc/upgrade/canonicalize-ticket-type.pl
@@ -0,0 +1,64 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+#                                          <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+use strict;
+use warnings;
+
+use RT;
+RT::LoadConfig();
+RT->Config->Set('LogToScreen' => 'debug');
+RT::Init();
+
+$| = 1;
+
+use RT::Tickets;
+my $tickets = RT::Tickets->new( RT->SystemUser );
+$tickets->UnLimit;
+
+while ( my $ticket = $tickets->Next ) {
+    $ticket->__Set(Field => 'Type', Value => lc($ticket->Type));
+}

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


More information about the Rt-commit mailing list