2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
RSpec.describe "Multisite SiteSettings", type: :multisite do
|
2017-10-20 20:33:29 +08:00
|
|
|
def cache(name, namespace: true)
|
|
|
|
DistributedCache.new(name, namespace: namespace)
|
|
|
|
end
|
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
context "without namespace" do
|
|
|
|
let(:cache1) { cache("test", namespace: false) }
|
2017-10-20 20:33:29 +08:00
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
it "does not leak state across multisite" do
|
|
|
|
cache1["default"] = true
|
2017-10-20 20:33:29 +08:00
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
expect(cache1.hash).to eq("default" => true)
|
2017-10-20 20:33:29 +08:00
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
test_multisite_connection("second") do
|
|
|
|
message =
|
|
|
|
MessageBus
|
|
|
|
.track_publish(DistributedCache::Manager::CHANNEL_NAME) { cache1["second"] = true }
|
|
|
|
.first
|
2017-10-20 20:33:29 +08:00
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
expect(message.data[:hash_key]).to eq("test")
|
2017-10-20 20:33:29 +08:00
|
|
|
expect(message.data[:op]).to eq(:set)
|
2023-01-09 19:18:21 +08:00
|
|
|
expect(message.data[:key]).to eq("second")
|
2017-10-20 20:33:29 +08:00
|
|
|
expect(message.data[:value]).to eq(true)
|
|
|
|
end
|
|
|
|
|
2023-01-09 19:18:21 +08:00
|
|
|
expect(cache1.hash).to eq("default" => true, "second" => true)
|
2017-10-20 20:33:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|