From ddedc9947366b16f359f9c77471769c390da58a1 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Wed, 25 Apr 2012 22:37:32 -0700 Subject: [PATCH] Fix I18n tests by clearing out locale paths from other test runs --- .../lib/middleman-core/core_extensions/default_helpers.rb | 4 ---- middleman-core/lib/middleman-core/core_extensions/i18n.rb | 7 ++++++- .../padrino-core-0.10.6/lib/padrino-core/support_lite.rb | 2 +- .../vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index d0fc690f..4fe4d47e 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -17,10 +17,6 @@ module Middleman::CoreExtensions::DefaultHelpers # app.helpers ::Padrino::Helpers::TranslationHelpers app.helpers Helpers - - app.ready do - ::I18n.load_path += Dir["#{File.dirname(__FILE__)}/../vendor/padrino-helpers-0.10.6/lib/padrino-helpers/locale/*.yml"] - end end alias :included :registered end diff --git a/middleman-core/lib/middleman-core/core_extensions/i18n.rb b/middleman-core/lib/middleman-core/core_extensions/i18n.rb index 0f34f99a..ff059069 100644 --- a/middleman-core/lib/middleman-core/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-core/core_extensions/i18n.rb @@ -12,7 +12,12 @@ module Middleman::CoreExtensions::I18n # Needed for helpers as well app.after_configuration do - ::I18n.load_path += [Dir[File.join(root, locales_dir, "*.yml")]] + # This is for making the tests work - since the tests + # don't completely reload middleman, I18n.load_path can get + # polluted with paths from other test app directories that don't + # exist anymore. + ::I18n.load_path.delete_if {|path| path =~ %r{tmp/aruba}} + ::I18n.load_path += Dir[File.join(root, locales_dir, "*.yml")] ::I18n.reload! end end diff --git a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb index fd23c159..27305134 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite.rb @@ -191,7 +191,7 @@ end ## # Loads our locale configuration files # -### I18n.load_path += Dir["#{File.dirname(__FILE__)}/locale/*.yml"] if defined?(I18n) ### !!! FIXME middleman ### +I18n.load_path += Dir["#{File.dirname(__FILE__)}/locale/*.yml"] if defined?(I18n) ## # Used to determine if this file has already been required diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb index 97b45f90..202b848e 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.6/lib/padrino-helpers.rb @@ -1,7 +1,7 @@ require 'middleman-core/vendor/padrino-core-0.10.6/lib/padrino-core/support_lite' unless defined?(SupportLite) ### !!! FIXME middleman ### ### require 'padrino-core/support_lite' unless defined?(SupportLite) ### !!! FIXME middleman ### require 'cgi' -### require 'i18n' ### !!! FIXME middleman ### +require 'i18n' require 'enumerator' require 'active_support/core_ext/string/conversions' # to_date require 'active_support/core_ext/float/rounding' # round @@ -12,7 +12,7 @@ require 'active_support/inflector' # humanize FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__) # Load our locales -### I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-helpers/locale/*.yml"] ### !!! FIXME middleman ### +I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-helpers/locale/*.yml"] module Padrino ##