|
Lines 850-858
subtest 'update() tests' => sub {
Link Here
|
| 850 |
my $authorized_patron = $builder->build_object( |
850 |
my $authorized_patron = $builder->build_object( |
| 851 |
{ |
851 |
{ |
| 852 |
class => 'Koha::Patrons', |
852 |
class => 'Koha::Patrons', |
| 853 |
value => { flags => 1 } |
853 |
value => { flags => 2**2 } # catalog only, no additional permissions |
|
|
854 |
} |
| 855 |
); |
| 856 |
|
| 857 |
my $superlibrarian = $builder->build_object( |
| 858 |
{ |
| 859 |
class => 'Koha::Patrons', |
| 860 |
value => { flags => 1 } # superlibrarian |
| 861 |
} |
| 862 |
); |
| 863 |
|
| 864 |
# Ensure our librarian can see users from all branches (once list_borrowers is added) |
| 865 |
$builder->build( |
| 866 |
{ |
| 867 |
source => 'UserPermission', |
| 868 |
value => { |
| 869 |
borrowernumber => $authorized_patron->borrowernumber, |
| 870 |
module_bit => 4, |
| 871 |
code => 'edit_borrowers', |
| 872 |
}, |
| 854 |
} |
873 |
} |
| 855 |
); |
874 |
); |
|
|
875 |
|
| 856 |
my $password = 'thePassword123'; |
876 |
my $password = 'thePassword123'; |
| 857 |
$authorized_patron->set_password( { password => $password, skip_validation => 1 } ); |
877 |
$authorized_patron->set_password( { password => $password, skip_validation => 1 } ); |
| 858 |
my $userid = $authorized_patron->userid; |
878 |
my $userid = $authorized_patron->userid; |
|
Lines 868-874
subtest 'update() tests' => sub {
Link Here
|
| 868 |
|
888 |
|
| 869 |
my $patron_1 = $authorized_patron; |
889 |
my $patron_1 = $authorized_patron; |
| 870 |
my $patron_2 = $unauthorized_patron; |
890 |
my $patron_2 = $unauthorized_patron; |
| 871 |
my $newpatron = $unauthorized_patron->to_api( { user => $authorized_patron } ); |
891 |
my $newpatron = $unauthorized_patron->to_api( { user => $superlibrarian } ) |
|
|
892 |
; # Need to use a patron with ability to view the patron |
| 893 |
my $blanked_patron = $unauthorized_patron->to_api( { user => $authorized_patron } ) |
| 894 |
; # The api return will blank since we can't see, only update |
| 872 |
|
895 |
|
| 873 |
# delete RO attributes |
896 |
# delete RO attributes |
| 874 |
delete $newpatron->{patron_id}; |
897 |
delete $newpatron->{patron_id}; |
|
Lines 953-960
subtest 'update() tests' => sub {
Link Here
|
| 953 |
|
976 |
|
| 954 |
my $got = $result->tx->res->json; |
977 |
my $got = $result->tx->res->json; |
| 955 |
my $updated_on_got = delete $got->{updated_on}; |
978 |
my $updated_on_got = delete $got->{updated_on}; |
| 956 |
my $updated_on_expected = delete $newpatron->{updated_on}; |
979 |
my $updated_on_expected = delete $blanked_patron->{updated_on}; |
| 957 |
is_deeply( $got, $newpatron, 'Returned patron from update matches expected' ); |
980 |
is_deeply( $got, $blanked_patron, 'Returned patron from update matches expected' ); |
| 958 |
is( |
981 |
is( |
| 959 |
t::lib::Dates::compare( |
982 |
t::lib::Dates::compare( |
| 960 |
dt_from_string( $updated_on_got, 'rfc3339' ), |
983 |
dt_from_string( $updated_on_got, 'rfc3339' ), |
|
Lines 969-981
subtest 'update() tests' => sub {
Link Here
|
| 969 |
$newpatron->{cardnumber}, 'Patron is really updated!' |
992 |
$newpatron->{cardnumber}, 'Patron is really updated!' |
| 970 |
); |
993 |
); |
| 971 |
|
994 |
|
| 972 |
my $superlibrarian = $builder->build_object( |
|
|
| 973 |
{ |
| 974 |
class => 'Koha::Patrons', |
| 975 |
value => { flags => 1 } |
| 976 |
} |
| 977 |
); |
| 978 |
|
| 979 |
$newpatron->{cardnumber} = $superlibrarian->cardnumber; |
995 |
$newpatron->{cardnumber} = $superlibrarian->cardnumber; |
| 980 |
$newpatron->{userid} = $superlibrarian->userid; |
996 |
$newpatron->{userid} = $superlibrarian->userid; |
| 981 |
$newpatron->{email} = 'nosense@no.no'; |
997 |
$newpatron->{email} = 'nosense@no.no'; |
| 982 |
- |
|
|