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

(-)a/t/db_dependent/api/v1/illrequests.t (-8 / +6 lines)
Lines 99-105 subtest 'list() tests' => sub { Link Here
99
    my $response = $illrequest->unblessed;
99
    my $response = $illrequest->unblessed;
100
    $response->{id_prefix} = $illrequest->id_prefix;
100
    $response->{id_prefix} = $illrequest->id_prefix;
101
101
102
    my $req_formatted = add_formatted($illrequest);
102
    my $req_formatted = add_formatted($response);
103
103
104
    # One illrequest created, should get returned
104
    # One illrequest created, should get returned
105
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
105
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
Lines 134-140 subtest 'list() tests' => sub { Link Here
134
    my $response2 = $illrequest2->unblessed;
134
    my $response2 = $illrequest2->unblessed;
135
    $response2->{id_prefix} = $illrequest2->id_prefix;
135
    $response2->{id_prefix} = $illrequest2->id_prefix;
136
136
137
    my $req2_formatted = add_formatted($illrequest2);
137
    my $req2_formatted = add_formatted($response2);
138
138
139
    # Two illrequest created, should get returned
139
    # Two illrequest created, should get returned
140
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
140
    $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' );
Lines 159-178 sub add_formatted { Link Here
159
    my @format_dates = ( 'placed', 'updated' );
159
    my @format_dates = ( 'placed', 'updated' );
160
    # We need to embellish the request with properties that the API
160
    # We need to embellish the request with properties that the API
161
    # controller calculates on the fly
161
    # controller calculates on the fly
162
    my $req_unblessed = $req->unblessed;
163
    # Create new "formatted" columns for each date column
162
    # Create new "formatted" columns for each date column
164
    # that needs formatting
163
    # that needs formatting
165
    foreach my $field(@format_dates) {
164
    foreach my $field(@format_dates) {
166
        if (defined $req_unblessed->{$field}) {
165
        if (defined $req->{$field}) {
167
            $req_unblessed->{$field . "_formatted"} = format_sqldatetime(
166
            $req->{$field . "_formatted"} = format_sqldatetime(
168
                $req_unblessed->{$field},
167
                $req->{$field},
169
                undef,
168
                undef,
170
                undef,
169
                undef,
171
                1
170
                1
172
            );
171
            );
173
        }
172
        }
174
    }
173
    }
175
    return $req_unblessed;
174
    return $req;
176
}
175
}
177
176
178
sub create_user_and_session {
177
sub create_user_and_session {
179
- 

Return to bug 20600