aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile3
-rw-r--r--actionpack/actionpack.gemspec2
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/static.rb8
-rw-r--r--actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb6
-rw-r--r--actionpack/lib/action_view/helpers/asset_paths.rb1
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb3
-rw-r--r--actionpack/lib/action_view/helpers/sprockets_helper.rb6
-rw-r--r--actionpack/test/dispatch/show_exceptions_test.rb7
-rw-r--r--actionpack/test/dispatch/static_test.rb8
-rw-r--r--railties/lib/rails/application.rb2
-rw-r--r--railties/lib/rails/application/configuration.rb3
-rw-r--r--railties/lib/rails/generators/app_base.rb6
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt6
14 files changed, 38 insertions, 25 deletions
diff --git a/Gemfile b/Gemfile
index 6cbc1bbebc..4d317ba1dc 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,10 +8,9 @@ else
gem "arel", '~> 2.1.0'
end
-gem "rack", :git => "git://github.com/rack/rack.git"
gem "rack-test", :git => "git://github.com/brynary/rack-test.git"
-
gem "sprockets", :git => "git://github.com/sstephenson/sprockets.git"
+
gem "coffee-script"
gem "sass"
gem "uglifier"
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index d85f077e0f..2385ac611f 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency('rack-cache', '~> 1.0.0')
s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.6.0beta1')
- s.add_dependency('rack', '~> 1.3.0')
+ s.add_dependency('rack', '~> 1.3.0.beta')
s.add_dependency('rack-test', '~> 0.5.7')
s.add_dependency('rack-mount', '~> 0.7.2')
s.add_dependency('sprockets', '~> 2.0.0.beta.2')
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index b1adf3d2d1..c17c746096 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -116,7 +116,7 @@ module ActionDispatch
end
def render(status, body)
- [status, {'Content-Type' => 'text/html', 'Content-Length' => body.bytesize.to_s}, [body]]
+ [status, {'Content-Type' => "text/html; charset=#{Response.default_charset}", 'Content-Length' => body.bytesize.to_s}, [body]]
end
def public_path
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb
index 348f7b86b8..360c1209bb 100644
--- a/actionpack/lib/action_dispatch/middleware/static.rb
+++ b/actionpack/lib/action_dispatch/middleware/static.rb
@@ -2,10 +2,10 @@ require 'rack/utils'
module ActionDispatch
class FileHandler
- def initialize(root)
+ def initialize(root, cache_control)
@root = root.chomp('/')
@compiled_root = /^#{Regexp.escape(root)}/
- @file_server = ::Rack::File.new(@root)
+ @file_server = ::Rack::File.new(@root, cache_control)
end
def match?(path)
@@ -37,9 +37,9 @@ module ActionDispatch
class Static
FILE_METHODS = %w(GET HEAD).freeze
- def initialize(app, path)
+ def initialize(app, path, cache_control=nil)
@app = app
- @file_handler = FileHandler.new(path)
+ @file_handler = FileHandler.new(path, cache_control)
end
def call(env)
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
index 6c32fb17b8..6e71fd7ddc 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
+++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
@@ -1,11 +1,13 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
+<!DOCTYPE html>
+<html lang="en">
<head>
+ <meta charset="utf-8" />
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
- font-family: verdana, arial, helvetica, sans-serif;
+ font-family: helvetica, verdana, arial, sans-serif;
font-size: 13px;
line-height: 18px;
}
diff --git a/actionpack/lib/action_view/helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_paths.rb
index cb6737b94e..958f0e0a10 100644
--- a/actionpack/lib/action_view/helpers/asset_paths.rb
+++ b/actionpack/lib/action_view/helpers/asset_paths.rb
@@ -21,7 +21,6 @@ module ActionView
return source if is_uri?(source)
source = rewrite_extension(source, dir, ext) if ext
- source = "/#{dir}/#{source}" unless source[0] == ?/
source = rewrite_asset_path(source, dir)
if controller && include_host
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
index 38860431b4..cd0f8c8878 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -41,7 +41,8 @@ module ActionView
# Break out the asset path rewrite in case plugins wish to put the asset id
# someplace other than the query string.
- def rewrite_asset_path(source, path = nil)
+ def rewrite_asset_path(source, dir)
+ source = "/#{dir}/#{source}" unless source[0] == ?/
path = config.asset_path
if path && path.respond_to?(:call)
diff --git a/actionpack/lib/action_view/helpers/sprockets_helper.rb b/actionpack/lib/action_view/helpers/sprockets_helper.rb
index b43b91178c..ab98da9624 100644
--- a/actionpack/lib/action_view/helpers/sprockets_helper.rb
+++ b/actionpack/lib/action_view/helpers/sprockets_helper.rb
@@ -40,10 +40,10 @@ module ActionView
class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc:
def rewrite_asset_path(source, dir)
- if source =~ /^\/#{dir}\/(.+)/
- assets.path($1, performing_caching?, dir)
- else
+ if source[0] == ?/
source
+ else
+ assets.path(source, performing_caching?, dir)
end
end
diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb
index e453dd11ce..cc57a6cba0 100644
--- a/actionpack/test/dispatch/show_exceptions_test.rb
+++ b/actionpack/test/dispatch/show_exceptions_test.rb
@@ -137,4 +137,11 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
assert_response 500
assert_match(/RuntimeError\n in FeaturedTilesController/, body)
end
+
+ test "sets the HTTP charset parameter" do
+ @app = DevelopmentApp
+
+ get "/", {}, {'action_dispatch.show_exceptions' => true}
+ assert_equal "text/html; charset=utf-8", response.headers["Content-Type"]
+ end
end
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb
index 2ebbed4414..9f3cbd19ef 100644
--- a/actionpack/test/dispatch/static_test.rb
+++ b/actionpack/test/dispatch/static_test.rb
@@ -5,6 +5,12 @@ module StaticTests
assert_equal "Hello, World!", get("/nofile").body
end
+ def test_sets_cache_control
+ response = get("/index.html")
+ assert_html "/index.html", response
+ assert_equal "public, max-age=60", response.headers["Cache-Control"]
+ end
+
def test_serves_static_index_at_root
assert_html "/index.html", get("/index.html")
assert_html "/index.html", get("/index")
@@ -40,7 +46,7 @@ class StaticTest < ActiveSupport::TestCase
DummyApp = lambda { |env|
[200, {"Content-Type" => "text/plain"}, ["Hello, World!"]]
}
- App = ActionDispatch::Static.new(DummyApp, "#{FIXTURE_LOAD_PATH}/public")
+ App = ActionDispatch::Static.new(DummyApp, "#{FIXTURE_LOAD_PATH}/public", "public, max-age=60")
def setup
@app = App
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 0c3c7737ea..4e82761e5d 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -152,7 +152,7 @@ module Rails
end
if config.serve_static_assets
- middleware.use ::ActionDispatch::Static, paths["public"].first
+ middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
end
middleware.use ::Rack::Lock unless config.allow_concurrency
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index f818313955..29b9c27a13 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -9,7 +9,7 @@ module Rails
:dependency_loading, :encoding, :filter_parameters,
:force_ssl, :helpers_paths, :logger, :preload_frameworks,
:reload_plugins, :secret_token, :serve_static_assets,
- :session_options, :time_zone, :whiny_nils
+ :static_cache_control, :session_options, :time_zone, :whiny_nils
attr_writer :log_level
@@ -22,6 +22,7 @@ module Rails
@helpers_paths = []
@dependency_loading = true
@serve_static_assets = true
+ @static_cache_control = nil
@force_ssl = false
@session_store = :cookie_store
@session_options = {}
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 689ef921e1..b5110fa9b7 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -130,14 +130,10 @@ module Rails
if options.dev?
<<-GEMFILE.strip_heredoc
gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}'
- gem 'arel', :git => 'git://github.com/rails/arel.git'
- gem 'rack', :git => 'git://github.com/rack/rack.git'
GEMFILE
elsif options.edge?
<<-GEMFILE.strip_heredoc
gem 'rails', :git => 'git://github.com/rails/rails.git'
- gem 'arel', :git => 'git://github.com/rails/arel.git'
- gem 'rack', :git => 'git://github.com/rack/rack.git'
GEMFILE
else
<<-GEMFILE.strip_heredoc
@@ -145,8 +141,6 @@ module Rails
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
- # gem 'arel', :git => 'git://github.com/rails/arel.git'
- # gem 'rack', :git => 'git://github.com/rack/rack.git'
GEMFILE
end
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
index d8d1e55157..8d11377211 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -7,7 +7,11 @@
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
- # Log error messages when you accidentally call methods on nil.
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching