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

(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-2 / +45 lines)
Lines 53-58 get '/cities/rs' => sub { Link Here
53
    $c->render( status => 200, json => { count => $cities->count } );
53
    $c->render( status => 200, json => { count => $cities->count } );
54
};
54
};
55
55
56
get '/cities/rs_regression' => sub {
57
    my $c = shift;
58
    $c->validation->output( $c->req->params->to_hash );
59
    $c->stash_embed;
60
    $c->req->params->remove('q');
61
    my $cities = $c->objects->search_rs( Koha::Cities->new );
62
63
    $c->render( status => 200, json => { count => $cities->count } );
64
};
65
56
get '/cities/:city_id' => sub {
66
get '/cities/:city_id' => sub {
57
    my $c  = shift;
67
    my $c  = shift;
58
    my $id = $c->stash("city_id");
68
    my $id = $c->stash("city_id");
Lines 135-141 get '/cities/:city_id/rs' => sub { Link Here
135
145
136
# The tests
146
# The tests
137
use Test::NoWarnings;
147
use Test::NoWarnings;
138
use Test::More tests => 19;
148
use Test::More tests => 20;
139
use Test::Mojo;
149
use Test::Mojo;
140
150
141
use t::lib::Mocks;
151
use t::lib::Mocks;
Lines 991-993 subtest 'date handling' => sub { Link Here
991
1001
992
    $schema->storage->txn_rollback;
1002
    $schema->storage->txn_rollback;
993
};
1003
};
994
- 
1004
1005
subtest 'Regression test - search_rs should not reinstate removed query parameters' => sub {
1006
    plan tests => 3;
1007
1008
    $schema->storage->txn_begin;
1009
1010
    # Remove existing cities to have more control on the search results
1011
    Koha::Cities->delete;
1012
1013
    # Create three sample cities that match the query. We want to get all three returned when the city_name query parameter is removed
1014
    $builder->build_object(
1015
        {
1016
            class => 'Koha::Cities',
1017
            value => { city_name => 'city1' }
1018
        }
1019
    );
1020
    $builder->build_object(
1021
        {
1022
            class => 'Koha::Cities',
1023
            value => { city_name => 'city2' }
1024
        }
1025
    );
1026
    $builder->build_object(
1027
        {
1028
            class => 'Koha::Cities',
1029
            value => { city_name => 'city3' }
1030
        }
1031
    );
1032
    my $t = Test::Mojo->new;
1033
    $t->get_ok('/cities/rs_regression?q={"city_name":"city1"}')->status_is(200)->json_is( '/count' => 3 );
1034
1035
    $schema->storage->txn_rollback;
1036
};
1037

Return to bug 40417