play around with mock_redis, add comment explaining what happened

This commit is contained in:
Sam 2015-03-09 13:14:02 +11:00
parent da5446a438
commit ff063f4f9b
1 changed files with 21 additions and 0 deletions

View File

@ -82,8 +82,29 @@ Spork.prefork do
SiteSetting.provider = SiteSettings::LocalProcessProvider.new
end
class DiscourseMockRedis < MockRedis
def without_namespace
self
end
def delete_prefixed(prefix)
keys("#{prefix}*").each { |k| del(k) }
end
end
config.before :each do |x|
# TODO not sure about this, we could use a mock redis implementation here:
# this gives us really clean "flush" semantics, howere the side-effect is that
# we are no longer using a clean redis implementation, a preferable solution may
# be simply flushing before tests, trouble is that redis may be reused with dev
# so that would mean the dev would act weird
#
# perf benefit seems low (shaves 20 secs off a 4 minute test suite)
#
# $redis = DiscourseMockRedis.new
#
# disable all observers, enable as needed during specs
#
ActiveRecord::Base.observers.disable :all
SiteSetting.provider.all.each do |setting|
SiteSetting.remove_override!(setting.name)