Test content_log enable/disable logic

This commit is contained in:
Jared Johnson 2014-12-02 17:08:07 -06:00
parent ae887c156b
commit edc8f7600d
2 changed files with 16 additions and 5 deletions

View File

@ -6,10 +6,8 @@
use POSIX qw:strftime:; use POSIX qw:strftime:;
sub register { sub register {
my ( $self, $qp ) = @_; my ( $self ) = @_;
my $enabled = $qp->config('enable_content_log'); return if ! $self->content_log_enabled;
$enabled = 'true' if ! defined $enabled;
return if lc($enabled) ne 'true';
$self->register_hook('data_post', 'data_post_handler'); $self->register_hook('data_post', 'data_post_handler');
} }
@ -35,3 +33,11 @@ sub content_log_file {
my $date = strftime("%Y%m%d", localtime(time)); my $date = strftime("%Y%m%d", localtime(time));
return "mail/$date"; return "mail/$date";
} }
sub content_log_enabled {
my ( $self ) = @_;
my $enabled = $self->qp->config('enable_content_log');
$enabled = 'true' if ! defined $enabled;
return 1 if lc($enabled) eq 'true';
return 0;
}

View File

@ -5,8 +5,8 @@ use warnings;
sub register_tests { sub register_tests {
my ( $self ) = @_; my ( $self ) = @_;
$self->register_test('test_content_log_file'); $self->register_test('test_content_log_file');
$self->register_test('test_content_log_enabled');
} }
sub test_content_log_file { sub test_content_log_file {
@ -14,3 +14,8 @@ sub test_content_log_file {
ok( $self->content_log_file, 'content_log_file() returns something' ); ok( $self->content_log_file, 'content_log_file() returns something' );
} }
sub test_content_log_enabled {
my ( $self ) = @_;
ok( ! $self->content_log_enabled, 'content_log_enabled() returns false' );
}