1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Removed ActionDispatch::Static, but left empty MiddlewareStack to unify app method between Engine and Application

This commit is contained in:
Piotr Sarnacki 2010-07-08 12:07:25 +02:00
parent 7d7263bf9d
commit 3939d6bb51
6 changed files with 10 additions and 45 deletions

View file

@ -147,12 +147,6 @@ module Rails
self
end
def app
@app ||= begin
config.middleware = config.middleware.merge_into(default_middleware_stack)
config.middleware.build(routes)
end
end
alias :build_middleware_stack :app
def call(env)

View file

@ -11,7 +11,7 @@ module Rails
:encoding, :consider_all_requests_local, :dependency_loading,
:filter_parameters, :log_level, :logger,
:preload_frameworks, :reload_plugins,
:secret_token, :session_options,
:secret_token, :serve_static_assets, :session_options,
:time_zone, :whiny_nils
def initialize(*)

View file

@ -124,6 +124,11 @@ module Rails
Pathname.new(root).expand_path : Pathname.new(root).realpath
end
def endpoint(endpoint = nil)
@endpoint = endpoint if endpoint
@endpoint
end
protected
def method_missing(*args, &block)
@ -162,12 +167,6 @@ module Rails
self.class.endpoint || routes
end
def default_middleware_stack
ActionDispatch::MiddlewareStack.new.tap do |middleware|
middleware.use ::ActionDispatch::Static, paths.public.to_a.first if config.serve_static_assets
end
end
def call(env)
app.call(env)
end
@ -251,6 +250,9 @@ module Rails
end
protected
def default_middleware_stack
ActionDispatch::MiddlewareStack.new
end
def _all_autoload_paths
@_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq

View file

@ -21,11 +21,6 @@ module Rails
def instance
@instance ||= new
end
def endpoint(endpoint = nil)
@endpoint = endpoint if endpoint
@endpoint
end
end
def config

View file

@ -5,12 +5,11 @@ module Rails
class Configuration < ::Rails::Railtie::Configuration
attr_reader :root
attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths
attr_accessor :middleware, :plugins, :serve_static_assets
attr_accessor :middleware, :plugins
def initialize(root=nil)
super()
@root = root
@serve_static_assets = true
@middleware = Rails::Configuration::MiddlewareStackProxy.new
end

View file

@ -126,30 +126,5 @@ module RailtiesTest
assert Bukkits::Engine.config.yaffle_loaded
end
test "engine can serve files" do
@plugin.write "lib/bukkits.rb", <<-RUBY
class Bukkits
class Engine < ::Rails::Engine
config.serve_static_assets = true
end
end
RUBY
@plugin.write "public/omg.txt", <<-RUBY
OMG
RUBY
boot_rails
Rails::Application.routes.draw do |map|
mount(Bukkits::Engine => "/bukkits")
end
env = Rack::MockRequest.env_for("/bukkits/omg.txt")
response = Rails::Application.call(env)
assert_equal response[2].path, File.join(@plugin.path, "public/omg.txt")
end
end
end