Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Got all the railties tests to pass, rails must boot!

  • Loading branch information...
commit 9d398f48275a2740b0c7545da207ac2ebbe012ec 1 parent 30baaac
Yehuda Katz + Carl Lerche authored
View
28 railties/lib/initializer.rb
@@ -4,6 +4,8 @@
require 'rails/gem_dependency'
require 'rails/rack'
+RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
+
module Rails
class Configuration
attr_accessor :cache_classes, :load_paths, :eager_load_paths, :framework_paths,
@@ -13,11 +15,13 @@ class Configuration
:i18n, :gems
def initialize
+ set_root_path!
+
@framework_paths = []
@load_once_paths = []
@after_initialize_blocks = []
- @plugin_paths = []
@loaded_plugins = []
+ @plugin_paths = default_plugin_paths
@frameworks = default_frameworks
@plugin_loader = default_plugin_loader
@plugin_locators = default_plugin_locators
@@ -29,6 +33,24 @@ def after_initialize(&blk)
@after_initialize_blocks << blk if blk
end
+ def set_root_path!
+ raise 'RAILS_ROOT is not set' unless defined?(RAILS_ROOT)
+ raise 'RAILS_ROOT is not a directory' unless File.directory?(RAILS_ROOT)
+
+ self.root_path =
+ # Pathname is incompatible with Windows, but Windows doesn't have
+ # real symlinks so File.expand_path is safe.
+ if RUBY_PLATFORM =~ /(:?mswin|mingw)/
+ File.expand_path(RAILS_ROOT)
+
+ # Otherwise use Pathname#realpath which respects symlinks.
+ else
+ Pathname.new(RAILS_ROOT).realpath.to_s
+ end
+
+ RAILS_ROOT.replace self.root_path
+ end
+
def framework_paths
paths = %w(railties railties/lib activesupport/lib)
paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view)
@@ -54,6 +76,10 @@ def default_frameworks
[ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ]
end
+ def default_plugin_paths
+ ["#{root_path}/vendor/plugins"]
+ end
+
def default_plugin_loader
require 'rails/plugin/loader'
Plugin::Loader
View
3  railties/test/plugin_locator_test.rb
@@ -27,7 +27,8 @@ def setup
# We need to add our testing plugin directory to the plugin paths so
# the locator knows where to look for our plugins
@configuration.plugin_paths << plugin_fixture_root_path
- @initializer = Rails::Initializer.new(@configuration)
+ @initializer = Rails::Initializer.default
+ @initializer.config = @configuration
@locator = Rails::Plugin::FileSystemLocator.new(@initializer)
@valid_plugin_path = plugin_fixture_path('default/stubby')
@empty_plugin_path = plugin_fixture_path('default/empty')
View
3  railties/test/plugin_test.rb
@@ -2,7 +2,8 @@
class PluginTest < Test::Unit::TestCase
def setup
- @initializer = Rails::Initializer.new(Rails::Configuration.new)
+ @initializer = Rails::Initializer.default
+ @initializer.config = Rails::Configuration.new
@valid_plugin_path = plugin_fixture_path('default/stubby')
@empty_plugin_path = plugin_fixture_path('default/empty')
@gemlike_plugin_path = plugin_fixture_path('default/gemlike')
View
3  railties/test/rails_generator_test.rb
@@ -50,6 +50,9 @@ class RailsGeneratorTest < Test::Unit::TestCase
def setup
ActiveRecord::Base.pluralize_table_names = true
+ @initializer = Rails::Initializer.default
+ @initializer.config = Rails.configuration
+ @initializer.run(:set_root_path)
end
def test_sources
Please sign in to comment.
Something went wrong with that request. Please try again.