Commit 1e120924 authored by Katrin Fischer's avatar Katrin Fischer Committed by Kyle M Hall

Bug 5260: QA follow-up: Fix error when no notice template is defined

When no notice template ACQORDER was defined, you'r receive a false
positive "email sent" message. Now it will display a specific
error message instead.

Also includes 2 unit tests to test for the warn and new error code.
Signed-off-by: joubu's avatarJonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: default avatarKyle M Hall <kyle@bywatersolutions.com>
parent 0ca7ac9d
......@@ -566,7 +566,7 @@ sub SendAlerts {
},
repeat => $dataorders,
want_librarian => 1,
) or return;
) or return { error => "no_letter" };
# Remove the order tag
$letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms;
......
......@@ -178,10 +178,8 @@ if ( $op eq 'delete_confirm' ) {
};
if ( $@ ) {
$redirect_url .= '&email_error='.$@;
} elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
$redirect_url .= '&email_error=no_email';
} elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_basketno" ) {
$redirect_url .= '&email_error=no_basketno';
} elsif ( ref $err and exists $err->{error} ) {
$redirect_url .= '&email_error=' . $err->{error};
} else {
$redirect_url .= '&email_ok=1';
}
......
......@@ -301,6 +301,8 @@
This vendor has no contact selected for sending orders to or is missing an e-mail address.
[% ELSIF ( email_error == "no_basketno" ) %]
No basket given.
[% ELSIF ( email_error == "no_letter" ) %]
There is no notice template with code ACQORDER defined.
[% ELSE %]
ERROR! - [% email_error %]
[% END %]
......
......@@ -18,7 +18,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 78;
use Test::More tests => 80;
use Test::MockModule;
use Test::Warn;
......@@ -431,6 +431,13 @@ warning_is {
is($err, 1, "Successfully sent order.");
is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent order");
is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Order notice text constructed successfully');
$dbh->do(q{DELETE FROM letter WHERE code = 'TESTACQORDER';});
warning_like {
$err = SendAlerts( 'orderacquisition', $basketno , 'TESTACQORDER' ) }
qr/No orderacquisition TESTACQORDER letter transported by email/,
"GetPreparedLetter warns about missing notice template";
is($err->{'error'}, 'no_letter', "No TESTACQORDER letter was defined.");
}
......
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