From e13befa963323dfcd4b6d8e14b0f6980946b7e1b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 21 May 2009 10:00:45 -0500 Subject: Fixing #2288 - fixing the tests broken by my attr_ttl code Signed-off-by: Luke Kanies --- lib/puppet/util/cacher.rb | 1 + spec/unit/util/cacher.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb index ef619c9a6..e42577686 100644 --- a/lib/puppet/util/cacher.rb +++ b/lib/puppet/util/cacher.rb @@ -116,6 +116,7 @@ module Puppet::Util::Cacher end def expired_by_ttl?(name) + return false unless self.class.respond_to?(:attr_ttl) return false unless ttl = self.class.attr_ttl(name) @ttl_timestamps ||= {} diff --git a/spec/unit/util/cacher.rb b/spec/unit/util/cacher.rb index 696ef6b19..d0f5d5e92 100755 --- a/spec/unit/util/cacher.rb +++ b/spec/unit/util/cacher.rb @@ -149,6 +149,15 @@ describe Puppet::Util::Cacher do lambda { klass.cached_attr(:myattr, :ttl => "yep") { Time.now } }.should raise_error(ArgumentError) end + it "should not check for a ttl expiration if the class does not support that method" do + klass = Class.new do + extend Puppet::Util::Cacher + end + + klass.metaclass.cached_attr(:myattr) { "eh" } + klass.myattr + end + it "should automatically expire cached attributes whose ttl has expired, even if no expirer is present" do klass = Class.new do def self.to_s -- cgit