Lines 209-225
get '/build_query' => sub {
Link Here
|
209 |
get '/stash_embed' => sub { |
209 |
get '/stash_embed' => sub { |
210 |
my $c = shift; |
210 |
my $c = shift; |
211 |
|
211 |
|
212 |
$c->stash_embed(); |
212 |
try { |
213 |
my $embed = $c->stash('koha.embed'); |
213 |
$c->stash_embed( |
214 |
my $strings = $c->stash('koha.strings'); |
214 |
{ |
|
|
215 |
spec => { |
216 |
'parameters' => [ |
217 |
{ |
218 |
'in' => 'header', |
219 |
'name' => 'x-koha-embed', |
220 |
'items' => { |
221 |
'enum' => [ |
222 |
'checkouts', 'checkouts.item', |
223 |
'library', 'holds+count' |
224 |
] |
225 |
} |
226 |
} |
227 |
] |
228 |
} |
229 |
} |
230 |
); |
215 |
|
231 |
|
216 |
$c->render( |
232 |
my $embed = $c->stash('koha.embed'); |
217 |
status => 200, |
233 |
my $strings = $c->stash('koha.strings'); |
218 |
json => { |
234 |
|
219 |
strings => $strings, |
235 |
$c->render( |
220 |
embed => $embed, |
236 |
status => 200, |
221 |
} |
237 |
json => { |
222 |
); |
238 |
strings => $strings, |
|
|
239 |
embed => $embed |
240 |
} |
241 |
); |
242 |
} |
243 |
catch { |
244 |
$c->render( |
245 |
status => 400, |
246 |
json => { error => "$_" } |
247 |
); |
248 |
}; |
249 |
}; |
250 |
|
251 |
get '/stash_embed_no_spec' => sub { |
252 |
my $c = shift; |
253 |
|
254 |
try { |
255 |
$c->stash_embed( { spec => {} } ); |
256 |
|
257 |
my $embed = $c->stash('koha.embed'); |
258 |
my $strings = $c->stash('koha.strings'); |
259 |
|
260 |
$c->render( |
261 |
status => 200, |
262 |
json => { |
263 |
strings => $strings, |
264 |
embed => $embed |
265 |
} |
266 |
); |
267 |
} |
268 |
catch { |
269 |
$c->render( |
270 |
status => 400, |
271 |
json => { error => "$_" } |
272 |
); |
273 |
}; |
223 |
}; |
274 |
}; |
224 |
|
275 |
|
225 |
get '/stash_overrides' => sub { |
276 |
get '/stash_overrides' => sub { |
Lines 433-439
subtest '_build_query_params_from_api' => sub {
Link Here
|
433 |
|
484 |
|
434 |
subtest 'stash_embed() tests' => sub { |
485 |
subtest 'stash_embed() tests' => sub { |
435 |
|
486 |
|
436 |
plan tests => 16; |
487 |
plan tests => 19; |
437 |
|
488 |
|
438 |
my $t = Test::Mojo->new; |
489 |
my $t = Test::Mojo->new; |
439 |
|
490 |
|
Lines 468-473
subtest 'stash_embed() tests' => sub {
Link Here
|
468 |
patron => { } |
519 |
patron => { } |
469 |
}) |
520 |
}) |
470 |
->json_is( '/strings' => 1 ); |
521 |
->json_is( '/strings' => 1 ); |
|
|
522 |
|
523 |
$t->get_ok( '/stash_embed_no_spec' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } ) |
524 |
->status_is(400) |
525 |
->json_is( '/error' => |
526 |
qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Embedding objects is not allowed on this endpoint.'\n} |
527 |
); |
471 |
}; |
528 |
}; |
472 |
|
529 |
|
473 |
subtest 'stash_overrides() tests' => sub { |
530 |
subtest 'stash_overrides() tests' => sub { |