[Rt-commit] rt branch, 4.0/rest-load-ticket-cf-with-queue-limit, updated. rt-4.0.5-81-g09bbeae

? sunnavy sunnavy at bestpractical.com
Mon Feb 27 05:50:58 EST 2012


The branch, 4.0/rest-load-ticket-cf-with-queue-limit has been updated
       via  09bbeae82e86bcb149fb8d37f400bfd16797de5f (commit)
      from  3a7f36396400279a3658686f94491e3663d3dbce (commit)

Summary of changes:
 t/web/rest_cfs_with_same_name.t |   88 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 t/web/rest_cfs_with_same_name.t

- Log -----------------------------------------------------------------
commit 09bbeae82e86bcb149fb8d37f400bfd16797de5f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Feb 27 18:50:13 2012 +0800

    test cfs with same name in rest

diff --git a/t/web/rest_cfs_with_same_name.t b/t/web/rest_cfs_with_same_name.t
new file mode 100644
index 0000000..958f671
--- /dev/null
+++ b/t/web/rest_cfs_with_same_name.t
@@ -0,0 +1,88 @@
+use strict;
+use warnings;
+use RT::Interface::REST;
+
+use RT::Test tests => 25;
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+for my $queue_name (qw/foo bar/) {
+
+    my $queue = RT::Test->load_or_create_queue( Name => $queue_name );
+    ok( $queue, "created queue $queue_name" );
+    my $cf = RT::Test->load_or_create_custom_field(
+        Name  => 'test',
+        Type  => 'Freeform',
+        Queue => $queue_name,
+    );
+    ok( $cf->id, "created cf test for queue $queue_name " . $cf->id );
+
+    $m->post(
+        "$baseurl/REST/1.0/ticket/new",
+        [
+            user   => 'root',
+            pass   => 'password',
+            format => 'l',
+        ]
+    );
+
+    my $text = $m->content;
+    my @lines = $text =~ m{.*}g;
+    shift @lines;    # header
+
+    # cfs aren't in the default ticket form
+    push @lines, "CF.{test}: baz";
+
+    $text = join "\n", @lines;
+
+    ok( $text =~ s/Subject:\s*$/Subject: test cf/m,
+        "successfully replaced subject" );
+    ok( $text =~ s/Queue: General\s*$/Queue: $queue_name/m,
+        "successfully replaced Queue" );
+
+    $m->post(
+        "$baseurl/REST/1.0/ticket/edit",
+        [
+            user => 'root',
+            pass => 'password',
+            content => $text,
+        ],
+        Content_Type => 'form-data'
+    );
+
+    my ($id) = $m->content =~ /Ticket (\d+) created/;
+    ok( $id, "got ticket #$id" );
+
+    my $ticket = RT::Ticket->new( RT->SystemUser );
+    $ticket->Load($id);
+    is( $ticket->id,      $id,       "loaded the REST-created ticket" );
+    is( $ticket->Subject, "test cf", "subject successfully set" );
+    is( $ticket->Queue, $queue->id, "queue successfully set" );
+    is( $ticket->FirstCustomFieldValue("test"), "baz", "cf successfully set" );
+
+    $m->post(
+        "$baseurl/REST/1.0/ticket/show",
+        [
+            user   => 'root',
+            pass   => 'password',
+            format => 'l',
+            id     => "ticket/$id",
+        ]
+    );
+    $text = $m->content;
+    like( $text, qr/^CF\.{test}: baz\s*$/m, 'cf value in rest show' );
+
+    $text =~ s{.*}{}; # remove header
+    $text =~ s!CF\.{test}: baz!CF.{test}: newbaz!;
+    $m->post(
+        "$baseurl/REST/1.0/ticket/edit",
+        [
+            user => 'root',
+            pass => 'password',
+            content => $text,
+        ],
+        Content_Type => 'form-data'
+    );
+    $m->content =~ /Ticket ($id) updated/;
+    is( $ticket->FirstCustomFieldValue("test"), "newbaz", "cf successfully updated" );
+}
+

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


More information about the Rt-commit mailing list