Bug 27944: (QA follow-up) Rename ->open for ->set_pending

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomas Cohen Arazi 2021-08-10 13:16:53 -03:00 committed by Jonathan Druart
parent 60d6b7f3eb
commit da29499e0f
4 changed files with 36 additions and 13 deletions

View File

@ -36,7 +36,7 @@ Koha::ArticleRequest - Koha Article Request Object class
=head1 API
=head2 Class Methods
=head2 Class methods
=cut
@ -53,11 +53,11 @@ sub request {
return $self;
}
=head3 open
=head3 set_pending
=cut
sub open {
sub set_pending {
my ($self) = @_;
$self->status(Koha::ArticleRequest::Status::Pending);
@ -216,6 +216,8 @@ sub store {
}
}
=head2 Internal methods
=head3 _type
=cut

View File

@ -606,7 +606,7 @@
type: "POST",
url: '/cgi-bin/koha/svc/article_request',
data: {
action: 'open',
action: 'pending',
id: id,
},
success: function( data ) {

View File

@ -50,8 +50,8 @@ if ($ar) {
elsif ( $action eq 'process' ) {
$ar = $ar->process();
}
elsif ( $action eq 'open' ) {
$ar = $ar->open();
elsif ( $action eq 'pending' ) {
$ar = $ar->set_pending();
}
elsif ( $action eq 'complete' ) {
$ar = $ar->complete();

View File

@ -19,7 +19,8 @@ use Modern::Perl;
use POSIX qw(strftime);
use Test::More tests => 54;
use Test::More tests => 55;
use Test::MockModule;
use t::lib::TestBuilder;
use t::lib::Mocks;
@ -101,8 +102,7 @@ is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->com
# cancel
$article_request->cancel();
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' );
$article_request->status(Koha::ArticleRequest::Status::Pending);
$article_request->store();
$article_request->set_pending();
is( $article_request->biblio->id, $biblio->id, '$ar->biblio() gets corresponding Koha::Biblio object' );
is( $article_request->item->id, $item->id, '$ar->item() gets corresponding Koha::Item object' );
@ -120,8 +120,7 @@ is( $patron->article_requests_current()->count(), 0, 'Completed request not retu
$article_request->cancel();
is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' );
$article_request->status(Koha::ArticleRequest::Status::Pending);
$article_request->store();
$article_request->set_pending();
is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' );
$article_request->process();
@ -130,8 +129,7 @@ $article_request->complete();
$article_request->cancel();
is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' );
$article_request->status(Koha::ArticleRequest::Status::Pending);
$article_request->store();
$article_request->set_pending();
$ar = $biblio->article_requests();
is( ref($ar), 'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' );
@ -253,3 +251,26 @@ subtest 'may_article_request' => sub {
};
$schema->storage->txn_rollback();
subtest 'set_pending() tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
my $ar = $builder->build_object(
{
class => 'Koha::ArticleRequests',
value => { status => Koha::ArticleRequest::Status::Requested }
}
);
$ar->set_pending()->discard_changes;
is( $ar->status, Koha::ArticleRequest::Status::Pending );
$schema->storage->txn_rollback;
};