diff --git a/spec/multisite/distributed_cache_spec.rb b/spec/multisite/distributed_cache_spec.rb index 0fed72dee8d..f269c748352 100644 --- a/spec/multisite/distributed_cache_spec.rb +++ b/spec/multisite/distributed_cache_spec.rb @@ -8,7 +8,7 @@ RSpec.describe "Multisite SiteSettings", type: :multisite do context "without namespace" do let(:cache1) { cache("test", namespace: false) } - it "does not leak state across multisite" do + it "does share a global state between multisite" do cache1["default"] = true expect(cache1.hash).to eq("default" => true) @@ -23,9 +23,35 @@ RSpec.describe "Multisite SiteSettings", type: :multisite do expect(message.data[:op]).to eq(:set) expect(message.data[:key]).to eq("second") expect(message.data[:value]).to eq(true) + expect(cache1.hash).to eq("default" => true, "second" => true) end expect(cache1.hash).to eq("default" => true, "second" => true) end end + + context "with namespace" do + let(:cache1) { cache("test", namespace: true) } + + it "does not share a state between multisite" do + cache1["default"] = true + + expect(cache1.hash).to eq("default" => true) + + test_multisite_connection("second") do + message = + MessageBus + .track_publish(DistributedCache::Manager::CHANNEL_NAME) { cache1["second"] = true } + .first + + expect(message.data[:hash_key]).to eq("test") + expect(message.data[:op]).to eq(:set) + expect(message.data[:key]).to eq("second") + expect(message.data[:value]).to eq(true) + expect(cache1.hash).to eq("second" => true) + end + + expect(cache1.hash).to eq("default" => true) + end + end end