Lines 14-20
Link Here
|
14 |
|
14 |
|
15 |
use Modern::Perl; |
15 |
use Modern::Perl; |
16 |
|
16 |
|
17 |
use Test::More tests => 5; |
17 |
use Test::More tests => 6; |
18 |
|
18 |
|
19 |
use Test::Mojo; |
19 |
use Test::Mojo; |
20 |
use Data::Dumper; |
20 |
use Data::Dumper; |
Lines 22-27
use Data::Dumper;
Link Here
|
22 |
use FindBin(); |
22 |
use FindBin(); |
23 |
use IPC::Cmd qw(can_run); |
23 |
use IPC::Cmd qw(can_run); |
24 |
use List::MoreUtils qw(any); |
24 |
use List::MoreUtils qw(any); |
|
|
25 |
use File::Slurp qw(read_file); |
25 |
|
26 |
|
26 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
27 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
27 |
my $spec = $t->get_ok( '/api/v1/', 'Correctly fetched the spec' )->tx->res->json; |
28 |
my $spec = $t->get_ok( '/api/v1/', 'Correctly fetched the spec' )->tx->res->json; |
Lines 170-172
subtest '400 response tests' => sub {
Link Here
|
170 |
print STDERR "$error\n"; |
171 |
print STDERR "$error\n"; |
171 |
} |
172 |
} |
172 |
}; |
173 |
}; |
173 |
- |
174 |
|
|
|
175 |
subtest 'POST (201) have location header' => sub { |
176 |
my @files = `git ls-files 'Koha/REST/V1/**/*.pm'`; |
177 |
plan tests => scalar @files; |
178 |
foreach my $file (@files) { |
179 |
chomp $file; |
180 |
my $content = read_file($file); |
181 |
if ( $content !~ /status\s*=>\s*201/s ) { |
182 |
pass("$file does not seem to have a POST endpoint"); |
183 |
} elsif ( $content =~ /\$c->res->headers->location\(.*?\);\s*return\s+\$c->render\s*\(\s*status\s*=>\s*201,/s ) { |
184 |
pass("$file contains the location header"); |
185 |
} else { |
186 |
fail("$file does not contain the location header"); |
187 |
} |
188 |
} |
189 |
}; |