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

(-)a/Koha/ArticleRequest.pm (-3 / +5 lines)
Lines 36-42 Koha::ArticleRequest - Koha Article Request Object class Link Here
36
36
37
=head1 API
37
=head1 API
38
38
39
=head2 Class Methods
39
=head2 Class methods
40
40
41
=cut
41
=cut
42
42
Lines 53-63 sub request { Link Here
53
    return $self;
53
    return $self;
54
}
54
}
55
55
56
=head3 open
56
=head3 set_pending
57
57
58
=cut
58
=cut
59
59
60
sub open {
60
sub set_pending {
61
    my ($self) = @_;
61
    my ($self) = @_;
62
62
63
    $self->status(Koha::ArticleRequest::Status::Pending);
63
    $self->status(Koha::ArticleRequest::Status::Pending);
Lines 216-221 sub store { Link Here
216
    }
216
    }
217
}
217
}
218
218
219
=head2 Internal methods
220
219
=head3 _type
221
=head3 _type
220
222
221
=cut
223
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (-1 / +1 lines)
Lines 606-612 Link Here
606
                type: "POST",
606
                type: "POST",
607
                url: '/cgi-bin/koha/svc/article_request',
607
                url: '/cgi-bin/koha/svc/article_request',
608
                data: {
608
                data: {
609
                    action: 'open',
609
                    action: 'pending',
610
                    id: id,
610
                    id: id,
611
                },
611
                },
612
                success: function( data ) {
612
                success: function( data ) {
(-)a/svc/article_request (-2 / +2 lines)
Lines 50-57 if ($ar) { Link Here
50
    elsif ( $action eq 'process' ) {
50
    elsif ( $action eq 'process' ) {
51
        $ar = $ar->process();
51
        $ar = $ar->process();
52
    }
52
    }
53
    elsif ( $action eq 'open' ) {
53
    elsif ( $action eq 'pending' ) {
54
        $ar = $ar->open();
54
        $ar = $ar->set_pending();
55
    }
55
    }
56
    elsif ( $action eq 'complete' ) {
56
    elsif ( $action eq 'complete' ) {
57
        $ar = $ar->complete();
57
        $ar = $ar->complete();
(-)a/t/db_dependent/ArticleRequests.t (-8 / +28 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 54;
22
use Test::More tests => 55;
23
use Test::MockModule;
23
24
24
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
25
use t::lib::Mocks;
26
use t::lib::Mocks;
Lines 101-108 is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->com Link Here
101
# cancel
102
# cancel
102
$article_request->cancel();
103
$article_request->cancel();
103
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' );
104
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' );
104
$article_request->status(Koha::ArticleRequest::Status::Pending);
105
$article_request->set_pending();
105
$article_request->store();
106
106
107
is( $article_request->biblio->id,   $biblio->id, '$ar->biblio() gets corresponding Koha::Biblio object' );
107
is( $article_request->biblio->id,   $biblio->id, '$ar->biblio() gets corresponding Koha::Biblio object' );
108
is( $article_request->item->id,     $item->id,   '$ar->item() gets corresponding Koha::Item object' );
108
is( $article_request->item->id,     $item->id,   '$ar->item() gets corresponding Koha::Item object' );
Lines 120-127 is( $patron->article_requests_current()->count(), 0, 'Completed request not retu Link Here
120
$article_request->cancel();
120
$article_request->cancel();
121
is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' );
121
is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' );
122
122
123
$article_request->status(Koha::ArticleRequest::Status::Pending);
123
$article_request->set_pending();
124
$article_request->store();
125
124
126
is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' );
125
is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' );
127
$article_request->process();
126
$article_request->process();
Lines 130-137 $article_request->complete(); Link Here
130
$article_request->cancel();
129
$article_request->cancel();
131
is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' );
130
is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' );
132
131
133
$article_request->status(Koha::ArticleRequest::Status::Pending);
132
$article_request->set_pending();
134
$article_request->store();
135
133
136
$ar = $biblio->article_requests();
134
$ar = $biblio->article_requests();
137
is( ref($ar),      'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' );
135
is( ref($ar),      'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' );
Lines 253-255 subtest 'may_article_request' => sub { Link Here
253
};
251
};
254
252
255
$schema->storage->txn_rollback();
253
$schema->storage->txn_rollback();
256
- 
254
255
subtest 'set_pending() tests' => sub {
256
257
    plan tests => 2;
258
259
    $schema->storage->txn_begin;
260
261
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
262
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
263
264
    my $ar = $builder->build_object(
265
        {
266
            class => 'Koha::ArticleRequests',
267
            value => { status => Koha::ArticleRequest::Status::Requested }
268
        }
269
    );
270
271
    $ar->set_pending()->discard_changes;
272
273
    is( $ar->status, Koha::ArticleRequest::Status::Pending );
274
275
    $schema->storage->txn_rollback;
276
};

Return to bug 27944