mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ensure initialize_database_middleware doesn't use ActionController if action_controller framework is not enabled [#2680 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
6ef329d325
commit
0d9e904da3
2 changed files with 23 additions and 6 deletions
|
@ -445,7 +445,8 @@ Run `rake gems:install` to install the missing gems.
|
|||
|
||||
def initialize_database_middleware
|
||||
if configuration.frameworks.include?(:active_record)
|
||||
if ActionController::Base.session_store == ActiveRecord::SessionStore
|
||||
if configuration.frameworks.include?(:action_controller) &&
|
||||
ActionController::Base.session_store == ActiveRecord::SessionStore
|
||||
configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement
|
||||
configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::QueryCache
|
||||
else
|
||||
|
@ -886,7 +887,7 @@ Run `rake gems:install` to install the missing gems.
|
|||
|
||||
# Enable threaded mode. Allows concurrent requests to controller actions and
|
||||
# multiple database connections. Also disables automatic dependency loading
|
||||
# after boot, and disables reloading code on every request, as these are
|
||||
# after boot, and disables reloading code on every request, as these are
|
||||
# fundamentally incompatible with thread safety.
|
||||
def threadsafe!
|
||||
self.preload_frameworks = true
|
||||
|
@ -1129,3 +1130,4 @@ class Rails::OrderedOptions < Array #:nodoc:
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ class InitializerSetupI18nTests < Test::Unit::TestCase
|
|||
config.i18n.load_path << "my/other/locale.yml"
|
||||
|
||||
Rails::Initializer.run(:initialize_i18n, config)
|
||||
assert_equal [
|
||||
assert_equal [
|
||||
File.expand_path(File.dirname(__FILE__) + "/../../activesupport/lib/active_support/locale/en.yml"),
|
||||
File.expand_path(File.dirname(__FILE__) + "/../../actionpack/lib/action_view/locale/en.yml"),
|
||||
File.expand_path(File.dirname(__FILE__) + "/../../activerecord/lib/active_record/locale/en.yml"),
|
||||
|
@ -363,17 +363,31 @@ class InitializerDatabaseMiddlewareTest < Test::Unit::TestCase
|
|||
ensure
|
||||
ActionController::Base.session_store = store
|
||||
end
|
||||
|
||||
def test_ensure_database_middleware_doesnt_use_action_controller_on_initializing
|
||||
@config.frameworks -= [:action_controller]
|
||||
store = ActionController::Base.session_store
|
||||
ActionController::Base.session_store = ActiveRecord::SessionStore
|
||||
|
||||
@config.middleware.expects(:use).with(ActiveRecord::ConnectionAdapters::ConnectionManagement)
|
||||
@config.middleware.expects(:use).with(ActiveRecord::QueryCache)
|
||||
|
||||
Rails::Initializer.run(:initialize_database_middleware, @config)
|
||||
ensure
|
||||
ActionController::Base.session_store = store
|
||||
@config.frameworks += [:action_controller]
|
||||
end
|
||||
end
|
||||
|
||||
class InitializerViewPathsTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@config = Rails::Configuration.new
|
||||
@config.frameworks = [:action_view, :action_controller, :action_mailer]
|
||||
|
||||
|
||||
ActionController::Base.stubs(:view_paths).returns(stub)
|
||||
ActionMailer::Base.stubs(:view_paths).returns(stub)
|
||||
end
|
||||
|
||||
|
||||
def test_load_view_paths_doesnt_perform_anything_when_action_view_not_in_frameworks
|
||||
@config.frameworks -= [:action_view]
|
||||
ActionController::Base.view_paths.expects(:load!).never
|
||||
|
@ -390,4 +404,5 @@ class RailsRootTest < Test::Unit::TestCase
|
|||
def test_rails_dot_root_should_be_a_pathname
|
||||
assert_equal File.join(RAILS_ROOT, 'app', 'controllers'), Rails.root.join('app', 'controllers').to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue