|
Lines 255-261
subtest 'Simple tests for httpheaders and getCategories' => sub {
Link Here
|
| 255 |
|
255 |
|
| 256 |
my $rec = Koha::UploadedFiles->search_term( { term => 'file' } )->next; |
256 |
my $rec = Koha::UploadedFiles->search_term( { term => 'file' } )->next; |
| 257 |
my @hdrs = $rec->httpheaders; |
257 |
my @hdrs = $rec->httpheaders; |
| 258 |
is( @hdrs == 4 && $hdrs[1] =~ /application\/octet-stream/, 1, 'Simple test for httpheaders' ); |
258 |
is( @hdrs == 6 && $hdrs[1] =~ /application\/octet-stream/, 1, 'Simple test for httpheaders' ); |
| 259 |
$builder->build( |
259 |
$builder->build( |
| 260 |
{ |
260 |
{ |
| 261 |
source => 'AuthorisedValue', |
261 |
source => 'AuthorisedValue', |
|
Lines 364-378
subtest 'Testing delete_temporary' => sub {
Link Here
|
| 364 |
}; |
364 |
}; |
| 365 |
|
365 |
|
| 366 |
subtest 'Testing download headers' => sub { |
366 |
subtest 'Testing download headers' => sub { |
| 367 |
plan tests => 2; |
367 |
plan tests => 3; |
| 368 |
my $test_pdf = Koha::UploadedFile->new( { filename => 'pdf.pdf', uploadcategorycode => 'B', filesize => 1000 } ); |
368 |
my $test_pdf = |
| 369 |
my $test_not = Koha::UploadedFile->new( { filename => 'pdf.not', uploadcategorycode => 'B', filesize => 1000 } ); |
369 |
Koha::UploadedFile->new( { filename => 'pdf.pdf', uploadcategorycode => 'B', filesize => 1000, public => 0 } ); |
| 370 |
my @pdf_expect = ( '-type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="pdf.pdf"' ); |
370 |
my $test_not = |
| 371 |
my @not_expect = ( '-type' => 'application/octet-stream', '-attachment' => 'pdf.not' ); |
371 |
Koha::UploadedFile->new( { filename => 'pdf.not', uploadcategorycode => 'B', filesize => 1000, public => 0 } ); |
| 372 |
my @pdf_head = $test_pdf->httpheaders; |
372 |
my $test_public = |
| 373 |
my @not_head = $test_not->httpheaders; |
373 |
Koha::UploadedFile->new( { filename => 'pdf.not', uploadcategorycode => 'B', filesize => 1000, public => 1 } ); |
| 374 |
is_deeply( \@pdf_head, \@pdf_expect, "Get inline pdf headers for pdf" ); |
374 |
my @pdf_expect = ( |
| 375 |
is_deeply( \@not_head, \@not_expect, "Get download headers for non pdf" ); |
375 |
'-type' => 'application/pdf', 'Cache-Control' => 'no-cache, no-store, max-age=0', |
|
|
376 |
'Content-Disposition' => 'inline; filename="pdf.pdf"' |
| 377 |
); |
| 378 |
my @not_expect = ( |
| 379 |
'-type' => 'application/octet-stream', '-attachment' => 'pdf.not', |
| 380 |
'Cache-Control' => 'no-cache, no-store, max-age=0' |
| 381 |
); |
| 382 |
my @public_expect = ( |
| 383 |
'-type' => 'application/octet-stream', '-attachment' => 'pdf.not', |
| 384 |
'Cache-Control' => 'public, max-age=43200' |
| 385 |
); |
| 386 |
my @pdf_head = $test_pdf->httpheaders; |
| 387 |
my @not_head = $test_not->httpheaders; |
| 388 |
my @public_head = $test_public->httpheaders; |
| 389 |
is_deeply( \@pdf_head, \@pdf_expect, "Get inline pdf headers for pdf" ); |
| 390 |
is_deeply( \@not_head, \@not_expect, "Get download headers for non pdf" ); |
| 391 |
is_deeply( \@public_head, \@public_expect, "Get download headers for public file" ); |
| 376 |
}; |
392 |
}; |
| 377 |
|
393 |
|
| 378 |
# The end |
394 |
# The end |
| 379 |
- |
|
|