[Rt-commit] rt branch, 4.0/update-ticket-links-in-rest, created. rt-4.0.4-115-g87c7e93
Jason May
jasonmay at bestpractical.com
Fri Dec 9 19:22:24 EST 2011
The branch, 4.0/update-ticket-links-in-rest has been created
at 87c7e930b90a5da3235439e90e053aba8684c899 (commit)
- Log -----------------------------------------------------------------
commit 87c7e930b90a5da3235439e90e053aba8684c899
Author: Jason May <jasonmay at bestpractical.com>
Date: Thu Dec 8 12:05:12 2011 -0500
Use the correct value when checking for new changes for links in REST
diff --git a/share/html/REST/1.0/Forms/ticket/links b/share/html/REST/1.0/Forms/ticket/links
index 2fb9a43..3ece44d 100755
--- a/share/html/REST/1.0/Forms/ticket/links
+++ b/share/html/REST/1.0/Forms/ticket/links
@@ -100,7 +100,8 @@ if ($changes) {
my $tick = RT::Ticket->new($session{CurrentUser});
$tick->Load($nkey);
if ($tick->Id) {
- $nkey = $uri->FromObject($tick);
+ $uri->FromObject($tick);
+ $nkey = $uri->URI;
}
else {
$n = 0;
diff --git a/t/web/rest.t b/t/web/rest.t
index 5e7194c..e38f201 100644
--- a/t/web/rest.t
+++ b/t/web/rest.t
@@ -1,7 +1,9 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use RT::Test tests => 18;
+use RT::Interface::REST;
+
+use RT::Test tests => 22;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -69,3 +71,82 @@ for ("id: ticket/1",
$m->content_contains($_);
}
+# Create ticket 2 for testing ticket links
+for (2 .. 3) {
+ $m->post("$baseurl/REST/1.0/ticket/edit", [
+ user => 'root',
+ pass => 'password',
+ content => $text,
+ ], Content_Type => 'form-data');
+
+ $m->post(
+ "$baseurl/REST/1.0/ticket/1/links",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+ );
+
+ my $link_data = form_parse($m->content);
+
+ push @{$link_data->[0]->[1]}, 'DependsOn';
+ vpush($link_data->[0]->[2], 'DependsOn', $_);
+
+ $m->post(
+ "$baseurl/REST/1.0/ticket/1/links",
+ [
+ user => 'root',
+ pass => 'password',
+ content => form_compose($link_data),
+ ],
+ Content_Type => 'form-data',
+ );
+
+}
+
+# See what links get reported for ticket 1.
+$m->post(
+ "$baseurl/REST/1.0/ticket/1/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+
+# Verify that the link was added correctly.
+my $content = form_parse($m->content);
+my $depends_on = vsplit($content->[0]->[2]->{DependsOn});
+@$depends_on = sort @$depends_on;
+like(
+ $depends_on->[0], qr{/ticket/2$},
+ "Check ticket link.",
+) or diag("'content' obtained:\n", $m->content);
+
+like(
+ $depends_on->[1], qr{/ticket/3$},
+ "Check ticket link.",
+) or diag("'content' obtained:\n", $m->content);
+
+$m->post(
+ "$baseurl/REST/1.0/ticket/2/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+my ($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|;
+is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content);
+
+$m->post(
+ "$baseurl/REST/1.0/ticket/3/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|;
+is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list