[Rt-commit] rt branch 5.0/validate-get-default-queue created. rt-5.0.2-26-gb19f794369
BPS Git Server
git at git.bestpractical.com
Tue Nov 2 19:02:12 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/validate-get-default-queue has been created
at b19f79436907157272c82b64f75160c64e29efa9 (commit)
- Log -----------------------------------------------------------------
commit b19f79436907157272c82b64f75160c64e29efa9
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Nov 3 01:45:45 2021 +0800
Add tests for default queue rights check
diff --git a/t/web/ticket_create.t b/t/web/ticket_create.t
index 58ac5134c4..b07139fc63 100644
--- a/t/web/ticket_create.t
+++ b/t/web/ticket_create.t
@@ -94,4 +94,21 @@ $m->content_lacks( 'Permission Denied', 'Has permission to create ticket' );
$form = $m->form_name('TicketCreate');
is_deeply( [ $form->find_input('Queue','option')->possible_values ], [ $queue2->id ], 'Only Another queue is listed' );
+RT::Test->stop_server;
+RT->Config->Set(DefaultQueue => 'General');
+( $baseurl, $m ) = RT::Test->started_ok;
+
+ok( $user->PrincipalObj->RevokeRight( Right => 'SeeQueue', Object => RT->System ), 'Revoke SeeQueue right' );
+ok( $m->login( 'user', 'password' ), 'logged in as user' );
+$m->submit_form_ok( { form_name => 'CreateTicketInQueue' }, 'Try to create ticket' );
+$m->text_contains('Permission Denied', 'No permission to create ticket without SeeQueue');
+$m->warning_like(qr/Permission Denied/, 'Permission denied warning' );
+
+ok( $user->PrincipalObj->GrantRight( Right => 'SeeQueue', Object => $queue2 ), 'Grant SeeQueue right to Another queue' );
+$m->submit_form_ok( { form_name => 'CreateTicketInQueue' }, 'Try to create ticket' );
+$m->content_lacks( 'Permission Denied', 'Has permission to create ticket' );
+$form = $m->form_name('TicketCreate');
+is( $form->value('Queue'), $queue2->id, 'Queue selection dropdown populated and pre-selected' );
+is_deeply( [ $form->find_input('Queue','option')->possible_values ], [ $queue2->id ], 'Only Another queue is listed' );
+
done_testing();
commit ef9baaa4f813c58d34fe3a21c0012463975c891d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Nov 2 03:35:12 2021 +0800
Load queue object in GetDefaultQueue to make sure it's valid and visible
This is an edge case. Previously if current user did't have "SeeQueue"
on the default queue, clicking "Create new ticket" would redirect to
ticket create page with the default queue id filled, which is weird
especially if current user has "SeeQueue" on another queue(it makes more
sense to use this queue instead).
As we don't fill the unavailable default queue any more, now ticket
create page can fill the first available queue instead.
To be consistent with documentation, now it always returns ID if found.
Previously it could be NAME if config is set to a name like "General".
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index ce0931f35a..6f85fcec03 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4800,7 +4800,9 @@ sub GetDefaultQueue {
$queue = RT->Config->Get( "DefaultQueue", $session{'CurrentUser'} );
}
- return $queue;
+ my $obj = RT::Queue->new( $HTML::Mason::Commands::session{'CurrentUser'} );
+ $obj->Load($queue);
+ return defined $obj->Name ? $obj->Id : undef;
}
=head2 UpdateDashboard
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list