[Rt-commit] r5032 - in rt/branches/3.7-EXPERIMENTAL: .
lib/t/regression
ruz at bestpractical.com
ruz at bestpractical.com
Fri Apr 14 14:41:48 EDT 2006
Author: ruz
Date: Fri Apr 14 14:41:41 2006
New Revision: 5032
Added:
rt/branches/3.7-EXPERIMENTAL/lib/t/regression/27-make_clicky.t
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky
Log:
r2382 at cubic-pc: cubic | 2006-04-14 22:44:46 +0400
* make clicky tests and fixes
Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/MakeClicky Fri Apr 14 14:41:41 2006
@@ -41,6 +41,12 @@
}
};
+my $escaper = sub {
+ my $content = shift;
+ RT::Interface::Web::EscapeUTF8( \$content );
+ return $content;
+};
+
# Hook to add more Clicky types
# XXX Have to have Page argument, as Mason gets caller wrong in Callback?
$m->comp("/Elements/Callback", Page => "/Elements/MakeClicky",
@@ -49,6 +55,7 @@
handle => \$handle
);
+
# Filter
my %active;
$active{$_}++ for RT->Config->Get('Active_MakeClicky');
@@ -81,24 +88,20 @@
my $pos = 0;
while ( $$content =~ /($regexp)/gsio ) {
- my $match_start = pos($$content) - length($1);
- if ( $match_start != $pos ) {
- my $plain = substr( $$content, $pos, $match_start );
- RT::Interface::Web::EscapeUTF8( \$plain );
- substr( $$content, $pos, $match_start ) = $plain;
- $match_start = $pos + length($plain);
+ my $match = $1;
+ my $skipped_len = pos($$content) - $pos - length($match);
+ if ( $skipped_len > 0 ) {
+ my $plain = $escaper->( substr( $$content, $pos, $skipped_len ) );
+ substr( $$content, $pos, $skipped_len ) = $plain;
+ $pos += ( $skipped_len = length($plain) );
}
{
- my $plain = $handle->( %ARGS, value => ($1 || '') );
- substr( $$content, $match_start, length($1) ) = $plain;
- pos($$content) = $pos = $match_start + length($plain);
+ my $plain = $handle->( %ARGS, value => $match );
+ substr( $$content, $pos, length($match) ) = $plain;
+ pos($$content) = ( $pos += length($plain) );
}
}
-{
- my $plain = substr( $$content, $pos );
- RT::Interface::Web::EscapeUTF8( \$plain );
- substr( $$content, $pos ) = $plain;
-}
+substr( $$content, $pos ) = $escaper->( substr( $$content, $pos ) ) unless $pos == length $$content;
</%INIT>
<%doc>
Added: rt/branches/3.7-EXPERIMENTAL/lib/t/regression/27-make_clicky.t
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/regression/27-make_clicky.t Fri Apr 14 14:41:41 2006
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More qw(no_plan);
+
+BEGIN {
+ use RT;
+ RT::LoadConfig();
+ RT::Init();
+}
+
+my %clicky = map { $_ => 1 } grep $_, RT->Config->Get('Active_MakeClicky');
+unless ( keys %clicky ) {
+ plan skip_all => 'No active Make Clicky actions';
+}
+
+use_ok('MIME::Entity');
+
+my $CurrentUser = $RT::SystemUser;
+
+my $queue = new RT::Queue($CurrentUser);
+$queue->Load('General') || Abort(loc("Queue could not be loaded."));
+
+my $message = MIME::Entity->build(
+ Subject => 'test',
+ Data => <<END,
+If you have some problems with RT you could find help
+on http://wiki.bestpractical.com or subscribe to
+the rt-users\@lists.bestpractical.com.
+
+--
+Best regards. BestPractical Team.
+END
+);
+
+my $ticket = new RT::Ticket( $CurrentUser );
+my ($id) = $ticket->Create(
+ Subject => 'test',
+ Queue => $queue->Id,
+ MIMEObj => $message,
+);
+ok($id, "We created a ticket #$id");
+ok($ticket->Transactions->First->Content, "Has some content");
+
+use Test::WWW::Mechanize;
+use constant BaseURL => "http://localhost:".RT->Config->Get('WebPort').RT->Config->Get('WebPath')."/";
+my $m = Test::WWW::Mechanize->new;
+isa_ok($m, 'Test::WWW::Mechanize');
+
+$m->get_ok( BaseURL."?user=root;pass=password" );
+$m->content_like(qr/Logout/, 'we did log in');
+
+$m->get_ok( BaseURL."Ticket/Display.html?id=$id" );
+
+SKIP: {
+ skip "httpurl action disabled", 1 unless $clicky{'httpurl'};
+ my @links = $m->find_link(
+ tag => 'a',
+ url => 'http://wiki.bestpractical.com',
+ text => '[Open URL]',
+ );
+ ok( scalar @links, 'found clicky link' );
+}
+
+SKIP: {
+ skip "httpurl_overwrite action disabled", 1 unless $clicky{'httpurl_overwrite'};
+ my @links = $m->find_link(
+ tag => 'a',
+ url => 'http://wiki.bestpractical.com',
+ text => 'http://wiki.bestpractical.com',
+ );
+ ok( scalar @links, 'found clicky link' );
+}
+
More information about the Rt-commit
mailing list