Skip to content

Commit 53c75d2

Browse files
Merge branch '5.0/sqlite-function-and-bind' into 5.0-trunk
2 parents 492a03a + 284c402 commit 53c75d2

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

lib/RT/Handle.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ sub Connect {
152152
$self->dbh->do( "SET statement_timeout = " . int( $timeout * 1000 ) )
153153
if defined $timeout && length $timeout;
154154
}
155+
elsif ( $db_type eq 'SQLite' ) {
156+
$self->dbh->{sqlite_see_if_its_a_number} = 1;
157+
}
155158

156159
$self->dbh->{'LongReadLen'} = RT->Config->Get('MaxAttachmentSize');
157160
}

t/shredder/03plugin_attachments.t

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
use strict;
2+
use warnings;
3+
4+
use Test::Deep;
5+
use RT::Test::Shredder tests => undef;
6+
use MIME::Entity;
7+
8+
my $test = "RT::Test::Shredder";
9+
10+
my @ARGS = sort qw(limit files_only file longer);
11+
12+
use_ok('RT::Shredder::Plugin::Attachments');
13+
{
14+
my $plugin = RT::Shredder::Plugin::Attachments->new;
15+
isa_ok( $plugin, 'RT::Shredder::Plugin::Attachments' );
16+
17+
is( lc $plugin->Type, 'search', 'correct type' );
18+
19+
my @args = sort $plugin->SupportArgs;
20+
cmp_deeply( \@args, \@ARGS, "support all args" );
21+
}
22+
23+
{
24+
my $ticket = RT::Ticket->new( RT->SystemUser );
25+
my $mime = MIME::Entity->build(
26+
From => 'test@example.com',
27+
Type => 'text/html',
28+
Data => ['test attachment'],
29+
);
30+
31+
$mime->attach(
32+
Path => 'share/static/images/bpslogo.png',
33+
Type => 'image/png',
34+
);
35+
36+
RT::Test->create_ticket( MIMEObj => $mime, Queue => 'General', Subject => 'test attachment' );
37+
my $attachments = RT::Attachments->new( RT->SystemUser );
38+
$attachments->Limit( FIELD => 'Filename', VALUE => 'bpslogo.png' );
39+
is( $attachments->Count, 1, 'created the attachment' );
40+
41+
my $plugin = RT::Shredder::Plugin::Attachments->new;
42+
my ( $status, $msg ) = $plugin->TestArgs( name => 'bpslogo.png', longer => '1k' );
43+
ok( $status, "plugin arguments are ok" ) or diag "error: $msg";
44+
45+
( $status, my @objects ) = $plugin->Run;
46+
ok( $status, "executed plugin successfully" ) or diag "error: @objects";
47+
is( scalar @objects, 1, 'found 1 attachment' );
48+
49+
my $shredder = $test->shredder_new();
50+
$shredder->PutObjects( Objects => \@objects );
51+
$shredder->WipeoutAll;
52+
53+
$attachments = RT::Attachments->new( RT->SystemUser );
54+
$attachments->Limit( FIELD => 'Filename', VALUE => 'bpslogo.png' );
55+
is( $attachments->Count, 0, 'shredded the attachment' );
56+
}
57+
58+
done_testing;

0 commit comments

Comments
 (0)