[Rt-commit] rt branch, 4.0/canonicalize-uris-in-ticketsql, updated. rt-4.0.6-251-ged28c8b

Thomas Sibley trs at bestpractical.com
Fri Aug 3 18:45:02 EDT 2012


The branch, 4.0/canonicalize-uris-in-ticketsql has been updated
       via  ed28c8bc04870f6403877a971bf9812a1ac392b7 (commit)
      from  5075951855fe6bfb4f3698386a1a3d4827f25259 (commit)

Summary of changes:
 t/api/uri-canonicalize.t | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 t/api/uri-canonicalize.t

- Log -----------------------------------------------------------------
commit ed28c8bc04870f6403877a971bf9812a1ac392b7
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Aug 3 15:44:26 2012 -0700

    Tests for the new RT::URI->CanonicalizeURI

diff --git a/t/api/uri-canonicalize.t b/t/api/uri-canonicalize.t
new file mode 100644
index 0000000..288569c
--- /dev/null
+++ b/t/api/uri-canonicalize.t
@@ -0,0 +1,54 @@
+use strict;
+use warnings;
+use RT::Test tests => undef;
+
+my @warnings;
+local $SIG{__WARN__} = sub {
+    push @warnings, "@_";
+};
+
+# Create ticket
+my $ticket = RT::Test->create_ticket( Queue => 1, Subject => 'test ticket' );
+ok $ticket->id, 'created ticket';
+
+# Create article class
+my $class = RT::Class->new( $RT::SystemUser );
+$class->Create( Name => 'URItest - '. $$ );
+ok $class->id, 'created a class';
+
+# Create article
+my $article = RT::Article->new( $RT::SystemUser );
+$article->Create(
+    Name    => 'Testing URI parsing - '. $$,
+    Summary => 'In which this should load',
+    Class   => $class->Id
+);
+ok $article->id, 'create article';
+
+# Test permutations of URIs
+my $ORG = RT->Config->Get('Organization');
+my $URI = RT::URI->new( RT->SystemUser );
+my %expected = (
+    # tickets
+    "1"                                 => "fsck.com-rt://$ORG/ticket/1",
+    "t:1"                               => "fsck.com-rt://$ORG/ticket/1",
+    "fsck.com-rt://$ORG/ticket/1"       => "fsck.com-rt://$ORG/ticket/1",
+
+    # articles
+    "a:1"                               => "fsck.com-article://$ORG/article/1",
+    "fsck.com-article://$ORG/article/1" => "fsck.com-article://$ORG/article/1",
+
+    # random stuff
+    "http://$ORG"                       => "http://$ORG",
+    "mailto:foo\@example.com"           => "mailto:foo\@example.com",
+    "invalid"                           => "invalid",   # doesn't trigger die
+);
+for my $uri (sort keys %expected) {
+    is $URI->CanonicalizeURI($uri), $expected{$uri}, "canonicalized as expected";
+}
+
+is_deeply \@warnings, [
+    "Could not determine a URI scheme for invalid\n",
+], "expected warnings";
+
+done_testing;

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


More information about the Rt-commit mailing list