[Rt-commit] rt branch, 3.9-fix-queue-caching, updated. rt-3.8.8-746-g6c93217
Kevin Falcone
falcone at bestpractical.com
Thu Sep 16 15:10:20 EDT 2010
The branch, 3.9-fix-queue-caching has been updated
via 6c93217354355ce03eb49517440fb24e20ef1de4 (commit)
via 8a177c7c72bd0045ddde95b545425ea14a0dd947 (commit)
via e9e4fafd5eed4237c3316c22770ca85b5f0b75f3 (commit)
via 73b11973d599db5d7884f74b56711f36a40a743e (commit)
via 6dce5b3efac5a343d40c3ec514392a7f58048ad3 (commit)
via 57deb7debdbbbb5e2fa40e2f84663373764f6d81 (commit)
from 450830245e5eff80ab52d6b5f3de3a511aa242bf (commit)
Summary of changes:
lib/RT/Queue_Overlay.pm | 4 +++
lib/RT/System.pm | 15 +++++++++-
share/html/Elements/SelectQueue | 2 +-
t/web/queue_caching.t | 55 +++++++++++++++++++++++++++++++++++++++
4 files changed, 73 insertions(+), 3 deletions(-)
create mode 100644 t/web/queue_caching.t
- Log -----------------------------------------------------------------
commit 57deb7debdbbbb5e2fa40e2f84663373764f6d81
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Sep 15 15:11:00 2010 -0400
Small set of initial queue cache tests (these all pass)
diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
new file mode 100644
index 0000000..8849cc0
--- /dev/null
+++ b/t/web/queue_caching.t
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+use RT::Test tests => 6;
+
+# make an initial queue, so we have more than 1
+new_queue("Test$$");
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+diag("Check for 2 existing queues being visible") if $ENV{TEST_VERBOSE};
+{
+ok(my $form = $m->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");
+}
+
+sub new_queue {
+ my $name = shift;
+ 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;
+}
+
+sub internal_queues {
+ my $internal_queues = RT::Queues->new($RT::SystemUser);
+ $internal_queues->Limit(FIELD => 'Disabled', VALUE => 0);
+ my $queuelist;
+ while ( my $q = $internal_queues->Next ) {
+ $queuelist->{$q->Id} = $q->Name;
+ }
+ return $queuelist;
+}
+
commit 6dce5b3efac5a343d40c3ec514392a7f58048ad3
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Sep 15 18:06:02 2010 -0400
Refactor a bit and add the first obvious failing case
diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index 8849cc0..6b18e87 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 => 6;
+use RT::Test tests => 10;
# make an initial queue, so we have more than 1
new_queue("Test$$");
@@ -10,12 +10,13 @@ ok $m->login, 'logged in';
diag("Check for 2 existing queues being visible") if $ENV{TEST_VERBOSE};
{
-ok(my $form = $m->form_name('CreateTicketInQueue'), "Found New Ticket In form");
-ok(my $queuelist = $form->find_input('Queue','option'), "Found queue select");
-my @queues = $queuelist->possible_values;
+ check_queues();
+}
-my $queue_list = internal_queues();
-is_deeply([sort @queues],[sort keys %$queue_list], "Queue list contains the expected queues");
+diag("Add a new queue, which won't show up until we fix the cache") if $ENV{TEST_VERBOSE};
+{
+ new_queue("New Test $$");
+ check_queues();
}
sub new_queue {
@@ -35,3 +36,11 @@ sub internal_queues {
return $queuelist;
}
+sub check_queues {
+ ok(my $form = $m->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");
+}
commit 73b11973d599db5d7884f74b56711f36a40a743e
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Sep 15 18:26:49 2010 -0400
One other obvious test that we should be passing
diff --git a/t/web/queue_caching.t b/t/web/queue_caching.t
index 6b18e87..87e89fa 100644
--- a/t/web/queue_caching.t
+++ b/t/web/queue_caching.t
@@ -1,9 +1,9 @@
use strict;
use warnings;
-use RT::Test tests => 10;
+use RT::Test tests => 17;
# make an initial queue, so we have more than 1
-new_queue("Test$$");
+my $original_test_queue = new_queue("Test$$");
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
@@ -19,8 +19,16 @@ diag("Add a new queue, which won't show up until we fix the cache") if $ENV{TEST
check_queues();
}
+diag("Disable an existing queue, it should stop appearing in the list") if $ENV{TEST_VERBOSE};
+{
+ sleep(1); # so the cache will actually invalidate
+ ok($original_test_queue->SetDisabled(1));
+ check_queues();
+}
+
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;
@@ -37,6 +45,7 @@ sub internal_queues {
}
sub check_queues {
+ $m->get_ok($baseurl,"Navigated to homepage");
ok(my $form = $m->form_name('CreateTicketInQueue'), "Found New Ticket In form");
ok(my $queuelist = $form->find_input('Queue','option'), "Found queue select");
my @queues = $queuelist->possible_values;
commit e9e4fafd5eed4237c3316c22770ca85b5f0b75f3
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 16 15:10:13 2010 -0400
use a newer syntax
diff --git a/share/html/Elements/SelectQueue b/share/html/Elements/SelectQueue
index ebe3f65..15d5573 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};
}
commit 8a177c7c72bd0045ddde95b545425ea14a0dd947
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 16 15:12:23 2010 -0400
Documentation, and use attributes correctly
diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index c2607a4..fe1cba8 100755
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -241,14 +241,25 @@ sub SubjectTag {
return grep !$seen{lc $_}++, values %$map;
}
+=head2 QueueCacheNeedsUpdate ( 1 )
+
+Attribute to decide when SelectQueue needs to flush the list of queues
+and retrieve new ones. Set when queues are created, enabled/disabled
+and on certain acl changes. Should also better understand group management.
+
+If passed a true value, will update the attribute to be the current time.
+
+=cut
+
sub QueueCacheNeedsUpdate {
my $self = shift;
my $update = shift;
if ($update) {
- return $self->SetAttribute('QueueCacheNeedsUpdate', $update);
+ return $self->SetAttribute(Name => 'QueueCacheNeedsUpdate', Content => time);
} else {
- return $self->FirstAttribute('QueueCacheNeedsUpdate') || 0;
+ my $cache = $self->FirstAttribute('QueueCacheNeedsUpdate');
+ return (defined $cache ? $cache->Content : 0 );
}
}
commit 6c93217354355ce03eb49517440fb24e20ef1de4
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Sep 16 15:12:56 2010 -0400
Flag the queue refresh cache on Disable/Enable and Create
diff --git a/lib/RT/Queue_Overlay.pm b/lib/RT/Queue_Overlay.pm
index 77535a2..ad71035 100755
--- a/lib/RT/Queue_Overlay.pm
+++ b/lib/RT/Queue_Overlay.pm
@@ -415,6 +415,8 @@ sub Create {
unless $status;
}
+ RT->System->QueueCacheNeedsUpdate(1);
+
return ( $id, $self->loc("Queue created") );
}
@@ -455,6 +457,8 @@ sub SetDisabled {
$RT::Handle->Commit();
+ RT->System->QueueCacheNeedsUpdate(1);
+
if ( $val == 1 ) {
return (1, $self->loc("Queue disabled"));
} else {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list