PERF: use before suite vs before file

BUGFIX: correctly punch through settings to local provider
This commit is contained in:
Sam 2014-03-28 16:34:20 +11:00
parent f3cc7360e0
commit 64b0d7e0ea
1 changed files with 21 additions and 15 deletions

View File

@ -52,16 +52,33 @@ Spork.prefork do
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = true
# if we need stuff post fork, pre tests run here
# config.before(:suite) do
# end
config.before(:suite) do
config.before do
DiscoursePluginRegistry.clear if ENV['LOAD_PLUGINS'] != "1"
Discourse.current_user_provider = TestCurrentUserProvider
SiteSetting.refresh!
# Rebase defaults
#
# We nuke the DB storage provider from site settings, so need to yank out the existing settings
# and pretend they are default.
# There are a bunch of settings that are seeded, they must be loaded as defaults
SiteSetting.current.each do |k,v|
SiteSetting.defaults[k] = v
end
require_dependency 'site_settings/local_process_provider'
SiteSetting.provider = SiteSettings::LocalProcessProvider.new
end
config.before :each do |x|
# disable all observers, enable as needed during specs
ActiveRecord::Base.observers.disable :all
SiteSetting.provider.all.each do |setting|
SiteSetting.remove_override!(setting.name)
end
end
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
@ -76,17 +93,6 @@ Spork.prefork do
end
end
config.before(:all) do
DiscoursePluginRegistry.clear if ENV['LOAD_PLUGINS'] != "1"
Discourse.current_user_provider = TestCurrentUserProvider
# a bit odd, but this setting is actually preloaded
SiteSetting.defaults[:uncategorized_category_id] = SiteSetting.uncategorized_category_id
require_dependency 'site_settings/local_process_provider'
SiteSetting.provider = SiteSettings::LocalProcessProvider.new
end
end
def freeze_time(now=Time.now)