From 5be6256b524d3114c3b701135d37309303787e23 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 31 Mar 2023 09:43:53 -0400 Subject: [PATCH] LP#1752334: (follow-up) adjust to allow "0" as a note Also ignore the additional note parameter if all it has are zero or more whitespace characters. It's unlikely that a client would want to set the additional note to "0", but it's nonetheless a good idea to distinguish between difference versions of Perl's false value. Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/lib/OpenILS/Utils/BadContact.pm | 7 ++++++- Open-ILS/src/perlmods/live_t/36-lp1752334-badcontact.t | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/BadContact.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/BadContact.pm index 78a5b4be38..edacc92b86 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/BadContact.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/BadContact.pm @@ -99,10 +99,15 @@ sub mark_users_contact_invalid { $usr_penalty->standing_penalty($penalty->id); $usr_penalty->staff($staff_id); + my $message = $_->$contact_type; + if (defined($addl_note) && $addl_note !~ /^\s*$/) { + $message .= ' ' . $addl_note; + } + my ($result) = $U->simplereq('open-ils.actor', 'open-ils.actor.user.penalty.apply', $editor->authtoken, $usr_penalty, - { message => $addl_note ? $_->$contact_type.' '.$addl_note : $_->$contact_type } + { message => $message } ); # FIXME: this perpetuates a bug; the patron editor UI doesn't handle these error states well diff --git a/Open-ILS/src/perlmods/live_t/36-lp1752334-badcontact.t b/Open-ILS/src/perlmods/live_t/36-lp1752334-badcontact.t index f927227cdb..c0ab921ddf 100644 --- a/Open-ILS/src/perlmods/live_t/36-lp1752334-badcontact.t +++ b/Open-ILS/src/perlmods/live_t/36-lp1752334-badcontact.t @@ -20,6 +20,7 @@ use constant { PHONE => '218-555-0177', EMAIL => 'nouser@evergreen-ils.test', TESTMESSAGE => '123456 TEST Invalidate Message', + TESTMESSAGE_ZERO => '0', PROFILE => 2, #patrons }; @@ -141,7 +142,7 @@ sub check_penalty { my $penalty = $ausp->[0]; #print ref($penalty)."\n"; - my $message = $data{$type}[$i].($note ? ' '.$note : ''); + my $message = $data{$type}[$i].(defined($note) ? ' '.$note : ''); isa_ok($penalty, 'Fieldmapper::actor::usr_message_penalty', 'User Penalty Found -- '.$type); is($penalty->message(), $message, $type.' penalty note matches expected format.'); @@ -210,7 +211,7 @@ invalidate_all($user->id(),undef,$user->home_ou(),undef); #Invalidate all notifications for user 2 - added note diag("Patron 2 - Added note"); $user = $aus->[1]; -invalidate_all($user->id(),TESTMESSAGE,$user->home_ou(),undef); +invalidate_all($user->id(),TESTMESSAGE_ZERO,$user->home_ou(),undef); #Invalidate notifications for users 3,4,5 - using search method with test message diag("Patron 3,4,5 - Added note - same contact info"); @@ -225,7 +226,7 @@ check_all_penalties($user->id(),undef,$user->home_ou(),undef,1); diag("Patron 2 - Added note"); $user = $aus->[1]; -check_all_penalties($user->id(),TESTMESSAGE,$user->home_ou(),undef,2); +check_all_penalties($user->id(),TESTMESSAGE_ZERO,$user->home_ou(),undef,2); diag("Patron 3 - Added note - same contact info"); $user = $aus->[2]; @@ -240,4 +241,4 @@ $user = $aus->[4]; check_all_penalties($user->id(),TESTMESSAGE,$user->home_ou(),undef,3); # Logout -$script->logout(); # Not a test, just to be pedantic. \ No newline at end of file +$script->logout(); # Not a test, just to be pedantic. -- 2.11.0