From 3b6b8a4a1e59c773bd3feaa94b1139c2ccdfbbd4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 25 Nov 2014 15:34:33 +0100 Subject: [PATCH] Bug 13215: Fix GetLetterTemplates should return default templates if branchcode is not defined Signed-off-by: Tomas Cohen Arazi --- C4/Letters.pm | 2 +- t/db_dependent/Letters/GetLetterTemplates.t | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 0b307f3917..a11c86276d 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -115,7 +115,7 @@ sub GetLetterTemplates { my $module = $params->{module}; my $code = $params->{code}; - my $branchcode = $params->{branchcode}; + my $branchcode = $params->{branchcode} // ''; my $dbh = C4::Context->dbh; my $letters = $dbh->selectall_hashref( q| diff --git a/t/db_dependent/Letters/GetLetterTemplates.t b/t/db_dependent/Letters/GetLetterTemplates.t index acde0a60e4..5beb658c4c 100644 --- a/t/db_dependent/Letters/GetLetterTemplates.t +++ b/t/db_dependent/Letters/GetLetterTemplates.t @@ -1,5 +1,5 @@ use Modern::Perl; -use Test::More tests => 6; +use Test::More tests => 7; use C4::Context; use C4::Letters qw( GetLetterTemplates ); @@ -123,3 +123,8 @@ is( scalar( keys %$letter_templates ), 1, '1 template should exist for circulation CPL code1' ); is( exists( $letter_templates->{email} ), 1, 'The mtt should be email for circulation CPL code1' ); + +$letter_templates = C4::Letters::GetLetterTemplates( + { module => 'circulation', code => 'code1' } ); +is( scalar( keys %$letter_templates ), + 2, '2 default templates should exist for circulation code1 (even if branchcode is not given)' ); -- 2.39.5