From 27d3a1ab998c21d35e37ddb0b0f3603720c497aa Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 23 May 2017 16:11:06 -0400 Subject: [PATCH] Bug 18478 - QA Followup Make sure to build necessary letters Fix awkward construction --- C4/Letters.pm | 2 +- t/db_dependent/Reserves.t | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index e0aaafe..cd7b785 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1054,7 +1054,7 @@ sub SendQueuedMessages { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } ); next MESSAGE; } - $message->{to_address} = $message->{to_address} ? $message->{to_address} : $member->{'smsalertnumber'}; + $message->{to_address} ||= $member->{'smsalertnumber'}; unless ( $message->{to_address} && $member->{'smsalertnumber'} ) { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } ); warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug; diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 0ac07f3..1a2d33c 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -733,14 +733,30 @@ subtest '_koha_notify_reserve() tests' => sub { }; my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); + $mp->mock("GetMessagingPreferences",$wants_hold_and_email); - my $sms_hold_notice = $builder->build_object({ - class => 'Koha::Notice::Templates', + $dbh->do('DELETE FROM letter'); + + my $email_hold_notice = $builder->build({ + source => 'Letter', + value => { + message_transport_type => 'email', + branchcode => '', + code => 'HOLD', + module => 'reserves', + lang => 'default', + } + }); + + my $sms_hold_notice = $builder->build({ + source => 'Letter', value => { message_transport_type => 'sms', branchcode => '', code => 'HOLD', + module => 'reserves', + lang=>'default', } }); -- 2.1.4