Bug 42667: (QA follow-up) Test edit permission on ownerless reports
Add two test cases covering reports with no borrowernumber (NULL owner): a patron without edit_all_reports should be denied, one with the permission should succeed. The POD documents this case but it was not previously exercised. Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
5da8ba1ce9
commit
51d1fe9498
|
|
@ -568,7 +568,7 @@ subtest 'running' => sub {
|
|||
};
|
||||
|
||||
subtest 'check_edit_permission() and store enforcement' => sub {
|
||||
plan tests => 6;
|
||||
plan tests => 8;
|
||||
|
||||
my $owner = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } );
|
||||
my $editor = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } );
|
||||
|
|
@ -618,6 +618,17 @@ subtest 'check_edit_permission() and store enforcement' => sub {
|
|||
{ report_name => 'new_one', savedsql => 'SELECT 1', borrowernumber => $owner->borrowernumber } )->store;
|
||||
}
|
||||
'creating a new report is not subject to the edit check';
|
||||
|
||||
my $ownerless = Koha::Report->new( { report_name => 'ownerless_test', savedsql => 'SELECT 1' } )->store;
|
||||
|
||||
t::lib::Mocks::mock_userenv( { patron => $owner } );
|
||||
throws_ok { $ownerless->savedsql('SELECT 2')->store }
|
||||
'Koha::Exceptions::Report::EditPermission',
|
||||
'a patron without edit_all_reports cannot edit an ownerless report';
|
||||
|
||||
t::lib::Mocks::mock_userenv( { patron => $editor } );
|
||||
lives_ok { $ownerless->savedsql('SELECT 3')->store }
|
||||
'a patron with edit_all_reports can edit an ownerless report';
|
||||
};
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue