FIX: SiteSettings::LocalProcessProvider didn't work on multisite
It always used "test" as current site.
This commit is contained in:
parent
0967ce478d
commit
11647b79f7
|
@ -3,9 +3,6 @@
|
|||
module SiteSettings; end
|
||||
|
||||
class SiteSettings::LocalProcessProvider
|
||||
|
||||
attr_accessor :current_site
|
||||
|
||||
class Setting
|
||||
attr_accessor :name, :data_type, :value
|
||||
|
||||
|
@ -29,7 +26,6 @@ class SiteSettings::LocalProcessProvider
|
|||
|
||||
def initialize
|
||||
@settings = {}
|
||||
self.current_site = "test"
|
||||
end
|
||||
|
||||
def all
|
||||
|
@ -61,4 +57,7 @@ class SiteSettings::LocalProcessProvider
|
|||
@settings[current_site] = {}
|
||||
end
|
||||
|
||||
def current_site
|
||||
RailsMultisite::ConnectionManagement.current_db
|
||||
end
|
||||
end
|
||||
|
|
|
@ -163,11 +163,13 @@ describe SiteSettingExtension do
|
|||
end
|
||||
|
||||
describe "multisite" do
|
||||
it "has no db cross talk" do
|
||||
it "has no db cross talk", type: :multisite do
|
||||
settings.setting(:hello, 1)
|
||||
settings.hello = 100
|
||||
settings.provider.current_site = "boom"
|
||||
expect(settings.hello).to eq(1)
|
||||
|
||||
test_multisite_connection("second") do
|
||||
expect(settings.hello).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -59,6 +59,27 @@ describe SiteSettings::LocalProcessProvider do
|
|||
end
|
||||
|
||||
it "returns the correct site name" do
|
||||
expect(provider.current_site).to eq("test")
|
||||
expect(provider.current_site).to eq("default")
|
||||
end
|
||||
|
||||
describe "multisite", type: :multisite do
|
||||
it "loads the correct settings" do
|
||||
test_multisite_connection("default") { provider.save("test", "bla-default", 2) }
|
||||
test_multisite_connection("second") { provider.save("test", "bla-second", 2) }
|
||||
|
||||
test_multisite_connection("default") do
|
||||
expect_same_setting(provider.find("test"), setting("test", "bla-default", 2))
|
||||
end
|
||||
|
||||
test_multisite_connection("second") do
|
||||
expect_same_setting(provider.find("test"), setting("test", "bla-second", 2))
|
||||
end
|
||||
end
|
||||
|
||||
it "returns the correct site name" do
|
||||
test_multisite_connection("second") do
|
||||
expect(provider.current_site).to eq("second")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -214,11 +214,20 @@ RSpec.configure do |config|
|
|||
SiteSetting.defaults.set_regardless_of_locale(k, v) if SiteSetting.respond_to? k
|
||||
end
|
||||
|
||||
SiteSetting.provider = SiteSettings::LocalProcessProvider.new
|
||||
SiteSetting.provider = TestLocalProcessProvider.new
|
||||
|
||||
WebMock.disable_net_connect!
|
||||
end
|
||||
|
||||
class TestLocalProcessProvider < SiteSettings::LocalProcessProvider
|
||||
attr_accessor :current_site
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.current_site = "test"
|
||||
end
|
||||
end
|
||||
|
||||
class DiscourseMockRedis < MockRedis
|
||||
def without_namespace
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue