Bug 40417: Regression test
prove t/db_dependent/Koha/REST/Plugin/Objects.t
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f45dd34d6e)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
274bf141ab
commit
78968f9436
|
|
@ -53,6 +53,16 @@ get '/cities/rs' => sub {
|
|||
$c->render( status => 200, json => { count => $cities->count } );
|
||||
};
|
||||
|
||||
get '/cities/rs_regression' => sub {
|
||||
my $c = shift;
|
||||
$c->validation->output( $c->req->params->to_hash );
|
||||
$c->stash_embed;
|
||||
$c->req->params->remove('q');
|
||||
my $cities = $c->objects->search_rs( Koha::Cities->new );
|
||||
|
||||
$c->render( status => 200, json => { count => $cities->count } );
|
||||
};
|
||||
|
||||
get '/cities/:city_id' => sub {
|
||||
my $c = shift;
|
||||
my $id = $c->stash("city_id");
|
||||
|
|
@ -135,7 +145,7 @@ get '/cities/:city_id/rs' => sub {
|
|||
|
||||
# The tests
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 19;
|
||||
use Test::More tests => 20;
|
||||
use Test::Mojo;
|
||||
|
||||
use t::lib::Mocks;
|
||||
|
|
@ -991,3 +1001,36 @@ subtest 'date handling' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'Regression test - search_rs should not reinstate removed query parameters' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
# Remove existing cities to have more control on the search results
|
||||
Koha::Cities->delete;
|
||||
|
||||
# Create three sample cities that match the query. We want to get all three returned when the city_name query parameter is removed
|
||||
$builder->build_object(
|
||||
{
|
||||
class => 'Koha::Cities',
|
||||
value => { city_name => 'city1' }
|
||||
}
|
||||
);
|
||||
$builder->build_object(
|
||||
{
|
||||
class => 'Koha::Cities',
|
||||
value => { city_name => 'city2' }
|
||||
}
|
||||
);
|
||||
$builder->build_object(
|
||||
{
|
||||
class => 'Koha::Cities',
|
||||
value => { city_name => 'city3' }
|
||||
}
|
||||
);
|
||||
my $t = Test::Mojo->new;
|
||||
$t->get_ok('/cities/rs_regression?q={"city_name":"city1"}')->status_is(200)->json_is( '/count' => 3 );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue