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

(-)a/C4/Letters.pm (+3 lines)
Lines 1651-1657 sub _process_tt { Link Here
1651
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1651
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1652
1652
1653
    my $output;
1653
    my $output;
1654
    my $schema = Koha::Database->new->schema;
1655
    $schema->txn_begin;
1654
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1656
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1657
    $schema->txn_rollback;
1655
1658
1656
    return $output;
1659
    return $output;
1657
}
1660
}
(-)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 => 28;
22
use Test::More tests => 29;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1176-1181 EOF Link Here
1176
    is( $letter->{content}, $expected_content );
1176
    is( $letter->{content}, $expected_content );
1177
};
1177
};
1178
1178
1179
subtest 'Execute TT process in a DB transaction' => sub {
1180
    plan tests => 2;
1181
    my $code = 'TEST_TXN';
1182
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1183
    my $template = <<EOF;
1184
=[% branch.branchcode %]=
1185
[%~ branch.delete ~%]
1186
EOF
1187
    reset_template({ template => $template, code => $code, module => 'test' });
1188
    my $letter = GetPreparedLetter(
1189
        module      => 'test',
1190
        letter_code => $code,
1191
        tables      => {
1192
            branches => $library->branchcode,
1193
        }
1194
    );
1195
    my $branchcode = $library->branchcode;
1196
    like($letter->{content}, qr{=$branchcode=}, 'content generated with the library');
1197
    is( ref($library->get_from_storage), 'Koha::Library', 'calling ->delete on the object has not been comitted');
1198
};
1199
1179
sub reset_template {
1200
sub reset_template {
1180
    my ( $params ) = @_;
1201
    my ( $params ) = @_;
1181
    my $template   = $params->{template};
1202
    my $template   = $params->{template};
1182
- 

Return to bug 28739