From fd5c8370239ba970776aa345f4485e96a78f96ac Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 26 Mar 2013 14:30:35 +1100 Subject: Unraveled another test environment cleanup bug with config.order = random:33691 --- spec/spec_helper.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c1b2d094c..57ab88da2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -71,6 +71,19 @@ Spork.prefork do ActionMailer::Base.deliveries = [] end + # Any test that messes with the locale needs to restore the state afterwards so that it + # doesn't interfere with any subsequent tests. This is made more complicated by the + # ApplicationController#set_gettext_locale which sets the locale and so you may be setting + # the locale in your tests and not even realising it. So, let's make things easier for + # ourselves and just always restore the locale for all tests. + config.before(:each) do + @save_i18n_locale = I18n.locale + end + + config.after(:each) do + I18n.locale = @save_i18n_locale + end + # This section makes the garbage collector run less often to speed up tests last_gc_run = Time.now -- cgit v1.2.3