View | Details | Raw Unified | Return to bug 28739
Collapse All | Expand All

(-)a/C4/Letters.pm (+3 lines)
Lines 1608-1614 sub _process_tt { Link Here
1608
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1608
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1609
1609
1610
    my $output;
1610
    my $output;
1611
    my $schema = Koha::Database->new->schema;
1612
    $schema->txn_begin;
1611
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1613
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1614
    $schema->txn_rollback;
1612
1615
1613
    return $output;
1616
    return $output;
1614
}
1617
}
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +22 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 29;
22
use Test::More tests => 30;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1188-1193 EOF Link Here
1188
    is( $letter->{content}, $expected_content );
1188
    is( $letter->{content}, $expected_content );
1189
};
1189
};
1190
1190
1191
subtest 'Execute TT process in a DB transaction' => sub {
1192
    plan tests => 2;
1193
    my $code = 'TEST_TXN';
1194
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1195
    my $template = <<EOF;
1196
=[% branch.branchcode %]=
1197
[%~ branch.delete ~%]
1198
EOF
1199
    reset_template({ template => $template, code => $code, module => 'test' });
1200
    my $letter = GetPreparedLetter(
1201
        module      => 'test',
1202
        letter_code => $code,
1203
        tables      => {
1204
            branches => $library->branchcode,
1205
        }
1206
    );
1207
    my $branchcode = $library->branchcode;
1208
    like($letter->{content}, qr{=$branchcode=}, 'content generated with the library');
1209
    is( ref($library->get_from_storage), 'Koha::Library', 'calling ->delete on the object has not been comitted');
1210
};
1211
1191
sub reset_template {
1212
sub reset_template {
1192
    my ( $params ) = @_;
1213
    my ( $params ) = @_;
1193
    my $template   = $params->{template};
1214
    my $template   = $params->{template};
1194
- 

Return to bug 28739