Permalink
Browse files

Use Rails.initialize! where we just want to run the initializers and …

…aren't concerned about the config
  • Loading branch information...
1 parent 92bfc69 commit d8594026962704b6b51e188a29406fbd22bb31ce @josh josh committed Oct 16, 2009
@@ -3,6 +3,11 @@ class Application
extend Initializable
class << self
+ # Stub out App initialize
+ def initialize!
+ new
+ end
+
def config
@config ||= Configuration.new
end
@@ -1,3 +1,3 @@
-Rails.application.new
+Rails.initialize!
require 'rails/info'
puts Rails::Info
@@ -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
@@ -12,7 +12,7 @@
require 'benchmark'
include Benchmark
-Rails.application.new
+Rails.initialize!
# Don't include compilation in the benchmark
ARGV.each { |expression| eval(expression) }
@@ -5,7 +5,7 @@
# 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
@@ -36,7 +36,7 @@
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?
@@ -18,6 +18,10 @@ def configuration
application.configuration
end
+ def initialize!
+ application.initialize!
+ end
+
def initialized?
@initialized || false
end
@@ -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!
@@ -43,7 +43,7 @@ def setup
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 @@ def setup
c.generators.colorize_logging = false
end
# Initialize the application
- Rails.application.new
+ Rails.initialize!
assert_equal Thor::Base.shell, Thor::Shell::Basic
end
@@ -16,11 +16,11 @@ def setup
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 @@ def setup
config.root = app_path
end
- Rails.application.new
+ Rails.initialize!
assert $:.include?("#{app_path}/app/models")
end
@@ -41,7 +41,7 @@ def setup
end
assert_raises RuntimeError do
- Rails.application.new
+ Rails.initialize!
end
end
@@ -58,7 +58,7 @@ module Zoo::ReptileHouse ; end
config.eager_load_paths = "#{app_path}/lib"
end
- Rails.application.new
+ Rails.initialize!
assert Zoo
end
@@ -67,7 +67,7 @@ module Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
config.root = app_path
config.frameworks = []
end
- Rails.application.new
+ Rails.initialize!
end
end
@@ -86,7 +86,7 @@ module Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
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 Zoo::ReptileHouse ; end
Rails::Initializer.run do |c|
c.root = app_path
end
- Rails.application.new
+ Rails.initialize!
assert_instance_of Pathname, Rails.root
end
end
@@ -18,7 +18,7 @@ def setup
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 @@ def setup
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 @@ def setup
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 @@ def setup
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 @@ def setup
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 @@ def setup
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 @@ def setup
end
assert_raise(LoadError) do
- Rails.application.new
+ Rails.initialize!
end
end
@@ -97,7 +97,7 @@ def setup
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
@@ -42,7 +42,7 @@ def assert_rails_boots(version)
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 @@ def assert_rails_does_not_boot(version)
$stderr = File.open("/dev/null", "w")
assert_raises(SystemExit) do
Rails::Initializer.run { |c| c.frameworks = [] }
- Rails.application.new
+ Rails.initialize!
end
end
end
@@ -15,7 +15,7 @@ def setup
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 @@ def setup
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(
@@ -13,7 +13,7 @@ def setup
ActionController::Base.session_store = nil
end
end
- Rails.application.new
+ Rails.initialize!
@paths = Rails.application.config.paths
end

0 comments on commit d859402

Please sign in to comment.