Commit 17e2e6c9 authored by Marcel de Rooy's avatar Marcel de Rooy Committed by Brendan Gallagher

Bug 17441: [QA Follow-up] Return value of SendAlerts

This patch makes the return value of SendAlerts more consistent.
It returns 1 on success, or undef || { error => 'msg' } on failure.
Needed to adjust one test in Letters.t too.
Adjusted one typo along the way (seleted).
Signed-off-by: default avatarMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested by running Letters.t.
Also tested SendAlerts from the interface with AutoEmailOpacUser and
memberentry (adding new patron).
Signed-off-by: default avatarBrendan Gallagher <brendan@bywatersolutions.com>
parent ff495c5f
......@@ -372,6 +372,9 @@ sub findrelatedto {
send an alert to all borrowers having put an alert on a given subject.
Returns undef or { error => 'message } on failure.
Returns true on success.
=cut
sub SendAlerts {
......@@ -441,7 +444,10 @@ sub SendAlerts {
: 'text/plain; charset="utf-8"',
}
);
sendmail(%mail) or carp $Mail::Sendmail::error;
unless( sendmail(%mail) ) {
carp $Mail::Sendmail::error;
return { error => $Mail::Sendmail::error };
}
}
}
elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' ) {
......@@ -469,7 +475,7 @@ sub SendAlerts {
if (!@$externalid){
carp "No Order seleted";
return { error => "no_order_seleted" };
return { error => "no_order_selected" };
}
$strsth .= join( ",", @$externalid ) . ")";
......@@ -555,7 +561,6 @@ sub SendAlerts {
. " Content="
. $letter->{content}
) if C4::Context->preference("LetterLog");
1;
}
# send an "account details" notice to a newly created user
elsif ( $type eq 'members' ) {
......@@ -589,8 +594,14 @@ sub SendAlerts {
: 'text/plain; charset="utf-8"',
}
);
sendmail(%mail) or carp $Mail::Sendmail::error;
unless( sendmail(%mail) ) {
carp $Mail::Sendmail::error;
return { error => $Mail::Sendmail::error };
}
}
# If we come here, return an OK status
return 1;
}
=head2 GetPreparedLetter( %params )
......
......@@ -467,7 +467,7 @@ warning_is {
$err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
"Fake sendmail",
"SendAlerts is using the mocked sendmail routine";
is($err2, "", "Successfully sent serial notification");
is($err2, 1, "Successfully sent serial notification");
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment