[Rt-commit] rt branch, 3.9-fix-queue-caching, updated. rt-3.8.8-790-gc150bca

Kevin Falcone falcone at bestpractical.com
Tue Sep 21 15:17:52 EDT 2010


The branch, 3.9-fix-queue-caching has been updated
       via  c150bca54433f808e64e458eddbe70e08e14c4a5 (commit)
       via  cd913a09f09035455bfb08c6f9d6edb3b96e3224 (commit)
       via  54b568913593ee85a9d4d4ce5010de363826e30a (commit)
       via  e67fff9ef9239ff93d8b50dc7b61e50d11817014 (commit)
      from  a6834bd1b71237561265ec52fdc07859ab3dbfa6 (commit)

Summary of changes:
 share/html/Elements/SelectQueue |    2 +-
 t/web/queue_caching.t           |   61 ++++++++++++++++++++++++++++++--------
 2 files changed, 49 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit e67fff9ef9239ff93d8b50dc7b61e50d11817014
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 21 12:18:51 2010 -0400

    Our diag() already checks for TEST_VERBOSE

diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index d12958c..fd8985a 100644
--- a/t/web/queue_caching.t
+++ b/t/web/queue_caching.t
@@ -11,18 +11,18 @@ ok $m->login, 'logged in';
 # the attribute cache hangs on to an old dbh
 delete $RT::System->{attributes};
 
-diag("Check for 2 existing queues being visible") if $ENV{TEST_VERBOSE};
+diag("Check for 2 existing queues being visible");
 {
     check_queues();
 }
 
-diag("Add a new queue, which won't show up until we fix the cache") if $ENV{TEST_VERBOSE};
+diag("Add a new queue, which won't show up until we fix the cache");
 {
     new_queue("New Test $$");
     check_queues();
 }
 
-diag("Disable an existing queue, it should stop appearing in the list") if $ENV{TEST_VERBOSE};
+diag("Disable an existing queue, it should stop appearing in the list");
 {
     sleep(1); # so the cache will actually invalidate
     ok($original_test_queue->SetDisabled(1));

commit 54b568913593ee85a9d4d4ce5010de363826e30a
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 21 14:52:54 2010 -0400

    Allow this function to take a browser and a list of queues

diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index fd8985a..5433118 100644
--- a/t/web/queue_caching.t
+++ b/t/web/queue_caching.t
@@ -13,20 +13,20 @@ delete $RT::System->{attributes};
 
 diag("Check for 2 existing queues being visible");
 {
-    check_queues();
+    check_queues($m);
 }
 
 diag("Add a new queue, which won't show up until we fix the cache");
 {
     new_queue("New Test $$");
-    check_queues();
+    check_queues($m);
 }
 
 diag("Disable an existing queue, it should stop appearing in the list");
 {
     sleep(1); # so the cache will actually invalidate
     ok($original_test_queue->SetDisabled(1));
-    check_queues();
+    check_queues($m);
 }
 
 sub new_queue {
@@ -47,12 +47,17 @@ sub internal_queues {
     return $queuelist;
 }
 
+
+# takes a WWW::Mech object and an optional arrayref of queue ids
+# compares the list of ids to the dropdown of Queues for the New Ticket In form
 sub check_queues {
-    $m->get_ok($baseurl,"Navigated to homepage");
-    ok(my $form = $m->form_name('CreateTicketInQueue'), "Found New Ticket In form");
+    my $browser = shift;
+    my $queue_list = shift;
+    $browser->get_ok($baseurl,"Navigated to homepage");
+    ok(my $form = $browser->form_name('CreateTicketInQueue'), "Found New Ticket In form");
     ok(my $queuelist = $form->find_input('Queue','option'), "Found queue select");
     my @queues = $queuelist->possible_values;
 
-    my $queue_list = internal_queues();
-    is_deeply([sort @queues],[sort keys %$queue_list], "Queue list contains the expected queues");
+    $queue_list = [keys %{internal_queues()}] unless $queue_list;
+    is_deeply([sort @queues],[sort @$queue_list], "Queue list contains the expected queues");
 }

commit cd913a09f09035455bfb08c6f9d6edb3b96e3224
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 21 15:13:56 2010 -0400

    Add tests where user rights change
    
    Granting SeeQueue and CreateTicket to a user should change the contents
    of the Queue dropdown.

diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index 5433118..046c2a3 100644
--- a/t/web/queue_caching.t
+++ b/t/web/queue_caching.t
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use RT::Test tests => 17;
+use RT::Test tests => 34;
 
 # make an initial queue, so we have more than 1
 my $original_test_queue = new_queue("Test$$");
@@ -29,6 +29,38 @@ diag("Disable an existing queue, it should stop appearing in the list");
     check_queues($m);
 }
 
+diag("Bring back a disabled queue");
+{
+    ok($original_test_queue->SetDisabled(0));
+    check_queues($m);
+}
+
+diag("Test a user who has more limited rights Queues");
+{
+
+my $user_a = RT::Test->load_or_create_user(
+    Name => 'user_a', Password => 'password',
+);
+ok $user_a && $user_a->id, 'loaded or created user';
+
+ok( RT::Test->set_rights(
+        { Principal => $user_a, Right => [qw(SeeQueue CreateTicket)], Object => $original_test_queue },
+), 'Allow user a to see the testing queue');
+
+my $a_m = RT::Test::Web->new;
+ok $a_m->login('user_a', 'password'), 'logged in as user A';
+
+# check that they see a single queue
+check_queues($a_m,[$original_test_queue->Id]);
+
+ok( RT::Test->add_rights(
+        { Principal => $user_a, Right => [qw(SeeQueue CreateTicket)] },
+), 'add global queue viewing rights');
+
+check_queues($a_m);
+
+}
+
 sub new_queue {
     my $name = shift;
     sleep(1); # so the cache will actually invalidate

commit c150bca54433f808e64e458eddbe70e08e14c4a5
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 21 15:14:50 2010 -0400

    Sleep less by making the time check looser

diff --git a/share/html/Elements/SelectQueue b/share/html/Elements/SelectQueue
index 15d5573..c04480d 100755
--- a/share/html/Elements/SelectQueue
+++ b/share/html/Elements/SelectQueue
@@ -92,7 +92,7 @@ if ( defined $session{$cache_key} && ref $session{$cache_key} eq 'ARRAY') {
     delete $session{$cache_key};
 }
 if ( defined $session{$cache_key} &&
-     $session{$cache_key}{lastupdated} < RT->System->QueueCacheNeedsUpdate ) {
+     $session{$cache_key}{lastupdated} <= RT->System->QueueCacheNeedsUpdate ) {
     delete $session{$cache_key};
 }
 
diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index 046c2a3..17c8c60 100644
--- a/t/web/queue_caching.t
+++ b/t/web/queue_caching.t
@@ -24,7 +24,6 @@ diag("Add a new queue, which won't show up until we fix the cache");
 
 diag("Disable an existing queue, it should stop appearing in the list");
 {
-    sleep(1); # so the cache will actually invalidate
     ok($original_test_queue->SetDisabled(1));
     check_queues($m);
 }
@@ -63,7 +62,6 @@ check_queues($a_m);
 
 sub new_queue {
     my $name = shift;
-    sleep(1); # so the cache will actually invalidate
     my $new_queue = RT::Queue->new($RT::SystemUser);
     ok($new_queue->Create( Name => $name, Description => "Testing for $name queue" ), "Created queue ".$new_queue->Name);
     return $new_queue;

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


More information about the Rt-commit mailing list