Bug 5260: QA follow-up: Fix error when no notice template is defined
authorKatrin Fischer <katrin.fischer.83@web.de>
Wed, 19 Oct 2016 21:26:22 +0000 (23:26 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 11:52:26 +0000 (11:52 +0000)
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: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Letters.pm
acqui/basket.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
t/db_dependent/Letters.t

index ef3433a..a981e8a 100644 (file)
@@ -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;
index b8caba5..054d743 100755 (executable)
@@ -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';
     }
index f94fbf4..8a114fd 100644 (file)
                 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 %]
index d283c01..3f20306 100644 (file)
@@ -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.");
 }