From edc8f7600dbfdb8125ed06a7db957d88609ac924 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Tue, 2 Dec 2014 17:08:07 -0600 Subject: [PATCH] Test content_log enable/disable logic --- plugins/content_log | 14 ++++++++++---- t/plugin_tests/content_log | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/content_log b/plugins/content_log index 992c1f5..6b884ea 100644 --- a/plugins/content_log +++ b/plugins/content_log @@ -6,10 +6,8 @@ use POSIX qw:strftime:; sub register { - my ( $self, $qp ) = @_; - my $enabled = $qp->config('enable_content_log'); - $enabled = 'true' if ! defined $enabled; - return if lc($enabled) ne 'true'; + my ( $self ) = @_; + return if ! $self->content_log_enabled; $self->register_hook('data_post', 'data_post_handler'); } @@ -35,3 +33,11 @@ sub content_log_file { my $date = strftime("%Y%m%d", localtime(time)); 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; +} diff --git a/t/plugin_tests/content_log b/t/plugin_tests/content_log index 7355815..a4ea0d9 100644 --- a/t/plugin_tests/content_log +++ b/t/plugin_tests/content_log @@ -5,8 +5,8 @@ use warnings; sub register_tests { my ( $self ) = @_; - $self->register_test('test_content_log_file'); + $self->register_test('test_content_log_enabled'); } sub test_content_log_file { @@ -14,3 +14,8 @@ sub test_content_log_file { 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' ); +} +