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

(-)a/Koha/REST/Plugin/Query.pm (+28 lines)
Lines 262-267 Merges parameters from $q_params into $filtered_params. Link Here
262
                    if $THE_embed;
262
                    if $THE_embed;
263
            }
263
            }
264
264
265
            return $c;
266
        }
267
    );
268
269
=head3 stash_overrides
270
271
    $c->stash_overrides();
272
273
=cut
274
275
    $app->helper(
276
        'stash_overrides' => sub {
277
278
            my ( $c ) = @_;
279
280
            my $override_header = $c->req->headers->header('x-koha-override');
281
282
            my $overrides = {};
283
284
            if ( $override_header ) {
285
                my @overrides = ();
286
                foreach my $override ( split /\s*,\s*/, $override_header ) {
287
                    $overrides->{$override} = 1;
288
                }
289
            }
290
291
            $c->stash( 'koha.overrides' => $overrides );
292
265
            return $c;
293
            return $c;
266
        }
294
        }
267
    );
295
    );
(-)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 487-489 subtest 'stash_embed() tests' => sub { Link Here
487
      );
499
      );
488
500
489
};
501
};
490
- 
502
503
subtest 'stash_overrides() tests' => sub {
504
505
    plan tests => 4;
506
507
    my $t = Test::Mojo->new;
508
509
    $t->get_ok( '/stash_overrides' => { 'x-koha-override' => 'any,none,some_other,any,' } )
510
      ->json_is( { 'any' => 1, 'none' => 1, 'some_other' => 1 } ); # empty string and duplicates are skipped
511
512
    $t->get_ok( '/stash_overrides' => { 'x-koha-override' => '' } )
513
      ->json_is( {} ); # empty string is skipped
514
};

Return to bug 27760