diff options
author | Luke Kanies <luke@madstop.com> | 2009-05-21 10:00:45 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-05-22 09:11:49 +1000 |
commit | e13befa963323dfcd4b6d8e14b0f6980946b7e1b (patch) | |
tree | c537af87be594f311d1281b0d627391e4a777d52 | |
parent | a406d585ce861757d6c14e0696a3847b46e4319d (diff) | |
download | puppet-e13befa963323dfcd4b6d8e14b0f6980946b7e1b.tar.gz puppet-e13befa963323dfcd4b6d8e14b0f6980946b7e1b.tar.xz puppet-e13befa963323dfcd4b6d8e14b0f6980946b7e1b.zip |
Fixing #2288 - fixing the tests broken by my attr_ttl code
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/util/cacher.rb | 1 | ||||
-rwxr-xr-x | spec/unit/util/cacher.rb | 9 |
2 files changed, 10 insertions, 0 deletions
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 |