diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-12 22:31:02 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-12 17:39:46 -0500 |
commit | e75b1f11057829964dd9c3aac3b0a0deb964707e (patch) | |
tree | abcc7f1ef7eb11896103a08f1969935cf0e4cfed /spec/support | |
parent | bf073583fba475382a927b8f35df6514d4bcb88f (diff) | |
download | gitlab-ce-e75b1f11057829964dd9c3aac3b0a0deb964707e.tar.gz |
Merge branch '24185-legacy-ci-status-reactive-cache' into 'security'
Use ReactiveCaching to update external CI status asynchronously
See https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2055
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/reactive_caching_helpers.rb | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/spec/support/reactive_caching_helpers.rb b/spec/support/reactive_caching_helpers.rb index 279db3c5748..98eb57f8b54 100644 --- a/spec/support/reactive_caching_helpers.rb +++ b/spec/support/reactive_caching_helpers.rb @@ -3,31 +3,35 @@ module ReactiveCachingHelpers ([subject.class.reactive_cache_key.call(subject)].flatten + qualifiers).join(':') end - def stub_reactive_cache(subject = nil, data = nil) + def alive_reactive_cache_key(subject, *qualifiers) + reactive_cache_key(subject, *(qualifiers + ['alive'])) + end + + def stub_reactive_cache(subject = nil, data = nil, *qualifiers) allow(ReactiveCachingWorker).to receive(:perform_async) allow(ReactiveCachingWorker).to receive(:perform_in) - write_reactive_cache(subject, data) if data + write_reactive_cache(subject, data, *qualifiers) if data end - def read_reactive_cache(subject) - Rails.cache.read(reactive_cache_key(subject)) + def read_reactive_cache(subject, *qualifiers) + Rails.cache.read(reactive_cache_key(subject, *qualifiers)) end - def write_reactive_cache(subject, data) - start_reactive_cache_lifetime(subject) - Rails.cache.write(reactive_cache_key(subject), data) + def write_reactive_cache(subject, data, *qualifiers) + start_reactive_cache_lifetime(subject, *qualifiers) + Rails.cache.write(reactive_cache_key(subject, *qualifiers), data) end - def reactive_cache_alive?(subject) - Rails.cache.read(reactive_cache_key(subject, 'alive')) + def reactive_cache_alive?(subject, *qualifiers) + Rails.cache.read(alive_reactive_cache_key(subject, *qualifiers)) end - def invalidate_reactive_cache(subject) - Rails.cache.delete(reactive_cache_key(subject, 'alive')) + def invalidate_reactive_cache(subject, *qualifiers) + Rails.cache.delete(alive_reactive_cache_key(subject, *qualifiers)) end - def start_reactive_cache_lifetime(subject) - Rails.cache.write(reactive_cache_key(subject, 'alive'), true) + def start_reactive_cache_lifetime(subject, *qualifiers) + Rails.cache.write(alive_reactive_cache_key(subject, *qualifiers), true) end def expect_reactive_cache_update_queued(subject) |