aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-04-29 08:39:44 +0200
committerJosé Valim <jose.valim@gmail.com>2010-04-29 08:39:52 +0200
commit1b816d502444ce2b3153d8c689d0057f1c257eee (patch)
tree4fb975de78c82295568b64bde76132084c8089ac /railties/test/application
parente33d304975f5b20b0ba819ab644a2a8f80ff3743 (diff)
downloadrails-1b816d502444ce2b3153d8c689d0057f1c257eee.tar.gz
rails-1b816d502444ce2b3153d8c689d0057f1c257eee.tar.bz2
rails-1b816d502444ce2b3153d8c689d0057f1c257eee.zip
The rake task :environment now loads config/environment.rb instead of initializing the application on its own. This fixes [#4492 state:resolved] and also avoids the application being initialized twice in some rake tasks.
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/middleware_test.rb1
-rw-r--r--railties/test/application/paths_test.rb5
-rw-r--r--railties/test/application/rake_test.rb14
3 files changed, 18 insertions, 2 deletions
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 27374dcb28..e9cddcc65a 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -20,6 +20,7 @@ module ApplicationTests
assert_equal [
"ActionDispatch::Static",
"Rack::Lock",
+ "ActiveSupport::Cache::Strategy::LocalCache",
"Rack::Runtime",
"Rails::Rack::Logger",
"ActionDispatch::ShowExceptions",
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb
index 5ab558c026..978d677efc 100644
--- a/railties/test/application/paths_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -48,7 +48,8 @@ module ApplicationTests
assert_path @paths.tmp.cache, "tmp", "cache"
assert_path @paths.config, "config"
assert_path @paths.config.locales, "config", "locales", "en.yml"
- assert_path @paths.config.environment, "config", "environments", "development.rb"
+ assert_path @paths.config.environment, "config", "environment.rb"
+ assert_path @paths.config.environments, "config", "environments", "development.rb"
assert_equal root("app", "controllers"), @paths.app.controllers.to_a.first
end
@@ -61,7 +62,7 @@ module ApplicationTests
end
test "environments has a glob equal to the current environment" do
- assert_equal "#{Rails.env}.rb", @paths.config.environment.glob
+ assert_equal "#{Rails.env}.rb", @paths.config.environments.glob
end
test "load path includes each of the paths in config.paths as long as the directories exist" do
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index bf2da866f4..6b7a471494 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -19,5 +19,19 @@ module ApplicationTests
::Rails.application.load_tasks
assert $task_loaded
end
+
+ def test_environment_is_required_in_rake_tasks
+ app_file "config/environment.rb", <<-RUBY
+ SuperMiddleware = Struct.new(:app)
+
+ Rails::Application.configure do
+ config.middleware.use SuperMiddleware
+ end
+
+ Rails::Application.initialize!
+ RUBY
+
+ assert_match "SuperMiddleware", Dir.chdir(app_path){ `rake middleware` }
+ end
end
end \ No newline at end of file