[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.6-215-gcc9cbab
? sunnavy
sunnavy at bestpractical.com
Mon Nov 29 02:13:40 EST 2010
The branch, 3.9-trunk has been updated
via cc9cbab51b9c541295baa33d0066581dce64754b (commit)
via 9ea80c94b14cfd73d5a244af3ddf4cb438050113 (commit)
from d1408db6ec81f1f61791bdf0f03fd1ee9129e430 (commit)
Summary of changes:
share/html/Elements/MakeClicky | 4 +-
t/ticket/clicky.t | 170 +++++++++++++++++++++++-----------------
2 files changed, 99 insertions(+), 75 deletions(-)
- Log -----------------------------------------------------------------
commit 9ea80c94b14cfd73d5a244af3ddf4cb438050113
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Nov 29 14:42:21 2010 +0800
rewrite clicky.t: test clicky with httpurl,httpurl_overwrite and none
diff --git a/t/ticket/clicky.t b/t/ticket/clicky.t
index 344b9f8..e64410a 100644
--- a/t/ticket/clicky.t
+++ b/t/ticket/clicky.t
@@ -3,81 +3,23 @@
use strict;
use warnings;
use Test::More;
-use RT::Test noinitialdata => 1, tests => 14;
-my %clicky;
+use RT::Test tests => 15;
-BEGIN {
-
- %clicky = map { $_ => 1 } grep $_, RT->Config->Get('Active_MakeClicky');
-
-# this's hack: we have to use RT::Test first to get RT->Config work, this
-# results in the fact that we can't plan any more
- unless ( keys %clicky ) {
- SKIP: {
- skip "No active Make Clicky actions", 14;
- }
- exit 0;
- }
-}
-
-my ($baseurl, $m) = RT::Test->started_ok;
-
-use_ok('MIME::Entity');
-
-my $CurrentUser = RT->SystemUser;
-
-my $queue = RT::Queue->new($CurrentUser);
-$queue->Load('General') || Abort(loc("Queue could not be loaded."));
-
-my $message = MIME::Entity->build(
- Subject => 'test',
+my $plain = MIME::Entity->build(
+ Subject => 'plain mime',
+ Type => 'text/plain',
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 = RT::Ticket->new( $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");
-
-ok $m->login, 'logged in';
-ok $m->goto_ticket($id), 'opened diplay page of the ticket';
-
-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' );
-}
-
-{
-
-my $message = MIME::Entity->build(
+my $html = MIME::Entity->build(
Type => 'text/html',
- Subject => 'test',
+ Subject => 'html mime',
Data => <<END,
If you have some problems with RT you could find help
on <a href="http://wiki.bestpractical.com">wiki</a>
@@ -87,25 +29,64 @@ Best regards. BestPractical Team.
END
);
-my $ticket = RT::Ticket->new($CurrentUser);
-my ($id) = $ticket->Create(
+
+my $ticket = RT::Ticket->new( RT->SystemUser );
+
+my ($plain_id) = $ticket->Create(
+ Subject => 'test',
+ Queue => 'General',
+ MIMEObj => $plain,
+);
+ok($plain_id, "We created a ticket #$plain_id");
+
+my ($html_id) = $ticket->Create(
Subject => 'test',
- Queue => $queue->Id,
- MIMEObj => $message,
+ Queue => 'General',
+ MIMEObj => $html,
);
-ok( $id, "We created a ticket #$id" );
-ok( $ticket->Transactions->First->Content, "Has some content" );
+ok($html_id, "We created a ticket #$html_id");
+
+diag 'test no clicky';
+{
+ RT->Config->Set( 'Active_MakeClicky' => () );
+ my ( $baseurl, $m ) = RT::Test->started_ok;
+ ok $m->login, 'logged in';
+ $m->goto_ticket($plain_id);
+
+ my @links = $m->find_link(
+ tag => 'a',
+ url => 'http://wiki.bestpractical.com',
+ );
+ ok( @links == 0, 'no clicky link found with plain message' );
+
+ @links = $m->find_link(
+ tag => 'a',
+ url => 'http://rt3.fsck.com',
+ );
+ ok( @links == 0, 'no extra clicky link found with html message' );
+}
-ok $m->login, 'logged in';
-ok $m->goto_ticket($id), 'opened diplay page of the ticket';
+diag 'test httpurl';
+{
+ RT::Test->stop_server;
+ RT->Config->Set( 'Active_MakeClicky' => qw/httpurl/ );
+ my ( $baseurl, $m ) = RT::Test->started_ok;
+ ok $m->login, 'logged in';
+ $m->goto_ticket($plain_id);
-SKIP: {
- skip "httpurl action disabled", 2 unless $clicky{'httpurl'};
my @links = $m->find_link(
tag => 'a',
url => 'http://wiki.bestpractical.com',
text => 'Open URL',
);
+ ok( scalar @links, 'found clicky link' );
+
+ $m->goto_ticket($html_id);
+ @links = $m->find_link(
+ tag => 'a',
+ url => 'http://wiki.bestpractical.com',
+ text => 'Open URL',
+ );
ok( @links == 0, 'not make clicky links clicky twice' );
@links = $m->find_link(
@@ -116,4 +97,19 @@ SKIP: {
ok( scalar @links, 'found clicky link' );
}
+diag 'test httpurl_overwrite';
+{
+ RT::Test->stop_server;
+ RT->Config->Set( 'Active_MakeClicky' => 'httpurl_overwrite' );
+ my ( $baseurl, $m ) = RT::Test->started_ok;
+ ok $m->login, 'logged in';
+ ok $m->goto_ticket($plain_id), 'opened diplay page of the ticket';
+
+ my @links = $m->find_link(
+ tag => 'a',
+ url => 'http://wiki.bestpractical.com',
+ text => 'http://wiki.bestpractical.com',
+ );
+ ok( scalar @links, 'found clicky link' );
}
+
commit cc9cbab51b9c541295baa33d0066581dce64754b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Nov 29 15:04:29 2010 +0800
try to parse #anchor in makeclicky
diff --git a/share/html/Elements/MakeClicky b/share/html/Elements/MakeClicky
index 53d6914..3b1410a 100644
--- a/share/html/Elements/MakeClicky
+++ b/share/html/Elements/MakeClicky
@@ -71,12 +71,12 @@ my %actions = (
my @types = (
{
name => "httpurl",
- regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/,
+ regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?/,
action => "url",
},
{
name => "httpurl_overwrite",
- regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}/,
+ regex => qr/$RE{URI}{HTTP}{-keep}{-scheme => 'https?'}(?:#\S+)?/,
action => "url_overwrite",
},
);
diff --git a/t/ticket/clicky.t b/t/ticket/clicky.t
index e64410a..a6af7f6 100644
--- a/t/ticket/clicky.t
+++ b/t/ticket/clicky.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
use Test::More;
-use RT::Test tests => 15;
+use RT::Test tests => 18;
my $plain = MIME::Entity->build(
Subject => 'plain mime',
@@ -12,6 +12,9 @@ my $plain = MIME::Entity->build(
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.
+
+to test anchor:
+https://wiki.bestpractical.com/test#anchor
--
Best regards. BestPractical Team.
END
@@ -24,6 +27,9 @@ my $html = MIME::Entity->build(
If you have some problems with RT you could find help
on <a href="http://wiki.bestpractical.com">wiki</a>
or find known bugs on http://rt3.fsck.com
+
+to test anchor:
+https://wiki.bestpractical.com/test#anchor
--
Best regards. BestPractical Team.
END
@@ -81,6 +87,13 @@ diag 'test httpurl';
);
ok( scalar @links, 'found clicky link' );
+ @links = $m->find_link(
+ tag => 'a',
+ url => 'https://wiki.bestpractical.com/test#anchor',
+ text => 'Open URL',
+ );
+ ok( scalar @links, 'found clicky link with anchor' );
+
$m->goto_ticket($html_id);
@links = $m->find_link(
tag => 'a',
@@ -95,6 +108,13 @@ diag 'test httpurl';
text => 'Open URL',
);
ok( scalar @links, 'found clicky link' );
+
+ @links = $m->find_link(
+ tag => 'a',
+ url => 'https://wiki.bestpractical.com/test#anchor',
+ text => 'Open URL',
+ );
+ ok( scalar @links, 'found clicky link with anchor' );
}
diag 'test httpurl_overwrite';
@@ -111,5 +131,13 @@ diag 'test httpurl_overwrite';
text => 'http://wiki.bestpractical.com',
);
ok( scalar @links, 'found clicky link' );
+
+ @links = $m->find_link(
+ tag => 'a',
+ url => 'https://wiki.bestpractical.com/test#anchor',
+ # extra space on every 30 chars
+ text => 'https://wiki.bestpractical.com /test#anchor',
+ );
+ ok( scalar @links, 'found clicky link with anchor' );
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list