Bugzilla – Attachment 101820 Details for
Bug 24964
Do not filter patrons AFTER they have been fetched from the DB (when searching with permissions)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24964: Add tests
Bug-24964-Add-tests.patch (text/plain), 4.51 KB, created by
Kyle M Hall (khall)
on 2020-03-26 12:54:22 UTC
(
hide
)
Description:
Bug 24964: Add tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-03-26 12:54:22 UTC
Size:
4.51 KB
patch
obsolete
>From 025bf017c14ed5ac93e02b076b6e06b389a3ee97 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 25 Mar 2020 11:20:20 +0100 >Subject: [PATCH] Bug 24964: Add tests > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Utils/Datatables_Members.t | 68 +++++++++++++++++++++-- > 1 file changed, 62 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t >index 7a77ea4ddd..85bebcd0fc 100644 >--- a/t/db_dependent/Utils/Datatables_Members.t >+++ b/t/db_dependent/Utils/Datatables_Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 51; >+use Test::More tests => 52; > > use C4::Context; > use C4::Members; >@@ -56,7 +56,8 @@ my $john_doe = $builder->build({ > branchcode => $branchcode, > dateofbirth => '1983-03-01', > userid => 'john.doe', >- initials => 'pacman' >+ initials => 'pacman', >+ flags => 0, > }, > }); > >@@ -68,7 +69,8 @@ my $john_smith = $builder->build({ > surname => 'Smith', > branchcode => $branchcode, > dateofbirth => '1982-02-01', >- userid => 'john.smith' >+ userid => 'john.smith', >+ flags => 0, > }, > }); > >@@ -80,7 +82,8 @@ my $jane_doe = $builder->build({ > surname => 'Doe', > branchcode => $branchcode, > dateofbirth => '1983-03-01', >- userid => 'jane.doe' >+ userid => 'jane.doe', >+ flags => 0, > }, > }); > my $jeanpaul_dupont = $builder->build({ >@@ -91,7 +94,8 @@ my $jeanpaul_dupont = $builder->build({ > surname => 'Dupont', > branchcode => $branchcode, > dateofbirth => '1982-02-01', >- userid => 'jeanpaul.dupont' >+ userid => 'jeanpaul.dupont', >+ flags => 0, > }, > }); > my $dupont_brown = $builder->build({ >@@ -102,7 +106,8 @@ my $dupont_brown = $builder->build({ > surname => 'Brown', > branchcode => $branchcode, > dateofbirth => '1979-01-01', >- userid => 'dupont.brown' >+ userid => 'dupont.brown', >+ flags => 0, > }, > }); > >@@ -495,5 +500,56 @@ subtest 'Search by any borrowers field (bug 17374)' => sub { > is( $search_results->{ patrons }[0]->{ cardnumber }, $john_doe->{cardnumber}, "We find the correct patron when sesrching by initials" ) > }; > >+subtest 'Search with permissions' => sub { >+ plan tests => 2; >+ >+ my $superlibrarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $branchcode, flags => 1 } >+ } >+ ); >+ my $librarian_with_full_permission = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $branchcode, flags => 4100 } >+ } >+ ); # 4100 = 4096 (2^12 suggestions) + 4 (2^2 catalogue) >+ my $librarian_with_subpermission = $builder->build_object( >+ { class => 'Koha::Patrons', value => { branchcode => $branchcode } } ); >+ C4::Context->dbh->do( >+ q|INSERT INTO user_permissions(borrowernumber, module_bit, code) VALUES(?,?,?)|, >+ undef, >+ $librarian_with_subpermission->borrowernumber, >+ 12, >+ 'suggestions_manage' >+ ); >+ >+ my $search_results = C4::Utils::DataTables::Members::search( >+ { >+ searchmember => "", >+ searchfieldstype => 'standard', >+ searchtype => 'contain', >+ branchcode => $branchcode, >+ has_permission => { >+ permission => 'suggestions', >+ subpermission => 'suggestions_manage' >+ }, >+ dt_params => { iDisplayLength => 3, iDisplayStart => 0 }, >+ } >+ ); >+ is( $search_results->{iTotalDisplayRecords}, >+ 3, "We find 3 patrons with suggestions_manage permission" ); >+ is_deeply( >+ [ map { $_->{borrowernumber} } @{ $search_results->{patrons} } ], >+ [ >+ $superlibrarian->borrowernumber, >+ $librarian_with_full_permission->borrowernumber, >+ $librarian_with_subpermission->borrowernumber >+ ], >+ 'We got the 3 patrons we expected' >+ ); >+}; >+ > # End > $schema->storage->txn_rollback; >-- >2.21.1 (Apple Git-122.3)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24964
:
101668
|
101669
|
101686
|
101702
|
101813
|
101814
|
101815
| 101820 |
101821
|
101822
|
101823
|
102434
|
102435
|
102457
|
102458
|
102459
|
102460
|
102461