|
Lines 84-90
subtest 'Test07' => sub {
Link Here
|
| 84 |
plan tests => 2; |
84 |
plan tests => 2; |
| 85 |
test07(); |
85 |
test07(); |
| 86 |
}; |
86 |
}; |
| 87 |
subtest 'Test08: UploadedFile->allows_add_by' => sub { |
87 |
subtest 'Test08: allows_add_by' => sub { |
| 88 |
plan tests => 4; |
88 |
plan tests => 4; |
| 89 |
test08(); |
89 |
test08(); |
| 90 |
}; |
90 |
}; |
|
Lines 176-201
sub test07 { #simple test for httpheaders and getCategories
Link Here
|
| 176 |
is( @$cat >= 1, 1, 'getCategories returned at least one category' ); |
176 |
is( @$cat >= 1, 1, 'getCategories returned at least one category' ); |
| 177 |
} |
177 |
} |
| 178 |
|
178 |
|
| 179 |
sub test08 { # UploadedFile->allows_add_by |
179 |
sub test08 { # allows_add_by |
| 180 |
my $builder = t::lib::TestBuilder->new; |
180 |
my $builder = t::lib::TestBuilder->new; |
| 181 |
my $patron = $builder->build({ |
181 |
my $patron = $builder->build({ |
| 182 |
source => 'Borrower', |
182 |
source => 'Borrower', |
| 183 |
value => { flags => 0 }, #no permissions |
183 |
value => { flags => 0 }, #no permissions |
| 184 |
}); |
184 |
}); |
| 185 |
my $patronid = $patron->{borrowernumber}; |
185 |
my $patronid = $patron->{borrowernumber}; |
| 186 |
is( Koha::Schema::Result::UploadedFile->allows_add_by( $patron->{userid} ), |
186 |
is( Koha::Upload->allows_add_by( $patron->{userid} ), |
| 187 |
undef, 'Patron is not allowed to do anything' ); |
187 |
undef, 'Patron is not allowed to do anything' ); |
| 188 |
|
188 |
|
| 189 |
# add some permissions: edit_catalogue |
189 |
# add some permissions: edit_catalogue |
| 190 |
my $fl = 2**9; # edit_catalogue |
190 |
my $fl = 2**9; # edit_catalogue |
| 191 |
$schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); |
191 |
$schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); |
| 192 |
is( Koha::Schema::Result::UploadedFile->allows_add_by( $patron->{userid} ), |
192 |
is( Koha::Upload->allows_add_by( $patron->{userid} ), |
| 193 |
undef, 'Patron is still not allowed to add uploaded files' ); |
193 |
undef, 'Patron is still not allowed to add uploaded files' ); |
| 194 |
|
194 |
|
| 195 |
# replace flags by all tools |
195 |
# replace flags by all tools |
| 196 |
$fl = 2**13; # tools |
196 |
$fl = 2**13; # tools |
| 197 |
$schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); |
197 |
$schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); |
| 198 |
is( Koha::Schema::Result::UploadedFile->allows_add_by( $patron->{userid} ), |
198 |
is( Koha::Upload->allows_add_by( $patron->{userid} ), |
| 199 |
1, 'Patron should be allowed now to add uploaded files' ); |
199 |
1, 'Patron should be allowed now to add uploaded files' ); |
| 200 |
|
200 |
|
| 201 |
# remove all tools and add upload_general_files only |
201 |
# remove all tools and add upload_general_files only |
|
Lines 209-215
sub test08 { # UploadedFile->allows_add_by
Link Here
|
| 209 |
code => 'upload_general_files', |
209 |
code => 'upload_general_files', |
| 210 |
}, |
210 |
}, |
| 211 |
}); |
211 |
}); |
| 212 |
is( Koha::Schema::Result::UploadedFile->allows_add_by( $patron->{userid} ), |
212 |
is( Koha::Upload->allows_add_by( $patron->{userid} ), |
| 213 |
1, 'Patron is still allowed to add uploaded files' ); |
213 |
1, 'Patron is still allowed to add uploaded files' ); |
| 214 |
} |
214 |
} |
| 215 |
|
215 |
|