Bug 30070: (follow-up) Filter out deleted files on the API
EDI uses a 'deleted' flag in the table to denote deleted files, we should filter those out of the API response. Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
a2fb53a719
commit
8b5a5f46cb
|
|
@ -68,6 +68,7 @@ sub to_api_mapping {
|
|||
return {
|
||||
message_type => 'type',
|
||||
basketno => 'basket_id',
|
||||
deleted => undef,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,16 +46,18 @@ Return the list of edifact files
|
|||
sub list {
|
||||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
my $filter = { deleted => 0 };
|
||||
return try {
|
||||
|
||||
my $files_rs = Koha::Edifact::Files->new;
|
||||
my $files_rs = Koha::Edifact::Files->search($filter);
|
||||
my $files = $c->objects->search($files_rs);
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => $files,
|
||||
);
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,9 +55,4 @@ properties:
|
|||
- string
|
||||
- "null"
|
||||
description: Edifact file name
|
||||
deleted:
|
||||
type:
|
||||
- boolean
|
||||
- "null"
|
||||
description: Is this file deleted
|
||||
additionalProperties: false
|
||||
|
|
|
|||
|
|
@ -66,15 +66,21 @@ subtest 'list() tests' => sub {
|
|||
# No acquisitions\/edifiles, so empty array should be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [] );
|
||||
|
||||
my $file = $builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER' } } );
|
||||
my $file = $builder->build_object(
|
||||
{ class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 0 } } );
|
||||
|
||||
# One file created, should get returned
|
||||
my $deleted_file = $builder->build_object(
|
||||
{ class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 1 } } );
|
||||
|
||||
# One file undeleted, should get returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [ $file->to_api ] );
|
||||
|
||||
my $another_file_ORDER =
|
||||
$builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER' } } );
|
||||
$builder->build_object(
|
||||
{ class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 0 } } );
|
||||
my $another_file_QUOTE =
|
||||
$builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'QUOTE' } } );
|
||||
$builder->build_object(
|
||||
{ class => 'Koha::Edifact::Files', value => { message_type => 'QUOTE', deleted => 0 } } );
|
||||
|
||||
# Two files created, they should both be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is(
|
||||
|
|
|
|||
Loading…
Reference in New Issue