[Rt-commit] rt branch, 4.0/rest-link-to-articles, created. rt-4.0.5-80-g0338800

? sunnavy sunnavy at bestpractical.com
Thu Mar 1 07:45:50 EST 2012


The branch, 4.0/rest-link-to-articles has been created
        at  033880064a7960061f678acd180e5df32535f7f3 (commit)

- Log -----------------------------------------------------------------
commit 31a1c83e9ea8846b427522a140abc556dc257722
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 1 20:20:19 2012 +0800

    allow to link to articles in rest

diff --git a/bin/rt.in b/bin/rt.in
index 5e1c053..f631e62 100755
--- a/bin/rt.in
+++ b/bin/rt.in
@@ -905,7 +905,7 @@ sub link {
     
     if (@ARGV == 3) {
         my ($from, $rel, $to) = @ARGV;
-        if ($from !~ /^\d+$/ || $to !~ /^\d+$/) {
+        if ($from !~ /^\d+$/ || $to !~ /^(?:a:)?\d+$/) {
             my $bad = $from =~ /^\d+$/ ? $to : $from;
             whine "Invalid $type ID '$bad' specified.";
             $bad = 1;
diff --git a/share/html/REST/1.0/ticket/link b/share/html/REST/1.0/ticket/link
index aa80b0d..e0cf818 100755
--- a/share/html/REST/1.0/ticket/link
+++ b/share/html/REST/1.0/ticket/link
@@ -81,7 +81,7 @@ if ($id && $object && $id != $object) {
     goto OUTPUT;
 }
 $id ||= $object;
-unless ($id =~ /^\d+$/ && $to =~ /^\d+$/) {
+unless ($id =~ /^\d+$/ && $to =~ /^(?:a:)?\d+$/) {
     my $bad = ($id !~ /^\d+$/) ? $id : $to;
     $output = $r->path_info. "\n";
     $output .= "Invalid ticket id: '$bad'.\n";

commit 033880064a7960061f678acd180e5df32535f7f3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 1 20:32:48 2012 +0800

    cli link to articles test

diff --git a/t/web/command_line_link_to_articles.t b/t/web/command_line_link_to_articles.t
new file mode 100644
index 0000000..26ee65f
--- /dev/null
+++ b/t/web/command_line_link_to_articles.t
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+use Test::Expect;
+use RT::Test tests => 12, actual_server => 1;
+
+my $class = RT::Class->new( RT->SystemUser );
+my ( $class_id, $msg ) = $class->Create( Name => 'foo' );
+ok( $class_id, $msg );
+
+my $article = RT::Article->new( RT->SystemUser );
+( my $article_id, $msg ) =
+  $article->Create( Class => 'foo', Summary => 'article summary' );
+ok( $article_id, $msg );
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+my $rt_tool_path = "$RT::BinPath/rt";
+
+$ENV{'RTUSER'}   = 'root';
+$ENV{'RTPASSWD'} = 'password';
+$RT::Logger->debug(
+    "Connecting to server at " . RT->Config->Get('WebBaseURL') );
+$ENV{'RTSERVER'} = RT->Config->Get('WebBaseURL');
+$ENV{'RTDEBUG'}  = '1';
+$ENV{'RTCONFIG'} = '/dev/null';
+
+expect_run(
+    command => "$rt_tool_path shell",
+    prompt  => 'rt> ',
+    quit    => 'quit',
+);
+expect_send( q{create -t ticket set subject='new ticket'},
+    "creating a ticket..." );
+
+expect_like( qr/Ticket \d+ created/, "created the ticket" );
+expect_handle->before() =~ /Ticket (\d+) created/;
+my $ticket_id = $1;
+expect_send(
+    "link $ticket_id RefersTo a:$article_id",
+    "link $ticket_id RefersTo a:$article_id"
+);
+expect_like( qr/Created link $ticket_id RefersTo a:$article_id/,
+    'created link' );
+expect_send( "show -s ticket/$ticket_id/links", "show ticket links" );
+expect_like( qr/RefersTo: [\w\d\.\-]+:\/\/[\w\d\.]+\/article\/$article_id/,
+    "found new created link" );
+
+expect_quit();
+

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


More information about the Rt-commit mailing list