From af73e3cb15c966129221009f1de35dea8de6578e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 7 Dec 2012 06:02:43 +0000 Subject: Revert "Invert precedence of content in ActionDispatch::Static" This reverts commit c59734f756b79c39486c45273d2cc5d42cd0c864. --- actionpack/CHANGELOG.md | 7 ------- actionpack/lib/action_dispatch/middleware/static.rb | 18 +++++++----------- actionpack/test/dispatch/static_test.rb | 15 +++++---------- 3 files changed, 12 insertions(+), 28 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 43880f2412..b57408ede3 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,11 +1,4 @@ ## Rails 4.0.0 (unreleased) ## - -* Invert precedence in `ActionDispatch::Static` so that dynamic content is preferred. - This prevents precompiled assets inadvertently being included twice when running - in development mode. Fixes #6421 - - *Andrew White* - * Add :if / :unless conditions to fragment cache: <%= cache @model, if: some_condition(@model) do %> diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 65670b0ff1..e3b15b43b9 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -51,20 +51,16 @@ module ActionDispatch end def call(env) - path = env['PATH_INFO'].chomp('/') - response = @app.call(env) - - if response[1]['X-Cascade'] == 'pass' - case env['REQUEST_METHOD'] - when 'GET', 'HEAD' - if match = @file_handler.match?(path) - env["PATH_INFO"] = match - return @file_handler.call(env) - end + case env['REQUEST_METHOD'] + when 'GET', 'HEAD' + path = env['PATH_INFO'].chomp('/') + if match = @file_handler.match?(path) + env["PATH_INFO"] = match + return @file_handler.call(env) end end - response + @app.call(env) end end end diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index f90be450e2..112f470786 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -4,19 +4,11 @@ require 'rbconfig' module StaticTests def test_serves_dynamic_content - dummy_app = lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] } - @app = ActionDispatch::Static.new(dummy_app, "#{FIXTURE_LOAD_PATH}/public", "public, max-age=60") assert_equal "Hello, World!", get("/nofile").body end - def test_dynamic_content_has_precedence_over_static_files - dummy_app = lambda { |env| [200, {"Content-Type" => "text/html"}, ["/foo/baz.html"]] } - @app = ActionDispatch::Static.new(dummy_app, "#{FIXTURE_LOAD_PATH}/public", "public, max-age=60") - assert_html "/foo/baz.html", get("/foo/bar.html") - end - def test_handles_urls_with_bad_encoding - assert_equal "", get("/doorkeeper%E3E4").body + assert_equal "Hello, World!", get("/doorkeeper%E3E4").body end def test_sets_cache_control @@ -48,6 +40,7 @@ module StaticTests assert_html "means hello in Japanese\n", get("/foo/#{Rack::Utils.escape("こんにちは.html")}") end + def test_serves_static_file_with_exclamation_mark_in_filename with_static_file "/foo/foo!bar.html" do |file| assert_html file, get("/foo/foo%21bar.html") @@ -149,7 +142,9 @@ module StaticTests end class StaticTest < ActiveSupport::TestCase - DummyApp = lambda { |env| [404, {"X-Cascade" => "pass"}, []] } + DummyApp = lambda { |env| + [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] + } App = ActionDispatch::Static.new(DummyApp, "#{FIXTURE_LOAD_PATH}/public", "public, max-age=60") def setup -- cgit v1.2.3