aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-16 18:58:35 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-16 18:58:35 -0500
commitd8594026962704b6b51e188a29406fbd22bb31ce (patch)
tree60e24269b4cabaebfcf21a6c9c7b5da0f05f1f29 /railties
parent92bfc693f2293fe5d459a6edb4216594cd5a7eb2 (diff)
downloadrails-d8594026962704b6b51e188a29406fbd22bb31ce.tar.gz
rails-d8594026962704b6b51e188a29406fbd22bb31ce.tar.bz2
rails-d8594026962704b6b51e188a29406fbd22bb31ce.zip
Use Rails.initialize! where we just want to run the initializers and aren't concerned about the config
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application.rb5
-rw-r--r--railties/lib/rails/commands/about.rb2
-rwxr-xr-xrailties/lib/rails/commands/generate.rb2
-rw-r--r--railties/lib/rails/commands/performance/benchmarker.rb2
-rw-r--r--railties/lib/rails/commands/performance/profiler.rb2
-rw-r--r--railties/lib/rails/commands/runner.rb2
-rw-r--r--railties/lib/rails/core.rb4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environment.rb2
-rw-r--r--railties/test/application/generators_test.rb4
-rw-r--r--railties/test/application/initializer_test.rb34
-rw-r--r--railties/test/application/plugins_test.rb18
-rw-r--r--railties/test/initializer/check_ruby_version_test.rb4
-rw-r--r--railties/test/initializer/initialize_i18n_test.rb4
-rw-r--r--railties/test/initializer/path_test.rb2
14 files changed, 48 insertions, 39 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index fe2dc3769e..621f1c3878 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -3,6 +3,11 @@ module Rails
extend Initializable
class << self
+ # Stub out App initialize
+ def initialize!
+ new
+ end
+
def config
@config ||= Configuration.new
end
diff --git a/railties/lib/rails/commands/about.rb b/railties/lib/rails/commands/about.rb
index 54c12a266f..6fdbc08027 100644
--- a/railties/lib/rails/commands/about.rb
+++ b/railties/lib/rails/commands/about.rb
@@ -1,3 +1,3 @@
-Rails.application.new
+Rails.initialize!
require 'rails/info'
puts Rails::Info
diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb
index cfa6a51d94..22aefa803a 100755
--- a/railties/lib/rails/commands/generate.rb
+++ b/railties/lib/rails/commands/generate.rb
@@ -1,5 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators'))
-Rails.application.new
+Rails.initialize!
if ARGV.size == 0
Rails::Generators.help
diff --git a/railties/lib/rails/commands/performance/benchmarker.rb b/railties/lib/rails/commands/performance/benchmarker.rb
index 5039c5408c..5420b57311 100644
--- a/railties/lib/rails/commands/performance/benchmarker.rb
+++ b/railties/lib/rails/commands/performance/benchmarker.rb
@@ -12,7 +12,7 @@ end
require 'benchmark'
include Benchmark
-Rails.application.new
+Rails.initialize!
# Don't include compilation in the benchmark
ARGV.each { |expression| eval(expression) }
diff --git a/railties/lib/rails/commands/performance/profiler.rb b/railties/lib/rails/commands/performance/profiler.rb
index 7274e2dfb7..30346dc0e7 100644
--- a/railties/lib/rails/commands/performance/profiler.rb
+++ b/railties/lib/rails/commands/performance/profiler.rb
@@ -5,7 +5,7 @@ end
# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
-Rails.application.new # Initialize the application
+Rails.initialize! # Initialize the application
# Define a method to profile.
if ARGV[1] and ARGV[1].to_i > 1
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index d24f36dd63..84d72f9fa9 100644
--- a/railties/lib/rails/commands/runner.rb
+++ b/railties/lib/rails/commands/runner.rb
@@ -36,7 +36,7 @@ ARGV.delete(code_or_file)
ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
-Rails.application.new
+Rails.initialize!
begin
if code_or_file.nil?
diff --git a/railties/lib/rails/core.rb b/railties/lib/rails/core.rb
index e15661e2d7..6e7f912e6d 100644
--- a/railties/lib/rails/core.rb
+++ b/railties/lib/rails/core.rb
@@ -18,6 +18,10 @@ module Rails
application.configuration
end
+ def initialize!
+ application.initialize!
+ end
+
def initialized?
@initialized || false
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environment.rb b/railties/lib/rails/generators/rails/app/templates/config/environment.rb
index fcf4eddb00..3bb0f2619e 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environment.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/environment.rb
@@ -6,4 +6,4 @@
# Load the rails application
require File.expand_path(File.join(File.dirname(__FILE__), 'application'))
# Initialize the rails application
-Rails.application.new
+Rails.initialize!
diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb
index 25c82578a3..03fecffdd0 100644
--- a/railties/test/application/generators_test.rb
+++ b/railties/test/application/generators_test.rb
@@ -43,7 +43,7 @@ module ApplicationTests
c.generators.test_framework :rspec
end
# Initialize the application
- Rails.application.new
+ Rails.initialize!
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework]
@@ -55,7 +55,7 @@ module ApplicationTests
c.generators.colorize_logging = false
end
# Initialize the application
- Rails.application.new
+ Rails.initialize!
assert_equal Thor::Base.shell, Thor::Shell::Basic
end
diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb
index 805ff8b6be..c2e64374d0 100644
--- a/railties/test/application/initializer_test.rb
+++ b/railties/test/application/initializer_test.rb
@@ -16,11 +16,11 @@ module ApplicationTests
if RUBY_VERSION < '1.9'
$KCODE = ''
- Rails.application.new
+ Rails.initialize!
assert_equal 'UTF8', $KCODE
else
Encoding.default_external = Encoding::US_ASCII
- Rails.application.new
+ Rails.initialize!
assert_equal Encoding::UTF_8, Encoding.default_external
end
end
@@ -30,7 +30,7 @@ module ApplicationTests
config.root = app_path
end
- Rails.application.new
+ Rails.initialize!
assert $:.include?("#{app_path}/app/models")
end
@@ -41,7 +41,7 @@ module ApplicationTests
end
assert_raises RuntimeError do
- Rails.application.new
+ Rails.initialize!
end
end
@@ -58,7 +58,7 @@ module ApplicationTests
config.eager_load_paths = "#{app_path}/lib"
end
- Rails.application.new
+ Rails.initialize!
assert Zoo
end
@@ -67,7 +67,7 @@ module ApplicationTests
app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'"
assert_nil $initialize_test_set_from_env
Rails::Initializer.run { |config| config.root = app_path }
- Rails.application.new
+ Rails.initialize!
assert_equal "success", $initialize_test_set_from_env
end
@@ -77,7 +77,7 @@ module ApplicationTests
config.root = app_path
config.frameworks = []
end
- Rails.application.new
+ Rails.initialize!
end
end
@@ -86,7 +86,7 @@ module ApplicationTests
config.root = app_path
config.frameworks = [:action_controller]
end
- Rails.application.new
+ Rails.initialize!
assert $:.include?("#{framework_path}/actionpack/lib")
end
@@ -96,7 +96,7 @@ module ApplicationTests
config.root = app_path
config.frameworks = [:action_view]
end
- Rails.application.new
+ Rails.initialize!
assert $:.include?("#{framework_path}/actionpack/lib")
end
@@ -107,7 +107,7 @@ module ApplicationTests
config.after_initialize { $test_after_initialize_block1 = "success" }
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
end
- Rails.application.new
+ Rails.initialize!
assert_equal "success", $test_after_initialize_block1
assert_equal "congratulations", $test_after_initialize_block2
@@ -120,7 +120,7 @@ module ApplicationTests
config.after_initialize # don't pass a block, this is what we're testing!
config.after_initialize { $test_after_initialize_block2 = "congratulations" }
end
- Rails.application.new
+ Rails.initialize!
assert_equal "success", $test_after_initialize_block1
assert_equal "congratulations", $test_after_initialize_block2
@@ -132,7 +132,7 @@ module ApplicationTests
config.root = app_path
config.i18n.default_locale = :de
end
- Rails.application.new
+ Rails.initialize!
assert_equal :de, I18n.default_locale
end
@@ -169,7 +169,7 @@ module ApplicationTests
config.root = app_path
config.action_controller.session_store = :cookie_store
end
- Rails.application.new
+ Rails.initialize!
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
end
@@ -187,7 +187,7 @@ module ApplicationTests
c.root = app_path
c.action_controller.session_store = :active_record_store
end
- Rails.application.new
+ Rails.initialize!
expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
middleware = Rails.application.config.middleware.map { |m| m.klass }
@@ -200,7 +200,7 @@ module ApplicationTests
c.frameworks -= [:action_controller]
c.action_controller.session_store = :active_record_store
end
- Rails.application.new
+ Rails.initialize!
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
end
@@ -211,7 +211,7 @@ module ApplicationTests
c.root = app_path
c.frameworks -= [:action_view]
end
- Rails.application.new
+ Rails.initialize!
assert_equal nil, ActionMailer::Base.template_root
assert_equal [], ActionController::Base.view_paths
@@ -221,7 +221,7 @@ module ApplicationTests
Rails::Initializer.run do |c|
c.root = app_path
end
- Rails.application.new
+ Rails.initialize!
assert_instance_of Pathname, Rails.root
end
end
diff --git a/railties/test/application/plugins_test.rb b/railties/test/application/plugins_test.rb
index 6ea6d49460..0926ed106b 100644
--- a/railties/test/application/plugins_test.rb
+++ b/railties/test/application/plugins_test.rb
@@ -18,7 +18,7 @@ module ApplicationTests
test "all plugins are loaded when registered plugin list is untouched" do
Rails::Initializer.run { |c| c.root = app_path }
- Rails.application.new
+ Rails.initialize!
assert_plugins [
:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby
], Rails.application.config.loaded_plugins, @failure_tip
@@ -32,7 +32,7 @@ module ApplicationTests
test "only the specified plugins are located in the order listed" do
plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon]
Rails::Initializer.run { |c| c.root = app_path; c.plugins = plugin_names }
- Rails.application.new
+ Rails.initialize!
assert_plugins plugin_names, Rails.application.config.loaded_plugins
end
@@ -41,7 +41,7 @@ module ApplicationTests
config.root = app_path
config.plugins = [:stubby, :all, :acts_as_chunky_bacon]
end
- Rails.application.new
+ Rails.initialize!
assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], Rails.application.config.loaded_plugins, @failure_tip
end
@@ -51,7 +51,7 @@ module ApplicationTests
config.root = app_path
config.plugins = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
end
- Rails.application.new
+ Rails.initialize!
assert_plugins plugin_names, Rails.application.config.loaded_plugins, @failure_tip
end
@@ -61,8 +61,8 @@ module ApplicationTests
config.root = app_path
config.plugins = [:stubby, :acts_as_chunky_bacon, :all]
end
- Rails.application.new
-
+ Rails.initialize!
+
assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], Rails.application.config.loaded_plugins, @failure_tip
end
@@ -71,7 +71,7 @@ module ApplicationTests
config.root = app_path
config.plugins = [:stubby, :acts_as_chunky_bacon]
end
- Rails.application.new
+ Rails.initialize!
assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/stubby/lib")
assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/acts/acts_as_chunky_bacon/lib")
@@ -84,7 +84,7 @@ module ApplicationTests
end
assert_raise(LoadError) do
- Rails.application.new
+ Rails.initialize!
end
end
@@ -97,7 +97,7 @@ module ApplicationTests
config.root = app_path
config.plugins = [:stubby, :acts_as_chunky_bacon, :non_existant_plugin1, :non_existant_plugin2]
end
- Rails.application.new
+ Rails.initialize!
flunk "Expected a LoadError but did not get one"
rescue LoadError => e
assert_plugins valid_plugins, Rails.application.config.loaded_plugins, @failure_tip
diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb
index 6c32f5635b..0c725311ad 100644
--- a/railties/test/initializer/check_ruby_version_test.rb
+++ b/railties/test/initializer/check_ruby_version_test.rb
@@ -42,7 +42,7 @@ module InitializerTests
set_ruby_version(version)
assert_nothing_raised "It appears that rails does not boot" do
Rails::Initializer.run { |c| c.frameworks = [] }
- Rails.application.new
+ Rails.initialize!
end
end
@@ -51,7 +51,7 @@ module InitializerTests
$stderr = File.open("/dev/null", "w")
assert_raises(SystemExit) do
Rails::Initializer.run { |c| c.frameworks = [] }
- Rails.application.new
+ Rails.initialize!
end
end
end
diff --git a/railties/test/initializer/initialize_i18n_test.rb b/railties/test/initializer/initialize_i18n_test.rb
index 92ac1312bf..04b44cedd0 100644
--- a/railties/test/initializer/initialize_i18n_test.rb
+++ b/railties/test/initializer/initialize_i18n_test.rb
@@ -15,7 +15,7 @@ module InitializerTests
c.root = app_path
c.i18n.load_path << "my/other/locale.yml"
end
- Rails.application.new
+ Rails.initialize!
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal %W(
@@ -38,7 +38,7 @@ module InitializerTests
c.root = app_path
c.i18n.load_path << "my/other/locale.yml"
end
- Rails.application.new
+ Rails.initialize!
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal %W(
diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb
index 29acbdbd25..9c36bb2000 100644
--- a/railties/test/initializer/path_test.rb
+++ b/railties/test/initializer/path_test.rb
@@ -13,7 +13,7 @@ class PathsTest < Test::Unit::TestCase
ActionController::Base.session_store = nil
end
end
- Rails.application.new
+ Rails.initialize!
@paths = Rails.application.config.paths
end