diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-01-28 23:08:28 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-01-29 13:03:47 -0500 |
commit | 4eafc188437e0214c09d59083586ea871b625b14 (patch) | |
tree | ccd2fa1720f48ef7abe29fae603d3fa52dd67287 /spec/lib | |
parent | d54f80980432d781b8730c672576e5e47620f502 (diff) | |
download | gitlab-ce-4eafc188437e0214c09d59083586ea871b625b14.tar.gz |
Refactor Repository to use new RepositoryCache class
Abstracts away the lower-level implementation details from the
Repository model.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/repository_cache_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/repository_cache_spec.rb b/spec/lib/repository_cache_spec.rb new file mode 100644 index 00000000000..af399f3a731 --- /dev/null +++ b/spec/lib/repository_cache_spec.rb @@ -0,0 +1,34 @@ +require 'rspec' +require_relative '../../lib/repository_cache' + +describe RepositoryCache do + let(:backend) { double('backend').as_null_object } + let(:cache) { RepositoryCache.new('example', backend) } + + describe '#cache_key' do + it 'includes the namespace' do + expect(cache.cache_key(:foo)).to eq 'foo:example' + end + end + + describe '#expire' do + it 'expires the given key from the cache' do + cache.expire(:foo) + expect(backend).to have_received(:delete).with('foo:example') + end + end + + describe '#fetch' do + it 'fetches the given key from the cache' do + cache.fetch(:bar) + expect(backend).to have_received(:fetch).with('bar:example') + end + + it 'accepts a block' do + p = -> {} + + cache.fetch(:baz, &p) + expect(backend).to have_received(:fetch).with('baz:example', &p) + end + end +end |