View | Details | Raw Unified | Return to bug 27760
Collapse All | Expand All

(-)a/Koha/REST/Plugin/Query.pm (+28 lines)
Lines 237-242 Merges parameters from $q_params into $filtered_params. Link Here
237
                    if $THE_embed;
237
                    if $THE_embed;
238
            }
238
            }
239
239
240
            return $c;
241
        }
242
    );
243
244
=head3 stash_overrides
245
246
    $c->stash_overrides();
247
248
=cut
249
250
    $app->helper(
251
        'stash_overrides' => sub {
252
253
            my ( $c ) = @_;
254
255
            my $override_header = $c->req->headers->header('x-koha-override');
256
257
            my $overrides = {};
258
259
            if ( $override_header ) {
260
                my @overrides = ();
261
                foreach my $override ( split /\s*,\s*/, $override_header ) {
262
                    $overrides->{$override} = 1;
263
                }
264
            }
265
266
            $c->stash( 'koha.overrides' => $overrides );
267
240
            return $c;
268
            return $c;
241
        }
269
        }
242
    );
270
    );
(-)a/t/Koha/REST/Plugin/Query.t (-2 / +26 lines)
Lines 255-260 get '/stash_embed_no_spec' => sub { Link Here
255
    };
255
    };
256
};
256
};
257
257
258
get '/stash_overrides' => sub {
259
    my $c = shift;
260
261
    $c->stash_overrides();
262
    my $overrides = $c->stash('koha.overrides');
263
264
    $c->render(
265
        status => 200,
266
        json   => $overrides
267
    );
268
};
269
258
sub to_model {
270
sub to_model {
259
    my ($args) = @_;
271
    my ($args) = @_;
260
    $args->{three} = delete $args->{tres}
272
    $args->{three} = delete $args->{tres}
Lines 264-270 sub to_model { Link Here
264
276
265
# The tests
277
# The tests
266
278
267
use Test::More tests => 6;
279
use Test::More tests => 7;
268
use Test::Mojo;
280
use Test::Mojo;
269
281
270
subtest 'extract_reserved_params() tests' => sub {
282
subtest 'extract_reserved_params() tests' => sub {
Lines 485-487 subtest 'stash_embed() tests' => sub { Link Here
485
      );
497
      );
486
498
487
};
499
};
488
- 
500
501
subtest 'stash_overrides() tests' => sub {
502
503
    plan tests => 4;
504
505
    my $t = Test::Mojo->new;
506
507
    $t->get_ok( '/stash_overrides' => { 'x-koha-override' => 'any,none,some_other,any,' } )
508
      ->json_is( { 'any' => 1, 'none' => 1, 'some_other' => 1 } ); # empty string and duplicates are skipped
509
510
    $t->get_ok( '/stash_overrides' => { 'x-koha-override' => '' } )
511
      ->json_is( {} ); # empty string is skipped
512
};

Return to bug 27760