Got all the railties tests to pass, rails must boot!
This commit is contained in:
parent
30baaac546
commit
9d398f4827
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user