From ff063f4f9b866f18be95a4cb173d2fcea2e046b8 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 9 Mar 2015 13:14:02 +1100 Subject: [PATCH] play around with mock_redis, add comment explaining what happened --- spec/spec_helper.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c58755c01c2..2f888104a23 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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)