lib/Test2/Harness/UI/Controller/JobField.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 84 CC 5 SCAR 23.7
CC
5
Cov
0%
handle
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 10.8
1 package Test2::Harness::UI::Controller::JobField;
2 use strict;
3 use warnings;
4  
5 our $VERSION = '0.000150';
6  
7 use Data::GUID;
8 use List::Util qw/max/;
9 use Text::Xslate(qw/mark_raw/);
10 use Test2::Harness::UI::Util qw/share_dir/;
11 use Test2::Harness::UI::Response qw/resp error/;
12 use Test2::Harness::Util::JSON qw/encode_json decode_json/;
13 use Test2::Harness::UI::UUID qw/uuid_inflate/;
14  
15 use parent 'Test2::Harness::UI::Controller';
16 use Test2::Harness::UI::Util::HashBase qw/-title/;
17  
18 sub handle {
19 my $self = shift;
20 my ($route) = @_;
21  
22 my $req = $self->{+REQUEST};
23  
24 my $res = resp(200);
25 my $user = $req->user;
26  
27 die error(404 => 'Missing route') unless $route;
28  
29 my $it = $route->{id} or die error(404 => 'No id');
30 $it = uuid_inflate($it) or die error(404 => "Invalid id");
31 my $schema = $self->{+CONFIG}->schema;
32 my $field = $schema->resultset('JobField')->search({job_field_id => $it})->first or die error(404 => 'Invalid Field');
33  
34 if (my $act = $route->{action}) {
35 die error(401 => 'Login required') unless $user;
36 if ($act eq 'delete') {
37 $field->delete;
38 }
39 }
40  
41 $res->content_type('application/json');
42 $res->raw_body($field);
43 return $res;
44 }
45  
46 1;
47  
48 __END__