Skip to content

Commit

Permalink
Properly set options[:expires_in] from global_cache_options
Browse files Browse the repository at this point in the history
Fixes #91
  • Loading branch information
Frank Macreery committed Jan 24, 2016
1 parent 288916b commit 2cef1df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/garner/cache/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize(ruby_context = nil)
@key_hash = {}

# Set up options hash with defaults
@options_hash = Garner.config.global_cache_options || {}
@options_hash.merge!(expires_in: Garner.config.expires_in)
@options_hash = Garner.config.global_cache_options.dup || {}
@options_hash[:expires_in] ||= Garner.config.expires_in
end

def fetch(&block)
Expand Down
7 changes: 7 additions & 0 deletions spec/garner/cache/identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
subject.options_hash[:foo].should eq 'bar'
end

it 'includes Garner.config.global_cache_options[:expires_in]' do
Garner.configure do |config|
config.global_cache_options = { expires_in: 5.minutes }
end
subject.options_hash[:expires_in].should eq 5.minutes
end

it 'includes Garner.config.expires_in' do
Garner.configure { |config| config.expires_in = 5.minutes }
subject.options_hash[:expires_in].should eq 5.minutes
Expand Down

0 comments on commit 2cef1df

Please sign in to comment.