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

(-)a/Koha/REST/V1/Checkout.pm (-27 / +157 lines)
Lines 15-22 package Koha::REST::V1::Checkout; Link Here
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
18
use Mojo::Base 'Mojolicious::Controller';
21
19
22
use C4::Auth qw( haspermission );
20
use C4::Auth qw( haspermission );
Lines 24-65 use C4::Context; Link Here
24
use C4::Circulation;
22
use C4::Circulation;
25
use Koha::Checkouts;
23
use Koha::Checkouts;
26
24
27
sub list {
25
use Try::Tiny;
28
    my ($c, $args, $cb) = @_;
26
27
=head1 NAME
28
29
Koha::REST::V1::Checkout
30
31
=head1 API
29
32
30
    my $borrowernumber = $c->param('borrowernumber');
33
=head2 Methods
31
    my $checkouts = C4::Circulation::GetIssues({
32
        borrowernumber => $borrowernumber
33
    });
34
34
35
    $c->$cb($checkouts, 200);
35
=head3 list
36
37
List Koha::Checkout objects
38
39
=cut
40
41
sub list {
42
    my $c = shift->openapi->valid_input or return;
43
    try {
44
        my $checkouts_set = Koha::Checkouts->new;
45
        my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api );
46
        return $c->render( status => 200, openapi => $checkouts );
47
    } catch {
48
        if ( $_->isa('DBIx::Class::Exception') ) {
49
            return $c->render(
50
                status => 500,
51
                openapi => { error => $_->{msg} }
52
            );
53
        } else {
54
            return $c->render(
55
                status => 500,
56
                openapi => { error => "Something went wrong, check the logs." }
57
            );
58
        }
59
    };
36
}
60
}
37
61
62
=head3 get
63
64
get one checkout
65
66
=cut
67
38
sub get {
68
sub get {
39
    my ($c, $args, $cb) = @_;
69
    my $c = shift->openapi->valid_input or return;
40
70
41
    my $checkout_id = $args->{checkout_id};
71
    my $checkout = Koha::Checkouts->find( $c->validation->param('checkout_id') );
42
    my $checkout = Koha::Checkouts->find($checkout_id);
43
72
44
    if (!$checkout) {
73
    unless ($checkout) {
45
        return $c->$cb({
74
        return $c->render(
46
            error => "Checkout doesn't exist"
75
            status => 404,
47
        }, 404);
76
            openapi => { error => "Checkout doesn't exist" }
77
        );
48
    }
78
    }
49
79
50
    return $c->$cb($checkout->unblessed, 200);
80
    return $c->render(
81
        status => 200,
82
        openapi => _to_api($checkout->TO_JSON)
83
    );
51
}
84
}
52
85
86
=head3 renew
87
88
Renew a checkout
89
90
=cut
91
53
sub renew {
92
sub renew {
54
    my ($c, $args, $cb) = @_;
93
    my $c = shift->openapi->valid_input or return;
55
94
56
    my $checkout_id = $args->{checkout_id};
95
    my $checkout_id = $c->validation->param('checkout_id');
57
    my $checkout = Koha::Checkouts->find($checkout_id);
96
    my $checkout = Koha::Checkouts->find( $checkout_id );
58
97
59
    if (!$checkout) {
98
    unless ($checkout) {
60
        return $c->$cb({
99
        return $c->render(
61
            error => "Checkout doesn't exist"
100
            status => 404,
62
        }, 404);
101
            openapi => { error => "Checkout doesn't exist" }
102
        );
63
    }
103
    }
64
104
65
    my $borrowernumber = $checkout->borrowernumber;
105
    my $borrowernumber = $checkout->borrowernumber;
Lines 69-75 sub renew { Link Here
69
    unless (C4::Context->preference('OpacRenewalAllowed')) {
109
    unless (C4::Context->preference('OpacRenewalAllowed')) {
70
        my $user = $c->stash('koha.user');
110
        my $user = $c->stash('koha.user');
71
        unless ($user && haspermission($user->userid, { circulate => "circulate_remaining_permissions" })) {
111
        unless ($user && haspermission($user->userid, { circulate => "circulate_remaining_permissions" })) {
72
            return $c->$cb({error => "Opac Renewal not allowed"}, 403);
112
            return $c->render(
113
                status => 403,
114
                openapi => { error => "Opac Renewal not allowed"}
115
            );
73
        }
116
        }
74
    }
117
    }
75
118
Lines 77-89 sub renew { Link Here
77
        $borrowernumber, $itemnumber);
120
        $borrowernumber, $itemnumber);
78
121
79
    if (!$can_renew) {
122
    if (!$can_renew) {
80
        return $c->$cb({error => "Renewal not authorized ($error)"}, 403);
123
        return $c->render(
124
            status => 403,
125
            openapi => { error => "Renewal not authorized ($error)" }
126
        );
81
    }
127
    }
82
128
83
    AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
129
    AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
84
    $checkout = Koha::Checkouts->find($checkout_id);
130
    $checkout = Koha::Checkouts->find($checkout_id);
85
131
86
    return $c->$cb($checkout->unblessed, 200);
132
    return $c->render(
133
        status => 200,
134
        openapi => _to_api( $checkout->TO_JSON )
135
    );
87
}
136
}
88
137
138
=head3 _to_api
139
140
Helper function that maps a hashref of Koha::Checkout attributes into REST api
141
attribute names.
142
143
=cut
144
145
sub _to_api {
146
    my $checkout = shift;
147
148
    foreach my $column ( keys %{ $Koha::REST::V1::Checkout::to_api_mapping } ) {
149
        my $mapped_column = $Koha::REST::V1::Checkout::to_api_mapping->{$column};
150
        if ( exists $checkout->{ $column } && defined $mapped_column )
151
        {
152
            $checkout->{ $mapped_column } = delete $checkout->{ $column };
153
        }
154
        elsif ( exists $checkout->{ $column } && !defined $mapped_column ) {
155
            delete $checkout->{ $column };
156
        }
157
    }
158
    return $checkout;
159
}
160
161
=head3 _to_model
162
163
Helper function that maps REST api objects into Koha::Checkouts
164
attribute names.
165
166
=cut
167
168
sub _to_model {
169
    my $checkout = shift;
170
171
    foreach my $attribute ( keys %{ $Koha::REST::V1::Checkout::to_model_mapping } ) {
172
        my $mapped_attribute = $Koha::REST::V1::Checkout::to_model_mapping->{$attribute};
173
        if ( exists $checkout->{ $attribute } && defined $mapped_attribute )
174
        {
175
            $checkout->{ $mapped_attribute } = delete $checkout->{ $attribute };
176
        }
177
        elsif ( exists $checkout->{ $attribute } && !defined $mapped_attribute )
178
        {
179
            delete $checkout->{ $attribute };
180
        }
181
    }
182
    return $checkout;
183
}
184
185
=head2 Global variables
186
187
=head3 $to_api_mapping
188
189
=cut
190
191
our $to_api_mapping = {
192
    issue_id        => 'checkout_id',
193
    borrowernumber  => 'patron_id',
194
    itemnumber      => 'item_id',
195
    date_due        => 'due_date',
196
    branchcode      => 'library_id',
197
    returndate      => 'checkin_date',
198
    lastreneweddate => 'last_renewed_date',
199
    issuedate       => 'checked_out_date',
200
    notedate        => 'note_date',
201
};
202
203
=head3 $to_model_mapping
204
205
=cut
206
207
our $to_model_mapping = {
208
    checkout_id       => 'issue_id',
209
    patron_id         => 'borrowernumber',
210
    item_id           => 'itemnumber',
211
    due_date          => 'date_due',
212
    library_id        => 'branchcode',
213
    checkin_date      => 'returndate',
214
    last_renewed_date => 'lastreneweddate',
215
    checked_out_date  => 'issuedate',
216
    note_date         => 'notedate',
217
};
218
89
1;
219
1;
(-)a/api/v1/swagger/definitions/checkout.json (-18 / +20 lines)
Lines 1-34 Link Here
1
{
1
{
2
  "type": "object",
2
  "type": "object",
3
  "properties": {
3
  "properties": {
4
    "issue_id": {
4
    "checkout_id": {
5
      "type": "string",
5
      "type": "integer",
6
      "description": "internally assigned checkout identifier"
6
      "description": "internally assigned checkout identifier"
7
    },
7
    },
8
    "borrowernumber": {
8
    "patron_id": {
9
      "$ref": "../x-primitives.json#/borrowernumber"
9
      "$ref": "../x-primitives.json#/patron_id"
10
    },
10
    },
11
    "itemnumber": {
11
    "item_id": {
12
      "$ref": "../x-primitives.json#/itemnumber"
12
      "type": "integer",
13
      "description": "internal identifier of checked out item"
13
    },
14
    },
14
    "date_due": {
15
    "due_date": {
15
      "type": "string",
16
      "type": "string",
17
      "format": "date-time",
16
      "description": "Due date"
18
      "description": "Due date"
17
    },
19
    },
18
    "branchcode": {
20
    "library_id": {
19
      "type": "string",
21
      "type": ["string", "null"],
20
      "description": "code of the library the item was checked out"
22
      "description": "code of the library the item was checked out"
21
    },
23
    },
22
    "issuingbranch": {
24
    "checkin_date": {
23
      "type": "string",
24
      "description": "Code of the branch where issue was made"
25
    },
26
    "returndate": {
27
      "type": ["string", "null"],
25
      "type": ["string", "null"],
26
      "format": "date",
28
      "description": "Date the item was returned"
27
      "description": "Date the item was returned"
29
    },
28
    },
30
    "lastreneweddate": {
29
    "last_renewed_date": {
31
      "type": ["string", "null"],
30
      "type": ["string", "null"],
31
      "format": "date-time",
32
      "description": "Date the item was last renewed"
32
      "description": "Date the item was last renewed"
33
    },
33
    },
34
    "renewals": {
34
    "renewals": {
Lines 43-50 Link Here
43
      "type": "string",
43
      "type": "string",
44
      "description": "Last update time"
44
      "description": "Last update time"
45
    },
45
    },
46
    "issuedate": {
46
    "checked_out_date": {
47
      "type": ["string", "null"],
47
      "type": "string",
48
      "format": "date-time",
48
      "description": "Date the item was issued"
49
      "description": "Date the item was issued"
49
    },
50
    },
50
    "onsite_checkout": {
51
    "onsite_checkout": {
Lines 55-62 Link Here
55
      "type": ["string", "null"],
56
      "type": ["string", "null"],
56
      "description": "Issue note text"
57
      "description": "Issue note text"
57
    },
58
    },
58
    "notedate": {
59
    "note_date": {
59
      "type": ["string", "null"],
60
      "type": ["string", "null"],
61
      "format": "date",
60
      "description": "Datetime of the issue note"
62
      "description": "Datetime of the issue note"
61
    }
63
    }
62
  }
64
  }
(-)a/api/v1/swagger/paths/checkouts.json (-7 / +4 lines)
Lines 1-10 Link Here
1
{
1
{
2
  "/checkouts": {
2
  "/checkouts": {
3
    "get": {
3
    "get": {
4
      "x-mojo-to": "Checkout#list",
4
      "operationId": "listCheckouts",
5
      "operationId": "listCheckouts",
5
      "tags": ["patrons", "checkouts"],
6
      "tags": ["patrons", "checkouts"],
6
      "parameters": [{
7
      "parameters": [{
7
        "$ref": "../parameters.json#/borrowernumberQueryParam"
8
        "$ref": "../parameters.json#/patron_id_qp"
8
      }],
9
      }],
9
      "produces": [
10
      "produces": [
10
        "application/json"
11
        "application/json"
Lines 26-33 Link Here
26
        }
27
        }
27
      },
28
      },
28
      "x-koha-authorization": {
29
      "x-koha-authorization": {
29
        "allow-owner": true,
30
        "allow-guarantor": true,
31
        "permissions": {
30
        "permissions": {
32
          "circulate": "circulate_remaining_permissions"
31
          "circulate": "circulate_remaining_permissions"
33
        }
32
        }
Lines 36-41 Link Here
36
  },
35
  },
37
  "/checkouts/{checkout_id}": {
36
  "/checkouts/{checkout_id}": {
38
    "get": {
37
    "get": {
38
      "x-mojo-to": "Checkout#get",
39
      "operationId": "getCheckout",
39
      "operationId": "getCheckout",
40
      "tags": ["patrons", "checkouts"],
40
      "tags": ["patrons", "checkouts"],
41
      "parameters": [{
41
      "parameters": [{
Lines 57-70 Link Here
57
        }
57
        }
58
      },
58
      },
59
      "x-koha-authorization": {
59
      "x-koha-authorization": {
60
        "allow-owner": true,
61
        "allow-guarantor": true,
62
        "permissions": {
60
        "permissions": {
63
          "circulate": "circulate_remaining_permissions"
61
          "circulate": "circulate_remaining_permissions"
64
        }
62
        }
65
      }
63
      }
66
    },
64
    },
67
    "put": {
65
    "put": {
66
      "x-mojo-to": "Checkout#renew",
68
      "operationId": "renewCheckout",
67
      "operationId": "renewCheckout",
69
      "tags": ["patrons", "checkouts"],
68
      "tags": ["patrons", "checkouts"],
70
      "parameters": [{
69
      "parameters": [{
Lines 86-93 Link Here
86
        }
85
        }
87
      },
86
      },
88
      "x-koha-authorization": {
87
      "x-koha-authorization": {
89
        "allow-owner": true,
90
        "allow-guarantor": true,
91
        "permissions": {
88
        "permissions": {
92
          "circulate": "circulate_remaining_permissions"
89
          "circulate": "circulate_remaining_permissions"
93
        }
90
        }
(-)a/t/db_dependent/api/v1/checkouts.t (-32 / +36 lines)
Lines 32-47 use C4::Circulation; Link Here
32
use C4::Items;
32
use C4::Items;
33
33
34
use Koha::Database;
34
use Koha::Database;
35
use Koha::DateUtils;
35
use Koha::Patron;
36
use Koha::Patron;
36
37
37
my $schema = Koha::Database->schema;
38
my $schema = Koha::Database->schema;
38
$schema->storage->txn_begin;
39
my $dbh = C4::Context->dbh;
40
my $builder = t::lib::TestBuilder->new;
39
my $builder = t::lib::TestBuilder->new;
41
$dbh->{RaiseError} = 1;
40
41
$schema->storage->txn_begin;
42
43
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' );
42
44
43
$ENV{REMOTE_ADDR} = '127.0.0.1';
45
$ENV{REMOTE_ADDR} = '127.0.0.1';
44
my $t = Test::Mojo->new('Koha::REST::V1');
46
my $t = Test::Mojo->new('Koha::REST::V1');
47
my $tx;
48
49
my $dbh = C4::Context->dbh;
45
50
46
$dbh->do('DELETE FROM issues');
51
$dbh->do('DELETE FROM issues');
47
$dbh->do('DELETE FROM items');
52
$dbh->do('DELETE FROM items');
Lines 73-86 my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; Link Here
73
my $module = new Test::MockModule('C4::Context');
78
my $module = new Test::MockModule('C4::Context');
74
$module->mock('userenv', sub { { branch => $branchcode } });
79
$module->mock('userenv', sub { { branch => $branchcode } });
75
80
76
my $tx = $t->ua->build_tx(GET => "/api/v1/checkouts?borrowernumber=$borrowernumber");
81
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?patron_id=$borrowernumber");
77
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
82
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
78
$t->request_ok($tx)
83
$t->request_ok($tx)
79
  ->status_is(200)
84
  ->status_is(200)
80
  ->json_is([]);
85
  ->json_is([]);
81
86
82
my $notexisting_borrowernumber = $borrowernumber + 1;
87
my $notexisting_borrowernumber = $borrowernumber + 1;
83
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?borrowernumber=$notexisting_borrowernumber");
88
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?patron_id=$notexisting_borrowernumber");
84
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
89
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
85
$t->request_ok($tx)
90
$t->request_ok($tx)
86
  ->status_is(200)
91
  ->status_is(200)
Lines 99-114 my $date_due2 = Koha::DateUtils::dt_from_string( $issue2->date_due ); Link Here
99
my $issue3 = C4::Circulation::AddIssue($loggedinuser, 'TEST000003', $date_due);
104
my $issue3 = C4::Circulation::AddIssue($loggedinuser, 'TEST000003', $date_due);
100
my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due );
105
my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due );
101
106
102
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?borrowernumber=$borrowernumber");
107
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?patron_id=$borrowernumber");
103
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
108
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
104
$t->request_ok($tx)
109
$t->request_ok($tx)
105
  ->status_is(200)
110
  ->status_is(200)
106
  ->json_is('/0/borrowernumber' => $borrowernumber)
111
  ->json_is('/0/patron_id' => $borrowernumber)
107
  ->json_is('/0/itemnumber' => $itemnumber1)
112
  ->json_is('/0/item_id' => $itemnumber1)
108
  ->json_is('/0/date_due' => $date_due1->ymd . ' ' . $date_due1->hms)
113
  ->json_is('/0/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) )
109
  ->json_is('/1/borrowernumber' => $borrowernumber)
114
  ->json_is('/1/patron_id' => $borrowernumber)
110
  ->json_is('/1/itemnumber' => $itemnumber2)
115
  ->json_is('/1/item_id' => $itemnumber2)
111
  ->json_is('/1/date_due' => $date_due2->ymd . ' ' . $date_due2->hms)
116
  ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) )
112
  ->json_hasnt('/2');
117
  ->json_hasnt('/2');
113
118
114
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/".$issue3->issue_id);
119
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/".$issue3->issue_id);
Lines 119-125 $t->request_ok($tx) Link Here
119
              required_permissions => { circulate => "circulate_remaining_permissions" }
124
              required_permissions => { circulate => "circulate_remaining_permissions" }
120
						});
125
						});
121
126
122
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?borrowernumber=".$loggedinuser->{borrowernumber});
127
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?patron_id=".$loggedinuser->{borrowernumber});
123
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
128
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
124
$t->request_ok($tx)
129
$t->request_ok($tx)
125
  ->status_is(403)
130
  ->status_is(403)
Lines 127-164 $t->request_ok($tx) Link Here
127
						  required_permissions => { circulate => "circulate_remaining_permissions" }
132
						  required_permissions => { circulate => "circulate_remaining_permissions" }
128
					  });
133
					  });
129
134
130
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?borrowernumber=$borrowernumber");
135
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts?patron_id=$borrowernumber");
131
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
136
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
132
$t->request_ok($tx)
137
$t->request_ok($tx)
133
  ->status_is(200)
138
  ->status_is(200)
134
  ->json_is('/0/borrowernumber' => $borrowernumber)
139
  ->json_is('/0/patron_id' => $borrowernumber)
135
  ->json_is('/0/itemnumber' => $itemnumber1)
140
  ->json_is('/0/item_id' => $itemnumber1)
136
  ->json_is('/0/date_due' => $date_due1->ymd . ' ' . $date_due1->hms)
141
  ->json_is('/0/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) )
137
  ->json_is('/1/borrowernumber' => $borrowernumber)
142
  ->json_is('/1/patron_id' => $borrowernumber)
138
  ->json_is('/1/itemnumber' => $itemnumber2)
143
  ->json_is('/1/item_id' => $itemnumber2)
139
  ->json_is('/1/date_due' => $date_due2->ymd . ' ' . $date_due2->hms)
144
  ->json_is('/1/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due2 }) )
140
  ->json_hasnt('/2');
145
  ->json_hasnt('/2');
141
146
142
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue1->issue_id);
147
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue1->issue_id);
143
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
148
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
144
$t->request_ok($tx)
149
$t->request_ok($tx)
145
  ->status_is(200)
150
  ->status_is(200)
146
  ->json_is('/borrowernumber' => $borrowernumber)
151
  ->json_is('/patron_id' => $borrowernumber)
147
  ->json_is('/itemnumber' => $itemnumber1)
152
  ->json_is('/item_id' => $itemnumber1)
148
  ->json_is('/date_due' => $date_due1->ymd . ' ' . $date_due1->hms)
153
  ->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) )
