From 36f90d17c429c6e946e4e1ead8f391a8e2e33713 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Tue, 9 Jul 2024 18:05:40 +0200 Subject: [PATCH] Check if rpsec concurrency changes do a thing --- lib/cached_resource/configuration.rb | 2 ++ spec/cached_resource/caching_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/cached_resource/configuration.rb b/lib/cached_resource/configuration.rb index e35703a..ea532c6 100644 --- a/lib/cached_resource/configuration.rb +++ b/lib/cached_resource/configuration.rb @@ -12,6 +12,8 @@ class Configuration < OpenStruct # prefix for log messages LOGGER_PREFIX = "[cached_resource]" + # "Internal" variable to represent enabling concurrency + # so that we know when its value changes. attr_reader :concurrent_write # Initialize a Configuration with the given options, overriding any diff --git a/spec/cached_resource/caching_spec.rb b/spec/cached_resource/caching_spec.rb index efc927e..b8b492a 100644 --- a/spec/cached_resource/caching_spec.rb +++ b/spec/cached_resource/caching_spec.rb @@ -107,7 +107,14 @@ class NotTheThing < ActiveResource::Base it "should cache a response asynchronusly when on" do Thing.cached_resource.concurrent_write = true + expect(Concurrent::Promise).to receive(:execute).and_wrap_original do |original_method, *args, &block| + original_method.call(*args, &block) + end result = Thing.find(5) + # sleep 1 + # expect(Concurrent::Promise).to receive(:execute) + # Concurrent::Promise.execute + read_from_cache("thing/5").should == nil loops = 0 begin