Bugzilla – Attachment 124309 Details for
Bug 28932
Backend overriding status_graph element causes duplicate actions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28932: Fix duplicate next_action & prev_action
Bug-28932-Fix-duplicate-nextaction--prevaction.patch (text/plain), 7.30 KB, created by
Andrew Isherwood
on 2021-08-31 14:14:15 UTC
(
hide
)
Description:
Bug 28932: Fix duplicate next_action & prev_action
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2021-08-31 14:14:15 UTC
Size:
7.30 KB
patch
obsolete
>From b888abe99eb9864bdedfc1fb36d4945c672f6af2 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Tue, 31 Aug 2021 15:12:23 +0100 >Subject: [PATCH] Bug 28932: Fix duplicate next_action & prev_action > >This commit fixes the problem described in Bug 28932. > >Test plan: >- Run the unit tests: prove t/db_dependent/Illrequests.t >=> TEST: Ensure all tests pass >--- > Koha/Illrequest.pm | 6 +- > t/db_dependent/Illrequests.t | 121 ++++++++++++++++++++++++++++++++++- > 2 files changed, 124 insertions(+), 3 deletions(-) > >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 2eaa5accda..17240a0049 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -569,7 +569,8 @@ sub _status_graph_union { > if ( grep { $prev_action eq $_ } @core_status_ids ) { > my @next_actions = > @{$status_graph->{$prev_action}->{next_actions}}; >- push @next_actions, $backend_status_key; >+ push @next_actions, $backend_status_key >+ if (!grep(/^$backend_status_key$/, @next_actions)); > $status_graph->{$prev_action}->{next_actions} > = \@next_actions; > } >@@ -579,7 +580,8 @@ sub _status_graph_union { > if ( grep { $next_action eq $_ } @core_status_ids ) { > my @prev_actions = > @{$status_graph->{$next_action}->{prev_actions}}; >- push @prev_actions, $backend_status_key; >+ push @prev_actions, $backend_status_key >+ if (!grep(/^$backend_status_key$/, @prev_actions)); > $status_graph->{$next_action}->{prev_actions} > = \@prev_actions; > } >diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t >index 24ef726f96..ee4fcaeea2 100755 >--- a/t/db_dependent/Illrequests.t >+++ b/t/db_dependent/Illrequests.t >@@ -190,7 +190,7 @@ subtest 'Working with related objects' => sub { > > subtest 'Status Graph tests' => sub { > >- plan tests => 5; >+ plan tests => 6; > > $schema->storage->txn_begin; > >@@ -368,6 +368,125 @@ subtest 'Status Graph tests' => sub { > "new node + core_status_graph = bigger status graph" > ) || diag explain $new_graph; > >+ # Create a duplicate node >+ my $dupe_node = { >+ REQ => { >+ prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], >+ id => 'REQ', >+ name => 'Requested', >+ ui_method_name => 'Confirm request dupe', >+ method => 'confirm', >+ next_actions => [ 'REQREV', 'COMP', 'CHK' ], >+ ui_method_icon => 'fa-check', >+ } >+ }; >+ # Add the dupe node to the core_status_grpah >+ my $dupe_graph = $illrq_obj->_status_graph_union( $illrq_obj->_core_status_graph, $dupe_node); >+ # Compare the updated graph to the expected graph >+ # The structure we compare against here is just a copy of the structure found >+ # in Koha::Illrequest::_core_status_graph() + the new node we created above >+ cmp_deeply( $dupe_graph, >+ { >+ NEW => { >+ prev_actions => [ ], # Actions containing buttons >+ # leading to this status >+ id => 'NEW', # ID of this status >+ name => 'New request', # UI name of this status >+ ui_method_name => 'New request', # UI name of method leading >+ # to this status >+ method => 'create', # method to this status >+ next_actions => [ 'REQ', 'GENREQ', 'KILL' ], # buttons to add to all >+ # requests with this status >+ ui_method_icon => 'fa-plus', # UI Style class >+ }, >+ REQ => { >+ prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], >+ id => 'REQ', >+ name => 'Requested', >+ ui_method_name => 'Confirm request dupe', >+ method => 'confirm', >+ next_actions => [ 'REQREV', 'COMP', 'CHK' ], >+ ui_method_icon => 'fa-check', >+ }, >+ GENREQ => { >+ prev_actions => [ 'NEW', 'REQREV' ], >+ id => 'GENREQ', >+ name => 'Requested from partners', >+ ui_method_name => 'Place request with partners', >+ method => 'generic_confirm', >+ next_actions => [ 'COMP', 'CHK' ], >+ ui_method_icon => 'fa-send-o', >+ }, >+ REQREV => { >+ prev_actions => [ 'REQ' ], >+ id => 'REQREV', >+ name => 'Request reverted', >+ ui_method_name => 'Revert Request', >+ method => 'cancel', >+ next_actions => [ 'REQ', 'GENREQ', 'KILL' ], >+ ui_method_icon => 'fa-times', >+ }, >+ QUEUED => { >+ prev_actions => [ ], >+ id => 'QUEUED', >+ name => 'Queued request', >+ ui_method_name => 0, >+ method => 0, >+ next_actions => [ 'REQ', 'KILL' ], >+ ui_method_icon => 0, >+ }, >+ CANCREQ => { >+ prev_actions => [ 'NEW' ], >+ id => 'CANCREQ', >+ name => 'Cancellation requested', >+ ui_method_name => 0, >+ method => 0, >+ next_actions => [ 'KILL', 'REQ' ], >+ ui_method_icon => 0, >+ }, >+ COMP => { >+ prev_actions => [ 'REQ' ], >+ id => 'COMP', >+ name => 'Completed', >+ ui_method_name => 'Mark completed', >+ method => 'mark_completed', >+ next_actions => [ 'CHK' ], >+ ui_method_icon => 'fa-check', >+ }, >+ KILL => { >+ prev_actions => [ 'QUEUED', 'REQREV', 'NEW', 'CANCREQ' ], >+ id => 'KILL', >+ name => 0, >+ ui_method_name => 'Delete request', >+ method => 'delete', >+ next_actions => [ ], >+ ui_method_icon => 'fa-trash', >+ }, >+ CHK => { >+ prev_actions => [ 'REQ', 'GENREQ', 'COMP' ], >+ id => 'CHK', >+ name => 'Checked out', >+ ui_method_name => 'Check out', >+ needs_prefs => [ 'CirculateILL' ], >+ needs_perms => [ 'user_circulate_circulate_remaining_permissions' ], >+ needs_all => ignore(), >+ method => 'check_out', >+ next_actions => [ ], >+ ui_method_icon => 'fa-upload', >+ }, >+ RET => { >+ prev_actions => [ 'CHK' ], >+ id => 'RET', >+ name => 'Returned to library', >+ ui_method_name => 'Check in', >+ method => 'check_in', >+ next_actions => [ 'COMP' ], >+ ui_method_icon => 'fa-download', >+ } >+ }, >+ "new node + core_status_graph = bigger status graph" >+ ) || diag explain $dupe_graph; >+ > $schema->storage->txn_rollback; > }; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28932
:
124309
|
129020
|
129021