149
  ->json_hasnt('/1');
154
  ->json_hasnt('/1');
150
155
151
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue1->issue_id);
156
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue1->issue_id);
152
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
157
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
153
$t->request_ok($tx)
158
$t->request_ok($tx)
154
  ->status_is(200)
159
  ->status_is(200)
155
  ->json_is('/date_due' => $date_due1->ymd . ' ' . $date_due1->hms);
160
  ->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $date_due1 }) );
156
161
157
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue2->issue_id);
162
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue2->issue_id);
158
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
163
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
159
$t->request_ok($tx)
164
$t->request_ok($tx)
160
  ->status_is(200)
165
  ->status_is(200)
161
  ->json_is('/date_due' => $date_due2->ymd . ' ' . $date_due2->hms);
166
  ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $date_due2 }) );
162
167
163
168
164
$dbh->do('DELETE FROM issuingrules');
169
$dbh->do('DELETE FROM issuingrules');
Lines 172-178 $tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue1->issue_id); Link Here
172
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
177
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
173
$t->request_ok($tx)
178
$t->request_ok($tx)
174
  ->status_is(200)
179
  ->status_is(200)
175
  ->json_is('/date_due' => $expected_datedue->ymd . ' ' . $expected_datedue->hms);
180
  ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $expected_datedue }) );
176
181
177
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue3->issue_id);
182
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue3->issue_id);
178
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
183
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
Lines 187-200 $tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue2->issue_id); Link Here
187
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
192
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
188
$t->request_ok($tx)
193
$t->request_ok($tx)
189
  ->status_is(403)
194
  ->status_is(403)
190
  ->json_is({ error => "Opac Renewal not allowed"	});
195
  ->json_is({ error => "Opac Renewal not allowed" });
191
196
192
t::lib::Mocks::mock_preference( "OpacRenewalAllowed", 1 );
197
t::lib::Mocks::mock_preference( "OpacRenewalAllowed", 1 );
193
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue2->issue_id);
198
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue2->issue_id);
194
$tx->req->cookies({name => 'CGISESSID', value => $patron_session->id});
199
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
195
$t->request_ok($tx)
200
$t->request_ok($tx)
196
  ->status_is(200)
201
  ->status_is(200)
197
  ->json_is('/date_due' => $expected_datedue->ymd . ' ' . $expected_datedue->hms);
202
  ->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $expected_datedue}) );
198
203
199
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue1->issue_id);
204
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue1->issue_id);
200
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
205
$tx->req->cookies({name => 'CGISESSID', value => $session->id});
201
- 

Return to bug 13895