[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-758-gfe1fc0a
Shawn Moore
sartak at bestpractical.com
Fri Sep 10 17:50:22 EDT 2010
The branch, 3.9-trunk has been updated
via fe1fc0ace0239b5e08aa413347b7d5c09e2162b7 (commit)
via 0c2410f3f226862321767dca9cff6509d14897d3 (commit)
via 2b78c6b5203355ab6b5f1df7dffd2f1f17c0358c (commit)
via 6721fa43f49cc981266d6b51c0e6de915b92b2b6 (commit)
via 49ef25cfc4b4f1fb2c90fda36aafc7e260b2a159 (commit)
via 5f6671d567cfdbd9b4c8ec62a33f965694fa5358 (commit)
via 93c47886104c634ecc031f9b0f3e7bf211143396 (commit)
via 418aaa980f64781d36de6fb18ff98ff9106cde87 (commit)
via e5cf95371b834d904c9fa821b7e224e671bfe9a8 (commit)
via d4c21feb6b713d6a10b303cdb055f7d965677e89 (commit)
via 7f7538cc9f68c6795f7f290620269a8ce0a56fb1 (commit)
via 5f5c9848d42afcc8bbaebfa174dff4f8f51bdf36 (commit)
via a05d62151c2d0cb3df14aa2e1152ec19ce4bfd66 (commit)
via 53547047cbdafbfc052aa4c23ef3817624c8a48b (commit)
via 28cfc9ab04c43622821d7bae5982dbb3fd700f7b (commit)
via 1b052cb5c760e6211979939fbd11b953adab49d4 (commit)
via 2dadad140bd8b9417e965df21dfed1208741f51a (commit)
via b66f71f8068610e29ef34d6031b177181141e754 (commit)
via fee89ac4ebce1488d531cf0849a309957972b7aa (commit)
via 2dd6935c2eab21fbf83ad9d28c24adcdbab2674a (commit)
from 6a4c663e497263fc267bd88c7a5758f0869754ca (commit)
Summary of changes:
sbin/rt-test-dependencies.in | 1 +
share/html/Tools/Elements/Tabs | 4 +
.../WithHeaders/dhandler => Tools/Watching.html} | 66 ++--
share/html/Tools/index.html | 5 +
t/web/watching-queues.t | 378 ++++++++++++++++++++
5 files changed, 428 insertions(+), 26 deletions(-)
copy share/html/{Ticket/Attachment/WithHeaders/dhandler => Tools/Watching.html} (66%)
create mode 100644 t/web/watching-queues.t
- Log -----------------------------------------------------------------
commit 2dd6935c2eab21fbf83ad9d28c24adcdbab2674a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 16:34:16 2010 -0400
Begin /Tools/Watching.html
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
new file mode 100644
index 0000000..1c6a90b
--- /dev/null
+++ b/share/html/Tools/Watching.html
@@ -0,0 +1,52 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Elements/Header, Title => loc("Watching Queues") &>
+<& Elements/Tabs,
+ current_tab => "Tools/Watching.html",
+ Title => loc("Watching Queues") &>
+
commit fee89ac4ebce1488d531cf0849a309957972b7aa
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 16:34:29 2010 -0400
Add Watching to the tools tabs and frontpage
diff --git a/share/html/Tools/Elements/Tabs b/share/html/Tools/Elements/Tabs
index eca6268..daa6005 100644
--- a/share/html/Tools/Elements/Tabs
+++ b/share/html/Tools/Elements/Tabs
@@ -66,6 +66,10 @@ my $tabs = {
title => loc('My Day'),
path => 'Tools/MyDay.html',
},
+ e => {
+ title => loc('Watching Queues'),
+ path => 'Tools/Watching.html',
+ },
};
my $can_see_dashboards = $session{CurrentUser}->HasRight(Right => 'SubscribeDashboard', Object => $RT::System)
diff --git a/share/html/Tools/index.html b/share/html/Tools/index.html
index 8bb0c2b..b4639b6 100644
--- a/share/html/Tools/index.html
+++ b/share/html/Tools/index.html
@@ -69,6 +69,11 @@ my $tabs = {
path => '/Tools/MyDay.html',
description => loc('Easy updating of your open tickets'),
},
+ E => {
+ title => loc('Watching Queues'),
+ path => '/Tools/Watching.html',
+ description => loc('A list of queues you watch'),
+ },
};
my $can_see_dashboards = $session{CurrentUser}->HasRight(Right => 'SubscribeDashboard', Object => $RT::System)
commit b66f71f8068610e29ef34d6031b177181141e754
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 16:58:15 2010 -0400
The dumb, slow way to calculate what queues you watch
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index 1c6a90b..eb4c871 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -50,3 +50,31 @@
current_tab => "Tools/Watching.html",
Title => loc("Watching Queues") &>
+<ul>
+
+<%perl>
+my $Queues = RT::Queues->new($session{CurrentUser});
+$Queues->UnLimit;
+while (my $Queue = $Queues->Next) {
+ my @types;
+
+ for my $type ($Queue->AllRoleGroupTypes) {
+ push @types, $type if $Queue->IsWatcher(
+ PrincipalId => $session{CurrentUser}->id,
+ Type => $type,
+ );
+ }
+
+ next if !@types;
+</%perl>
+
+ <li><% $Queue->Name %>
+ <ul>
+% for my $type (@types) {
+ <li><% $type %></li>
+% }
+ </ul>
+ </li>
+% }
+
+</ul>
commit 2dadad140bd8b9417e965df21dfed1208741f51a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 17:04:17 2010 -0400
Use ShowQueue not $Queue->Name
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index eb4c871..12a0461 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -68,7 +68,7 @@ while (my $Queue = $Queues->Next) {
next if !@types;
</%perl>
- <li><% $Queue->Name %>
+ <li><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
<ul>
% for my $type (@types) {
<li><% $type %></li>
commit 1b052cb5c760e6211979939fbd11b953adab49d4
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 17:36:52 2010 -0400
Add some CSS classes
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index 12a0461..971890a 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -50,7 +50,7 @@
current_tab => "Tools/Watching.html",
Title => loc("Watching Queues") &>
-<ul>
+<ul class="queue-list">
<%perl>
my $Queues = RT::Queues->new($session{CurrentUser});
@@ -68,10 +68,10 @@ while (my $Queue = $Queues->Next) {
next if !@types;
</%perl>
- <li><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
- <ul>
+ <li class="queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
+ <ul class="queue-roles">
% for my $type (@types) {
- <li><% $type %></li>
+ <li class="queue-role"><% $type %></li>
% }
</ul>
</li>
commit 28cfc9ab04c43622821d7bae5982dbb3fd700f7b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Aug 19 17:47:54 2010 -0400
Be smarter when you're watching no queues
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index 971890a..99ebee9 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -50,9 +50,8 @@
current_tab => "Tools/Watching.html",
Title => loc("Watching Queues") &>
-<ul class="queue-list">
-
<%perl>
+my $count = 0;
my $Queues = RT::Queues->new($session{CurrentUser});
$Queues->UnLimit;
while (my $Queue = $Queues->Next) {
@@ -66,6 +65,15 @@ while (my $Queue = $Queues->Next) {
}
next if !@types;
+
+ my $first = ($count == 0);
+ if ($first) {
+</%perl>
+ <ul class="queue-list">
+<%perl>
+ }
+
+ $count += @types;
</%perl>
<li class="queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
@@ -77,4 +85,9 @@ while (my $Queue = $Queues->Next) {
</li>
% }
-</ul>
+% if ($count) {
+ </ul>
+% } else {
+ <p><&|/l&>You are not watching any queues.</&></p>
+% }
+
commit 53547047cbdafbfc052aa4c23ef3817624c8a48b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 17:58:15 2010 -0400
Improve class names for watching queues elements
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index 99ebee9..b1b962b 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -76,8 +76,8 @@ while (my $Queue = $Queues->Next) {
$count += @types;
</%perl>
- <li class="queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
- <ul class="queue-roles">
+ <li class="queue-roles"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
+ <ul class="queue-role-list">
% for my $type (@types) {
<li class="queue-role"><% $type %></li>
% }
commit a05d62151c2d0cb3df14aa2e1152ec19ce4bfd66
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 17:58:56 2010 -0400
Add Test::XPath dev dependency
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index ddbe5b4..d94e727 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -271,6 +271,7 @@ Test::Builder 0.77 # needed to fix TODO test
Test::MockTime
HTTP::Server::Simple::Mason 0.13
Log::Dispatch::Perl
+Test::XPath
.
$deps{'FASTCGI'} = [ text_to_hash( << '.') ];
commit 5f5c9848d42afcc8bbaebfa174dff4f8f51bdf36
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 17:59:06 2010 -0400
First cut of watching-queues.t
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
new file mode 100644
index 0000000..6a0176f
--- /dev/null
+++ b/t/web/watching-queues.t
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+use strict;
+
+use RT::Test tests => 20;
+use Test::XPath;
+my ($baseurl, $m) = RT::Test->started_ok;
+
+ok $m->login, 'logged in';
+
+diag "check watching page" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_contains('You are not watching any queues.');
+
+ # need to recover from embedded javascript using <!-- -->
+ my $tx = Test::XPath->new(xml => $m->content, is_html => 1, options => { recover => 1 });
+ $tx->not_ok('//ul[contains(@class,"queue-list")]', 'no queue list when watching nothing');
+}
+
+diag "add self as AdminCc on queue" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Configuration' );
+ $m->title_is('RT Administration', 'admin page');
+ $m->follow_link( text => 'Queues' );
+ $m->title_is('Admin queues', 'queues page');
+ $m->follow_link( text => 'General' );
+ $m->title_is('Editing Configuration for queue General');
+ $m->follow_link( text => 'Watchers' );
+ $m->title_is('Modify people related to queue General');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ UserField => 'Name',
+ UserOp => 'LIKE',
+ UserString => 'root',
+ },
+ });
+
+ $m->title_is('Modify people related to queue General', 'caught the right form! :)');
+
+ my $user = RT::User->new($RT::SystemUser);
+ $user->LoadByEmail('root at localhost');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ 'Queue-AddWatcher-Principal-' . $user->id => 'AdminCc',
+ },
+ });
+
+ $m->title_is('Modify people related to queue General', 'caught the right form! :)');
+
+ my $queue = RT::Queue->new($RT::SystemUser);
+ $queue->Load('General');
+ ok($queue->IsWatcher(Type => 'AdminCc', PrincipalId => $user->PrincipalId), 'added root as AdminCc on General');
+}
+
+diag "check watching page" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ # need to recover from embedded javascript using <!-- -->
+ my $tx = Test::XPath->new(xml => $m->content, is_html => 1, options => { recover => 1 });
+ $tx->ok('//ul[contains(@class,"queue-list")]', sub {
+ my $tx = shift;
+ $tx->is('count(//li[contains(@class,"queue-roles")])', 1, 'only one queue');
+ });
+}
+
commit 7f7538cc9f68c6795f7f290620269a8ce0a56fb1
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 18:29:47 2010 -0400
More markup for easier testing
diff --git a/share/html/Tools/Watching.html b/share/html/Tools/Watching.html
index b1b962b..f17e2e8 100644
--- a/share/html/Tools/Watching.html
+++ b/share/html/Tools/Watching.html
@@ -76,7 +76,8 @@ while (my $Queue = $Queues->Next) {
$count += @types;
</%perl>
- <li class="queue-roles"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &>
+ <li class="queue-roles">
+ <span class="queue-name"><& /Ticket/Elements/ShowQueue, QueueObj => $Queue &></span>
<ul class="queue-role-list">
% for my $type (@types) {
<li class="queue-role"><% $type %></li>
commit d4c21feb6b713d6a10b303cdb055f7d965677e89
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 18:30:09 2010 -0400
Factor out new_tx function
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 6a0176f..93ace7b 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -16,8 +16,7 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_contains('You are not watching any queues.');
- # need to recover from embedded javascript using <!-- -->
- my $tx = Test::XPath->new(xml => $m->content, is_html => 1, options => { recover => 1 });
+ my $tx = new_tx($m->content);
$tx->not_ok('//ul[contains(@class,"queue-list")]', 'no queue list when watching nothing');
}
@@ -69,11 +68,23 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_lacks('You are not watching any queues.');
- # need to recover from embedded javascript using <!-- -->
- my $tx = Test::XPath->new(xml => $m->content, is_html => 1, options => { recover => 1 });
+ my $tx = new_tx($m->content);
$tx->ok('//ul[contains(@class,"queue-list")]', sub {
my $tx = shift;
$tx->is('count(//li[contains(@class,"queue-roles")])', 1, 'only one queue');
});
}
+sub new_tx {
+ my $content = shift;
+
+ # need to recover from embedded javascript using <!-- -->
+ my $tx = Test::XPath->new(
+ xml => $content,
+ is_html => 1,
+ options => { recover => 1 },
+ );
+
+ return $tx;
+}
+
commit e5cf95371b834d904c9fa821b7e224e671bfe9a8
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 18:30:16 2010 -0400
Complete tests for making sure the queue/role list is correct (no more no less)
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 93ace7b..02fefb0 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,12 +1,13 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 20;
+use RT::Test tests => 25;
use Test::XPath;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
+
diag "check watching page" if $ENV{'TEST_VERBOSE'};
{
$m->follow_link( text => 'Tools' );
@@ -70,8 +71,14 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
my $tx = new_tx($m->content);
$tx->ok('//ul[contains(@class,"queue-list")]', sub {
- my $tx = shift;
- $tx->is('count(//li[contains(@class,"queue-roles")])', 1, 'only one queue');
+ $_->is('count(.//li[contains(@class,"queue-roles")])', 1, 'only one queue');
+ $_->ok('.//li[contains(@class,"queue-roles")]', sub {
+ $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
+ $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-role")])', 1, 'only one role');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/^\s*AdminCc\s*$/, 'correct role');
+ });
+ });
});
}
commit 418aaa980f64781d36de6fb18ff98ff9106cde87
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 18:34:26 2010 -0400
Make sure the list grows as we add more roles
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 02fefb0..ec4f124 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 25;
+use RT::Test tests => 45;
use Test::XPath;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -82,6 +82,68 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
});
}
+diag "add self as Cc on queue" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Configuration' );
+ $m->title_is('RT Administration', 'admin page');
+ $m->follow_link( text => 'Queues' );
+ $m->title_is('Admin queues', 'queues page');
+ $m->follow_link( text => 'General' );
+ $m->title_is('Editing Configuration for queue General');
+ $m->follow_link( text => 'Watchers' );
+ $m->title_is('Modify people related to queue General');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ UserField => 'Name',
+ UserOp => 'LIKE',
+ UserString => 'root',
+ },
+ });
+
+ $m->title_is('Modify people related to queue General', 'caught the right form! :)');
+
+ my $user = RT::User->new($RT::SystemUser);
+ $user->LoadByEmail('root at localhost');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ 'Queue-AddWatcher-Principal-' . $user->id => 'Cc',
+ },
+ });
+
+ $m->title_is('Modify people related to queue General', 'caught the right form! :)');
+
+ my $queue = RT::Queue->new($RT::SystemUser);
+ $queue->Load('General');
+ ok($queue->IsWatcher(Type => 'Cc', PrincipalId => $user->PrincipalId), 'added root as Cc on General');
+}
+
+diag "check watching page" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ my $tx = new_tx($m->content);
+ $tx->ok('//ul[contains(@class,"queue-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-roles")])', 1, 'only one queue');
+ $_->ok('.//li[contains(@class,"queue-roles")]', sub {
+ $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
+ $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-role")])', 2, 'two roles');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/AdminCc/, 'list includes AdminCc');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/(?<!Admin)Cc/, 'list includes Cc too');
+ });
+ });
+ });
+}
+
sub new_tx {
my $content = shift;
commit 93c47886104c634ecc031f9b0f3e7bf211143396
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Aug 20 18:38:06 2010 -0400
Test a second queue
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index ec4f124..95720da 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,12 +1,16 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 45;
+use RT::Test tests => 70;
use Test::XPath;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
+my $other_queue = RT::Queue->new($RT::SystemUser);
+$other_queue->Create(
+ Name => 'Fancypants',
+);
diag "check watching page" if $ENV{'TEST_VERBOSE'};
{
@@ -21,7 +25,7 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$tx->not_ok('//ul[contains(@class,"queue-list")]', 'no queue list when watching nothing');
}
-diag "add self as AdminCc on queue" if $ENV{'TEST_VERBOSE'};
+diag "add self as AdminCc on General" if $ENV{'TEST_VERBOSE'};
{
$m->follow_link( text => 'Configuration' );
$m->title_is('RT Administration', 'admin page');
@@ -82,7 +86,7 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
});
}
-diag "add self as Cc on queue" if $ENV{'TEST_VERBOSE'};
+diag "add self as Cc on General" if $ENV{'TEST_VERBOSE'};
{
$m->follow_link( text => 'Configuration' );
$m->title_is('RT Administration', 'admin page');
@@ -144,6 +148,75 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
});
}
+diag "add self as AdminCc on Fancypants" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Configuration' );
+ $m->title_is('RT Administration', 'admin page');
+ $m->follow_link( text => 'Queues' );
+ $m->title_is('Admin queues', 'queues page');
+ $m->follow_link( text => 'Fancypants' );
+ $m->title_is('Editing Configuration for queue Fancypants');
+ $m->follow_link( text => 'Watchers' );
+ $m->title_is('Modify people related to queue Fancypants');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ UserField => 'Name',
+ UserOp => 'LIKE',
+ UserString => 'root',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Fancypants', 'caught the right form! :)');
+
+ my $user = RT::User->new($RT::SystemUser);
+ $user->LoadByEmail('root at localhost');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ 'Queue-AddWatcher-Principal-' . $user->id => 'AdminCc',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Fancypants', 'caught the right form! :)');
+
+ ok($other_queue->IsWatcher(Type => 'AdminCc', PrincipalId => $user->PrincipalId), 'added root as AdminCc on Fancypants');
+}
+
+diag "check watching page" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ my $tx = new_tx($m->content);
+ $tx->ok('//ul[contains(@class,"queue-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-roles")])', 2, 'two queues');
+
+ $_->ok('.//li[contains(@class,"queue-roles")][contains(.//span[contains(@class,"queue-name")][text()],"General")]', sub {
+ $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
+ $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-role")])', 2, 'two roles');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/AdminCc/, 'list includes AdminCc');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/(?<!Admin)Cc/, 'list includes Cc too');
+ });
+ });
+
+ $_->ok('.//li[contains(@class,"queue-roles")][contains(.//span[contains(@class,"queue-name")][text()],"Fancypants")]', sub {
+ $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*Fancypants\s*$/, 'correct queue');
+ $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
+ $_->is('count(.//li[contains(@class,"queue-role")])', 1, 'one roles');
+ $_->like('.//li[contains(@class,"queue-role")][text()]', qr/^\s*AdminCc\s*$/, 'correct role');
+ });
+ });
+ });
+}
+
sub new_tx {
my $content = shift;
commit 5f6671d567cfdbd9b4c8ec62a33f965694fa5358
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 16:44:16 2010 -0400
Replace Test::XPath with Web::Scraper
The resulting code is shorter, human-friendly, and uses CSS
selectors instead of XPath :)
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index d94e727..547ee9e 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -271,7 +271,7 @@ Test::Builder 0.77 # needed to fix TODO test
Test::MockTime
HTTP::Server::Simple::Mason 0.13
Log::Dispatch::Perl
-Test::XPath
+Web::Scraper
.
$deps{'FASTCGI'} = [ text_to_hash( << '.') ];
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 95720da..c90b834 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,8 +1,8 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 70;
-use Test::XPath;
+use RT::Test tests => 45;
+use Web::Scraper;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
@@ -12,6 +12,19 @@ $other_queue->Create(
Name => 'Fancypants',
);
+my $watching = scraper {
+ process "li.queue-roles", 'queues[]' => scraper {
+ # trim the queue name
+ process 'span.queue-name', name => sub {
+ my $name = shift->as_text;
+ $name =~ s/^\s*//;
+ $name =~ s/\s*$//;
+ return $name;
+ };
+ process "li.queue-role", 'roles[]' => 'TEXT';
+ };
+};
+
diag "check watching page" if $ENV{'TEST_VERBOSE'};
{
$m->follow_link( text => 'Tools' );
@@ -21,8 +34,7 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_contains('You are not watching any queues.');
- my $tx = new_tx($m->content);
- $tx->not_ok('//ul[contains(@class,"queue-list")]', 'no queue list when watching nothing');
+ is_deeply($watching->scrape($m->content), {});
}
diag "add self as AdminCc on General" if $ENV{'TEST_VERBOSE'};
@@ -73,16 +85,13 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_lacks('You are not watching any queues.');
- my $tx = new_tx($m->content);
- $tx->ok('//ul[contains(@class,"queue-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-roles")])', 1, 'only one queue');
- $_->ok('.//li[contains(@class,"queue-roles")]', sub {
- $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
- $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-role")])', 1, 'only one role');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/^\s*AdminCc\s*$/, 'correct role');
- });
- });
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'General',
+ roles => ['AdminCc'],
+ },
+ ],
});
}
@@ -134,17 +143,13 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_lacks('You are not watching any queues.');
- my $tx = new_tx($m->content);
- $tx->ok('//ul[contains(@class,"queue-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-roles")])', 1, 'only one queue');
- $_->ok('.//li[contains(@class,"queue-roles")]', sub {
- $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
- $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-role")])', 2, 'two roles');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/AdminCc/, 'list includes AdminCc');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/(?<!Admin)Cc/, 'list includes Cc too');
- });
- });
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'General',
+ roles => ['Cc', 'AdminCc'],
+ },
+ ],
});
}
@@ -194,39 +199,17 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
$m->content_lacks('You are not watching any queues.');
- my $tx = new_tx($m->content);
- $tx->ok('//ul[contains(@class,"queue-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-roles")])', 2, 'two queues');
-
- $_->ok('.//li[contains(@class,"queue-roles")][contains(.//span[contains(@class,"queue-name")][text()],"General")]', sub {
- $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*General\s*$/, 'correct queue');
- $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-role")])', 2, 'two roles');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/AdminCc/, 'list includes AdminCc');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/(?<!Admin)Cc/, 'list includes Cc too');
- });
- });
-
- $_->ok('.//li[contains(@class,"queue-roles")][contains(.//span[contains(@class,"queue-name")][text()],"Fancypants")]', sub {
- $_->like('.//span[contains(@class,"queue-name")][text()]', qr/^\s*Fancypants\s*$/, 'correct queue');
- $_->ok('.//ul[contains(@class,"queue-role-list")]', sub {
- $_->is('count(.//li[contains(@class,"queue-role")])', 1, 'one roles');
- $_->like('.//li[contains(@class,"queue-role")][text()]', qr/^\s*AdminCc\s*$/, 'correct role');
- });
- });
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'Fancypants',
+ roles => ['AdminCc'],
+ },
+ {
+ name => 'General',
+ roles => ['Cc', 'AdminCc'],
+ },
+ ],
});
}
-sub new_tx {
- my $content = shift;
-
- # need to recover from embedded javascript using <!-- -->
- my $tx = Test::XPath->new(
- xml => $content,
- is_html => 1,
- options => { recover => 1 },
- );
-
- return $tx;
-}
-
commit 49ef25cfc4b4f1fb2c90fda36aafc7e260b2a159
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 16:56:28 2010 -0400
Load user only once
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index c90b834..13e40dd 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -7,6 +7,9 @@ my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
+my $user = RT::User->new($RT::SystemUser);
+$user->LoadByEmail('root at localhost');
+
my $other_queue = RT::Queue->new($RT::SystemUser);
$other_queue->Create(
Name => 'Fancypants',
@@ -59,9 +62,6 @@ diag "add self as AdminCc on General" if $ENV{'TEST_VERBOSE'};
$m->title_is('Modify people related to queue General', 'caught the right form! :)');
- my $user = RT::User->new($RT::SystemUser);
- $user->LoadByEmail('root at localhost');
-
$m->submit_form_ok({
form_number => 3,
fields => {
@@ -117,9 +117,6 @@ diag "add self as Cc on General" if $ENV{'TEST_VERBOSE'};
$m->title_is('Modify people related to queue General', 'caught the right form! :)');
- my $user = RT::User->new($RT::SystemUser);
- $user->LoadByEmail('root at localhost');
-
$m->submit_form_ok({
form_number => 3,
fields => {
@@ -175,9 +172,6 @@ diag "add self as AdminCc on Fancypants" if $ENV{'TEST_VERBOSE'};
$m->title_is('Modify people related to queue Fancypants', 'caught the right form! :)');
- my $user = RT::User->new($RT::SystemUser);
- $user->LoadByEmail('root at localhost');
-
$m->submit_form_ok({
form_number => 3,
fields => {
commit 6721fa43f49cc981266d6b51c0e6de915b92b2b6
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 16:56:38 2010 -0400
PrincipalId not id
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 13e40dd..c443b30 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -65,7 +65,7 @@ diag "add self as AdminCc on General" if $ENV{'TEST_VERBOSE'};
$m->submit_form_ok({
form_number => 3,
fields => {
- 'Queue-AddWatcher-Principal-' . $user->id => 'AdminCc',
+ 'Queue-AddWatcher-Principal-' . $user->PrincipalId => 'AdminCc',
},
});
@@ -120,7 +120,7 @@ diag "add self as Cc on General" if $ENV{'TEST_VERBOSE'};
$m->submit_form_ok({
form_number => 3,
fields => {
- 'Queue-AddWatcher-Principal-' . $user->id => 'Cc',
+ 'Queue-AddWatcher-Principal-' . $user->PrincipalId => 'Cc',
},
});
@@ -175,7 +175,7 @@ diag "add self as AdminCc on Fancypants" if $ENV{'TEST_VERBOSE'};
$m->submit_form_ok({
form_number => 3,
fields => {
- 'Queue-AddWatcher-Principal-' . $user->id => 'AdminCc',
+ 'Queue-AddWatcher-Principal-' . $user->PrincipalId => 'AdminCc',
},
});
commit 2b78c6b5203355ab6b5f1df7dffd2f1f17c0358c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 16:59:21 2010 -0400
Begin adding group tests
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index c443b30..f118ced 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 45;
+use RT::Test tests => 58;
use Web::Scraper;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -15,6 +15,16 @@ $other_queue->Create(
Name => 'Fancypants',
);
+my $loopy_queue = RT::Queue->new($RT::SystemUser);
+$loopy_queue->Create(
+ Name => 'Loopy',
+);
+
+my $group = RT::Group->new($RT::SystemUser);
+$group->CreateUserDefinedGroup(
+ Name => 'Groupies',
+);
+
my $watching = scraper {
process "li.queue-roles", 'queues[]' => scraper {
# trim the queue name
@@ -207,3 +217,60 @@ diag "check watching page" if $ENV{'TEST_VERBOSE'};
});
}
+diag "add group as Cc on Loopy" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Configuration' );
+ $m->title_is('RT Administration', 'admin page');
+ $m->follow_link( text => 'Queues' );
+ $m->title_is('Admin queues', 'queues page');
+ $m->follow_link( text => 'Loopy' );
+ $m->title_is('Editing Configuration for queue Loopy');
+ $m->follow_link( text => 'Watchers' );
+ $m->title_is('Modify people related to queue Loopy');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ GroupField => 'Name',
+ GroupOp => 'LIKE',
+ GroupString => 'Groupies',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Loopy', 'caught the right form! :)');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ 'Queue-AddWatcher-Principal-' . $group->PrincipalId => 'Cc',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Loopy', 'caught the right form! :)');
+
+ ok($loopy_queue->IsWatcher(Type => 'Cc', PrincipalId => $group->PrincipalId), 'added Groupies as Cc on Loopy');
+}
+
+diag "check watching page (no change since root is not a groupy)" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'Fancypants',
+ roles => ['AdminCc'],
+ },
+ {
+ name => 'General',
+ roles => ['Cc', 'AdminCc'],
+ },
+ ],
+ });
+}
+
commit 0c2410f3f226862321767dca9cff6509d14897d3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 16:59:29 2010 -0400
Silence undef warning by describing the group
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index f118ced..2b07258 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -23,6 +23,7 @@ $loopy_queue->Create(
my $group = RT::Group->new($RT::SystemUser);
$group->CreateUserDefinedGroup(
Name => 'Groupies',
+ Description => 'for the Metallica Speed of Sound tour',
);
my $watching = scraper {
commit fe1fc0ace0239b5e08aa413347b7d5c09e2162b7
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Sep 10 17:21:23 2010 -0400
Add tests for recursive-group-membership
Now that the tests are pretty exhaustive I'd feel comfortable
replacing the naive iteration with some more direct SQL.
diff --git a/t/web/watching-queues.t b/t/web/watching-queues.t
index 2b07258..68d6d81 100644
--- a/t/web/watching-queues.t
+++ b/t/web/watching-queues.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 58;
+use RT::Test tests => 75;
use Web::Scraper;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -26,6 +26,12 @@ $group->CreateUserDefinedGroup(
Description => 'for the Metallica Speed of Sound tour',
);
+my $outer_group = RT::Group->new($RT::SystemUser);
+$outer_group->CreateUserDefinedGroup(
+ Name => 'Groupies 2.0',
+ Description => 'for the Metallica Ride The Lightning tour',
+);
+
my $watching = scraper {
process "li.queue-roles", 'queues[]' => scraper {
# trim the queue name
@@ -252,6 +258,8 @@ diag "add group as Cc on Loopy" if $ENV{'TEST_VERBOSE'};
ok($loopy_queue->IsWatcher(Type => 'Cc', PrincipalId => $group->PrincipalId), 'added Groupies as Cc on Loopy');
}
+$group->AddMember($user->PrincipalId);
+
diag "check watching page (no change since root is not a groupy)" if $ENV{'TEST_VERBOSE'};
{
$m->follow_link( text => 'Tools' );
@@ -271,7 +279,100 @@ diag "check watching page (no change since root is not a groupy)" if $ENV{'TEST_
name => 'General',
roles => ['Cc', 'AdminCc'],
},
+ {
+ name => 'Loopy',
+ roles => ['Cc'],
+ },
],
});
}
+diag "add other group as AdminCc on Loopy" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Configuration' );
+ $m->title_is('RT Administration', 'admin page');
+ $m->follow_link( text => 'Queues' );
+ $m->title_is('Admin queues', 'queues page');
+ $m->follow_link( text => 'Loopy' );
+ $m->title_is('Editing Configuration for queue Loopy');
+ $m->follow_link( text => 'Watchers' );
+ $m->title_is('Modify people related to queue Loopy');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ GroupField => 'Name',
+ GroupOp => 'LIKE',
+ GroupString => 'Groupies',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Loopy', 'caught the right form! :)');
+
+ $m->submit_form_ok({
+ form_number => 3,
+ fields => {
+ 'Queue-AddWatcher-Principal-' . $outer_group->PrincipalId => 'AdminCc',
+ },
+ });
+
+ $m->title_is('Modify people related to queue Loopy', 'caught the right form! :)');
+
+ ok($loopy_queue->IsWatcher(Type => 'AdminCc', PrincipalId => $outer_group->PrincipalId), 'added Groupies 2.0 as AdminCc on Loopy');
+}
+
+diag "check watching page (no change since root is not in groupy 2.0)" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'Fancypants',
+ roles => ['AdminCc'],
+ },
+ {
+ name => 'General',
+ roles => ['Cc', 'AdminCc'],
+ },
+ {
+ name => 'Loopy',
+ roles => ['Cc'],
+ },
+ ],
+ });
+}
+
+$outer_group->AddMember($group->PrincipalId);
+
+diag "user is not a member of the outer group recursively" if $ENV{'TEST_VERBOSE'};
+{
+ $m->follow_link( text => 'Tools' );
+ $m->title_is('Tools', 'tools screen');
+ $m->follow_link( text => 'Watching Queues' );
+ $m->title_is('Watching Queues', 'watching screen');
+
+ $m->content_lacks('You are not watching any queues.');
+
+ is_deeply($watching->scrape($m->content), {
+ queues => [
+ {
+ name => 'Fancypants',
+ roles => ['AdminCc'],
+ },
+ {
+ name => 'General',
+ roles => ['Cc', 'AdminCc'],
+ },
+ {
+ name => 'Loopy',
+ roles => ['Cc', 'AdminCc'],
+ },
+ ],
+ });
+}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list