Bugzilla – Attachment 64783 Details for
Bug 18228
Make list permissions easier to use/understand
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18228: Adjust Virtualshelves.t
Bug-18228-Adjust-Virtualshelvest.patch (text/plain), 11.32 KB, created by
Nick Clemens (kidclamp)
on 2017-07-03 17:02:52 UTC
(
hide
)
Description:
Bug 18228: Adjust Virtualshelves.t
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-07-03 17:02:52 UTC
Size:
11.32 KB
patch
obsolete
>From e8ffa866aff19c51e588a3e87b6dcb9eb23d42d7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 8 Mar 2017 16:28:59 +0100 >Subject: [PATCH] Bug 18228: Adjust Virtualshelves.t > >Test plan: >Run t/db_dependent/Virtualshelves.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Eric Gosselin <eric.gosselin@inlibro.com> > >Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Virtualshelves.t | 82 +++++++++++++++++------------------------ > 1 file changed, 34 insertions(+), 48 deletions(-) > >diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t >index c867056..b092ae8 100644 >--- a/t/db_dependent/Virtualshelves.t >+++ b/t/db_dependent/Virtualshelves.t >@@ -19,7 +19,7 @@ $dbh->{AutoCommit} = 0; > teardown(); > > subtest 'CRUD' => sub { >- plan tests => 13; >+ plan tests => 12; > my $patron = $builder->build({ > source => 'Borrower', > }); >@@ -39,9 +39,8 @@ subtest 'CRUD' => sub { > > $number_of_shelves = Koha::Virtualshelves->search->count; > is( $number_of_shelves, 1, '1 shelf should have been inserted' ); >- is( $shelf->allow_add, 0, 'The default value for allow_add should be 1' ); >- is( $shelf->allow_delete_own, 1, 'The default value for allow_delete_own should be 0' ); >- is( $shelf->allow_delete_other, 0, 'The default value for allow_delete_other should be 0' ); >+ is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' ); >+ is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' ); > is( output_pref($shelf->created_on), output_pref(dt_from_string), 'The creation time should have been set to today' ); > > my $retrieved_shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); >@@ -194,50 +193,42 @@ subtest 'Shelf content' => sub { > my $contents = $shelf->get_contents; > is( $contents->count, 2, 'There are 2 biblios on this shelf' ); > >- # Patron 2 will try to remove a content >- # allow_add = 0, allow_delete_own = 1, allow_delete_other = 0 => Default values >+ # Patron 2 will try to remove biblios >+ # allow_change_from_owner = 1, allow_change_from_others = 0 (defaults) > my $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } ); > is( $number_of_deleted_biblios, 0, 'Patron 2 removed nothing' ); > # Now try with patron 1 > $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); > is( $number_of_deleted_biblios, 1, 'Patron 1 removed biblio' ); >- > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 1, 'To be sure the content has been deleted' ); > >- # allow_delete_own = 0 >- $shelf->allow_delete_own(0); >+ # allow_change_from_owner == 0 (readonly) >+ $shelf->allow_change_from_owner( 0 ); > $shelf->store; > $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); >- is( $number_of_deleted_biblios, 1, 'Patron 1 removed another biblio' ); >+ is( $number_of_deleted_biblios, 0, 'Owner could not delete' ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; >- is( $number_of_contents, 0, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' ); >+ is( $number_of_contents, 1, 'Number of entries still equal to 1' ); > $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >+ $number_of_contents = Koha::Virtualshelfcontents->search->count; >+ is( $number_of_contents, 1, 'Biblio not added to the list' ); >+ # Add back biblio1 >+ $shelf->allow_change_from_owner( 1 ); >+ $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >+ $number_of_contents = Koha::Virtualshelfcontents->search->count; >+ is( $number_of_contents, 2, 'Biblio added to the list' ); > >- # allow_add = 1, allow_delete_own = 1 >- $shelf->allow_add(1); >- $shelf->allow_delete_own(1); >- $shelf->store; >- >+ # allow_change_from_others == 1 >+ $shelf->allow_change_from_others( 1 ); > my $content3 = $shelf->add_biblio( $biblio3->{biblionumber}, $patron2->{borrowernumber} ); > my $content4 = $shelf->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >- > $number_of_contents = Koha::Virtualshelfcontents->search->count; >- is( $number_of_contents, 3, 'The biblio should have been added to the shelf by the patron 2' ); >- >+ is( $number_of_contents, 4, 'The biblio should have been added to the shelf by the patron 2' ); > $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio3->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } ); > is( $number_of_deleted_biblios, 1, 'Biblio 3 deleted by patron 2' ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; >- is( $number_of_contents, 2, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=1) ' ); >- >- # allow_add = 1, allow_delete_own = 1, allow_delete_other = 1 >- $shelf->allow_delete_other(1); >- $shelf->store; >- >- $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } ); >- is( $number_of_deleted_biblios, 1, 'Biblio 2 deleted by patron 2' ); >- $number_of_contents = Koha::Virtualshelfcontents->search->count; >- is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' ); >+ is( $number_of_contents, 3, 'Back to three entries' ); > > teardown(); > }; >@@ -257,9 +248,8 @@ subtest 'Shelf permissions' => sub { > { shelfname => "my first shelf", > owner => $patron1->{borrowernumber}, > category => 2, >- allow_add => 0, >- allow_delete_own => 0, >- allow_delete_other => 0, >+ allow_change_from_owner => 0, >+ allow_change_from_others => 0, > } > )->store; > >@@ -272,16 +262,14 @@ subtest 'Shelf permissions' => sub { > is( $public_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' ); > is( $public_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Public list should not be managed by someone else' ); > >- is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); >+ is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 0, 'The owner should not be able to add biblios to his list' ); > is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); > >- is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); >+ is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' ); > is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); > > >- $public_shelf->allow_add(1); >- $public_shelf->allow_delete_own(1); >- $public_shelf->allow_delete_other(1); >+ $public_shelf->allow_change_from_owner(1); > $public_shelf->store; > > is( $public_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his public list' ); >@@ -294,19 +282,18 @@ subtest 'Shelf permissions' => sub { > is( $public_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Public list should not be managed by someone else' ); > > is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); >- is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 1, 'Public list should not be modified (add) by someone else' ); >+ is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); > > is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); >- is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 1, 'Public list should not be modified (remove) by someone else' ); >+ is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); > > > my $private_shelf = Koha::Virtualshelf->new( > { shelfname => "my first shelf", > owner => $patron1->{borrowernumber}, > category => 1, >- allow_add => 0, >- allow_delete_own => 0, >- allow_delete_other => 0, >+ allow_change_from_owner => 0, >+ allow_change_from_others => 0, > } > )->store; > >@@ -319,16 +306,15 @@ subtest 'Shelf permissions' => sub { > is( $private_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' ); > is( $private_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Private list should not be managed by someone else' ); > >- is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); >+ is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 0, 'The owner should not be able to add biblios to his list' ); > is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' ); > >- is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); >+ is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' ); > is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' ); > > >- $private_shelf->allow_add(1); >- $private_shelf->allow_delete_own(1); >- $private_shelf->allow_delete_other(1); >+ $private_shelf->allow_change_from_owner(1); >+ $private_shelf->allow_change_from_others(1); > $private_shelf->store; > > is( $private_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his list' ); >@@ -438,7 +424,7 @@ subtest 'Get shelves containing biblios' => sub { > my $content3 = $shelf2->add_biblio( $biblio2->{biblionumber}, $patron2->{borrowernumber} ); > my $content4 = $shelf2->add_biblio( $biblio3->{biblionumber}, $patron2->{borrowernumber} ); > my $content5 = $shelf2->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >- my $content6 = $shelf3->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >+ my $content6 = $shelf3->add_biblio( $biblio4->{biblionumber}, $patron1->{borrowernumber} ); > > my $shelves_with_biblio1_for_any_patrons = Koha::Virtualshelves->get_shelves_containing_record( > { >-- >2.1.4
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 18228
:
60939
|
60940
|
60941
|
60942
|
60943
|
61471
|
61475
|
61476
|
61477
|
61478
|
63474
|
64505
|
64506
|
64507
|
64508
|
64509
|
64780
|
64781
|
64782
| 64783 |
64784
|
64785