Bug 11112: (follow-up) repair Koha::Calendar->add_holiday()
authorGalen Charlton <gmc@esilibrary.com>
Tue, 10 Dec 2013 18:11:37 +0000 (18:11 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 10 Dec 2013 18:19:15 +0000 (18:19 +0000)
This patch ensures that the package-level cache is updated
when add_holiday() is used.  Note that except for the test
case added by this patch, there doesn't seem to be anything
that actually calls ->add_holiday(); it may be better to remove it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Koha/Calendar.pm
t/db_dependent/Holidays.t

index 4e799e5..293ba88 100644 (file)
@@ -341,6 +341,7 @@ sub add_holiday {
     push @dt, $new_dt;
     $self->{single_holidays} =
       DateTime::Set->from_datetimes( dates => \@dt );
+    $single_holidays = $self->{single_holidays};
 
     return;
 }
index 5c4da1b..9d41105 100755 (executable)
@@ -5,7 +5,7 @@ use DateTime;
 use DateTime::TimeZone;
 
 use C4::Context;
-use Test::More tests => 8;
+use Test::More tests => 10;
 
 BEGIN { use_ok('Koha::Calendar'); }
 BEGIN { use_ok('C4::Calendar'); }
@@ -43,3 +43,13 @@ is( $koha_calendar->is_holiday($sunday),    1, 'Sunday is a closed day' );
 is( $koha_calendar->is_holiday($monday),    0, 'Monday is not a closed day' );
 is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' );
 is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' );
+
+my $custom_holiday = DateTime->new(
+    year  => 2013,
+    month => 11,
+    day   => 12,
+);
+is( $koha_calendar->is_holiday($custom_holiday), 0, '2013-11-10 does not start off as a holiday' );
+$koha_calendar->add_holiday($custom_holiday);
+is( $koha_calendar->is_holiday($custom_holiday), 1, 'able to add holiday for testing' );
+