2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-20 08:33:29 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-09-10 22:15:06 -04:00
|
|
|
RSpec.describe 'Multisite SiteSettings', type: :multisite do
|
2017-10-20 08:33:29 -04:00
|
|
|
def cache(name, namespace: true)
|
|
|
|
DistributedCache.new(name, namespace: namespace)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without namespace' do
|
|
|
|
let(:cache1) { cache('test', namespace: false) }
|
|
|
|
|
|
|
|
it 'does not leak state across multisite' do
|
|
|
|
cache1['default'] = true
|
|
|
|
|
|
|
|
expect(cache1.hash).to eq('default' => true)
|
|
|
|
|
2019-01-09 15:13:02 -05:00
|
|
|
test_multisite_connection('second') do
|
2017-10-20 08:33:29 -04:00
|
|
|
message = MessageBus.track_publish(DistributedCache::Manager::CHANNEL_NAME) do
|
|
|
|
cache1['second'] = true
|
|
|
|
end.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)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(cache1.hash).to eq('default' => true, 'second' => true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|