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

(-)a/t/lib/QA/TemplateFilters.pm (-4 / +4 lines)
Lines 30-37 sub fix_filters { Link Here
30
    return _process_tt_content( @_ )->{new_content};
30
    return _process_tt_content( @_ )->{new_content};
31
}
31
}
32
32
33
sub search_missing_filters {
33
sub missing_filters {
34
    return _process_tt_content( @_ )->{errors};
34
    return @{_process_tt_content( @_ )->{errors}};
35
35
36
}
36
}
37
37
Lines 216-222 t::lib::QA::TemplateFilters - Module used by tests and QA script to catch missin Link Here
216
216
217
    my $content = read_file($filename);
217
    my $content = read_file($filename);
218
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($content);
218
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($content);
219
    my $errors      = t::lib::QA::TemplateFilters::search_missing_filters($content);
219
    my $errors      = t::lib::QA::TemplateFilters::missing_filters($content);
220
220
221
=head1 DESCRIPTION
221
=head1 DESCRIPTION
222
222
Lines 231-237 and to not duplicate the code. Link Here
231
    the correct (guessed) filters.
231
    the correct (guessed) filters.
232
    It will also add the [% USE raw %] statement if it is needed.
232
    It will also add the [% USE raw %] statement if it is needed.
233
233
234
=head2 search_missing_filters
234
=head2 missing_filters
235
235
236
    Take a template content file in parameter and return an arrayref of errors.
236
    Take a template content file in parameter and return an arrayref of errors.
237
237
(-)a/t/template_filters.t (-10 / +10 lines)
Lines 33-41 EXPECTED Link Here
33
33
34
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
34
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
35
    is( $new_content . "\n", $expected, );
35
    is( $new_content . "\n", $expected, );
36
    my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input);
36
    my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input);
37
    is_deeply(
37
    is_deeply(
38
        $missing_filters,
38
        \@missing_filters,
39
        [
39
        [
40
            {
40
            {
41
                error       => "asset_must_be_raw",
41
                error       => "asset_must_be_raw",
Lines 79-87 EXPECTED Link Here
79
79
80
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
80
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
81
    is( $new_content . "\n", $expected, );
81
    is( $new_content . "\n", $expected, );
82
    my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input);
82
    my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input);
83
    is_deeply(
83
    is_deeply(
84
        $missing_filters,
84
        \@missing_filters,
85
        [{
85
        [{
86
                error => "missing_filter",
86
                error => "missing_filter",
87
                line => "        [% just_a_var %]",
87
                line => "        [% just_a_var %]",
Lines 163-171 EXPECTED Link Here
163
163
164
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
164
    my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);
165
    is( $new_content . "\n", $expected, );
165
    is( $new_content . "\n", $expected, );
166
    my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input);
166
    my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input);
167
    is_deeply(
167
    is_deeply(
168
        $missing_filters,[],);
168
        \@missing_filters,[],);
169
};
169
};
170
170
171
subtest 'Preserve pre/post chomps' => sub {
171
subtest 'Preserve pre/post chomps' => sub {
Lines 228-236 EXPECTED Link Here
228
    $input = <<INPUT;
228
    $input = <<INPUT;
229
<a href="[% wrong_filter | html %]">[% var | html %]</a>
229
<a href="[% wrong_filter | html %]">[% var | html %]</a>
230
INPUT
230
INPUT
231
    my $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input);
231
    my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input);
232
    is_deeply(
232
    is_deeply(
233
        $missing_filters,
233
        \@missing_filters,
234
        [
234
        [
235
            {
235
            {
236
                error => "wrong_html_filter",
236
                error => "wrong_html_filter",
Lines 245-250 INPUT Link Here
245
    $input = <<INPUT;
245
    $input = <<INPUT;
246
<a href="[% good_raw_filter | \$raw %]">[% var | html %]</a>
246
<a href="[% good_raw_filter | \$raw %]">[% var | html %]</a>
247
INPUT
247
INPUT
248
    $missing_filters = t::lib::QA::TemplateFilters::search_missing_filters($input);
248
    @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input);
249
    is_deeply( $missing_filters, [], );
249
    is_deeply( \@missing_filters, [], );
250
};
250
};
(-)a/xt/find-missing-filters.t (-3 / +2 lines)
Lines 52-59 find({ wanted => \&wanted, no_chdir => 1 }, @themes ); Link Here
52
my @errors;
52
my @errors;
53
for my $file ( @files ) {
53
for my $file ( @files ) {
54
    my $content = read_file($file);
54
    my $content = read_file($file);
55
    my $e = t::lib::QA::TemplateFilters::search_missing_filters($content);
55
    my @e = t::lib::QA::TemplateFilters::missing_filters($content);
56
    push @errors, { file => $file, errors => $e } if @$e;
56
    push @errors, { file => $file, errors => \@e } if @e;
57
}
57
}
58
58
59
is( @errors, 0, "Template variables should be correctly escaped" )
59
is( @errors, 0, "Template variables should be correctly escaped" )
60
- 

Return to bug 21576