[Rt-commit] r13140 - in rt/branches/3.8-TESTING: .
sartak at bestpractical.com
sartak at bestpractical.com
Tue Jun 10 17:11:30 EDT 2008
Author: sartak
Date: Tue Jun 10 17:11:27 2008
New Revision: 13140
Added:
rt/branches/3.8-TESTING/t/web/rest.t
Modified:
rt/branches/3.8-TESTING/ (props changed)
Log:
r62130 at onn: sartak | 2008-06-10 17:10:22 -0400
Begin adding tests for the REST interface
Added: rt/branches/3.8-TESTING/t/web/rest.t
==============================================================================
--- (empty file)
+++ rt/branches/3.8-TESTING/t/web/rest.t Tue Jun 10 17:11:27 2008
@@ -0,0 +1,45 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 8;
+use RT::Test;
+
+my ($baseurl, $m) = RT::Test->started_ok;
+
+my $cf = RT::Test->load_or_create_custom_field(
+ Name => 'fu()n:k/',
+ Type => 'Freeform',
+ Queue => 'General',
+);
+ok($cf->Id, "created a CustomField");
+is($cf->Name, 'fu()n:k/', "correct CF name");
+
+my $queue = RT::Test->load_or_create_queue(Name => 'General');
+ok($queue->Id, "loaded the General queue");
+
+$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
+$text = join "\n", @lines;
+ok($text =~ s/Subject:\s*$/Subject: REST interface/m, "successfully replaced subject");
+
+$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, "REST interface", "subject successfully set");
More information about the Rt-commit
mailing list