summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2017-11-30 19:48:57 +0100
committerBrett Walker <bwalker@gitlab.com>2017-11-30 19:48:57 +0100
commit29e96157dfaeea16e138c6395b69dad544b94a79 (patch)
tree141b2022df307adce17dc8280046a851b7518b50
parent147f98ce808ab3cef2e84ea9afb29bc8143a4f6e (diff)
downloadgitlab-ce-bw-count-service-cache-options.tar.gz
changed how `cache_options` behavesbw-count-service-cache-options
-rw-r--r--app/services/base_count_service.rb8
-rw-r--r--spec/services/base_count_service_spec.rb4
2 files changed, 6 insertions, 6 deletions
diff --git a/app/services/base_count_service.rb b/app/services/base_count_service.rb
index 7ded81b98ca..19873fe09a5 100644
--- a/app/services/base_count_service.rb
+++ b/app/services/base_count_service.rb
@@ -9,7 +9,7 @@ class BaseCountService
end
def count
- Rails.cache.fetch(cache_key, cache_options({ raw: raw? })) { uncached_count }.to_i
+ Rails.cache.fetch(cache_key, cache_options) { uncached_count }.to_i
end
def refresh_cache
@@ -33,8 +33,8 @@ class BaseCountService
end
# subclasses can override to add any specific options, such as
- # options[:expires_in] = 5.minutes
- def cache_options(options)
- options
+ # super.merge({ expires_in: 5.minutes })
+ def cache_options
+ { raw: raw? }
end
end
diff --git a/spec/services/base_count_service_spec.rb b/spec/services/base_count_service_spec.rb
index 8cf0f6ce584..090b2dcdd43 100644
--- a/spec/services/base_count_service_spec.rb
+++ b/spec/services/base_count_service_spec.rb
@@ -79,8 +79,8 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
end
describe '#cache_options' do
- it 'returns the passed in options' do
- expect(service.cache_options({ raw: true })).to eq({ raw: true })
+ it 'returns the default in options' do
+ expect(service.cache_options).to eq({ raw: false })
end
end
end