Skip to content

Commit

Permalink
remove duplication in test
Browse files Browse the repository at this point in the history
  • Loading branch information
preaction committed Apr 21, 2020
1 parent 0fdbe92 commit 623fb65
Showing 1 changed file with 10 additions and 38 deletions.
48 changes: 10 additions & 38 deletions t/controller/yancy.t
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ subtest helpers => sub {
$c->render( data => $c->csrf_token );
},
);
$r->get( '/employee' )->name( 'employee.list' )->to(
'yancy#list',
my %common_stash = (
schema => 'employees',
id_field => 'employee_id',
template => 'dump_item',
helpers => [
'collect_item',
Expand All @@ -873,55 +873,27 @@ subtest helpers => sub {
},
],
);
$r->get( '/employee' )->name( 'employee.list' )->to(
'yancy#list',
%common_stash,
);
$r->get( '/employee/:employee_id' )->name( 'employee.get' )->to(
'yancy#get',
schema => 'employees',
id_field => 'employee_id',
template => 'dump_item',
helpers => [
'collect_item',
sub {
my ( $c, $item ) = @_;
return $item;
},
],
%common_stash,
);
$r->post( '/employee/:employee_id' )->name( 'employee.set' )->to(
'yancy#set',
schema => 'employees',
id_field => 'employee_id',
helpers => [
'collect_item',
sub {
my ( $c, $item ) = @_;
return $item;
},
],
%common_stash,
forward_to => 'employee.get',
);
$r->post( '/employee' )->name( 'employee.create' )->to(
'yancy#set',
schema => 'employees',
helpers => [
'collect_item',
sub {
my ( $c, $item ) = @_;
return $item;
},
],
%common_stash,
forward_to => 'employee.get',
);
$r->post( '/employee/:employee_id/delete' )->name( 'employee.delete' )->to(
'yancy#delete',
schema => 'employees',
id_field => 'employee_id',
helpers => [
'collect_item',
sub {
my ( $c, $item ) = @_;
return $item;
},
],
%common_stash,
forward_to => 'employee.list',
);

Expand Down

0 comments on commit 623fb65

Please sign in to comment.