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

Upgraded rack

As Rack has some non backwards compatible changes added required
modifications to keep behaviour in rails close to same as before.

Also modified generators to include rack/rack for not yet released
version of rack
This commit is contained in:
Jarmo Isotalo 2014-02-08 15:30:14 -08:00
parent d29074af7a
commit adffea62b5
6 changed files with 32 additions and 13 deletions

View file

@ -7,6 +7,7 @@ gemspec
# ensure correct loading order
gem 'mocha', '~> 0.14', require: false
gem 'rack', github: 'rack/rack'
gem 'rack-cache', '~> 1.2'
gem 'jquery-rails', '~> 3.1.0'
gem 'turbolinks'

View file

@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activesupport', version
s.add_dependency 'rack', '~> 1.5.2'
s.add_dependency 'rack', '~> 1.6.0.alpha'
s.add_dependency 'rack-test', '~> 0.6.2'
s.add_dependency 'actionview', version

View file

@ -54,8 +54,14 @@ module ActionDispatch
end
def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
@env["action_dispatch.request.formats"] ||= begin
params_readable = begin
parameters[:format]
rescue ActionController::BadRequest
false
end
if params_readable
Array(Mime[parameters[:format]])
elsif use_accept_header && valid_accept_header
accepts
@ -64,8 +70,8 @@ module ActionDispatch
else
[Mime::HTML]
end
end
end
# Sets the \variant for template.
def variant=(variant)
if variant.is_a?(Symbol)

View file

@ -8,7 +8,11 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest
end
def parse
self.class.last_request_parameters = request.request_parameters
self.class.last_request_parameters = begin
request.request_parameters
rescue EOFError
{}
end
self.class.last_parameters = request.parameters
head :ok
end

View file

@ -798,6 +798,12 @@ class RequestFormat < BaseRequestTest
assert_not request.format.json?
end
test "format does not throw exceptions when malformed parameters" do
request = stub_request("QUERY_STRING" => "x[y]=1&x[y][][w]=2")
assert request.formats
assert request.format.html?
end
test "formats with xhr request" do
request = stub_request 'HTTP_X_REQUESTED_WITH' => "XMLHttpRequest"
request.expects(:parameters).at_least_once.returns({})
@ -892,15 +898,15 @@ class RequestParameters < BaseRequestTest
assert_equal({"bar" => 2}, request.query_parameters)
end
test "parameters still accessible after rack parse error" do
test "parameters not accessible after rack parse error" do
request = stub_request("QUERY_STRING" => "x[y]=1&x[y][][w]=2")
assert_raises(ActionController::BadRequest) do
# rack will raise a TypeError when parsing this query string
request.parameters
2.times do
assert_raises(ActionController::BadRequest) do
# rack will raise a TypeError when parsing this query string
request.parameters
end
end
assert_equal({}, request.parameters)
end
test "we have access to the original exception" do

View file

@ -200,10 +200,12 @@ module Rails
def rails_gemfile_entry
if options.dev?
[GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH),
GemfileEntry.github('arel', 'rails/arel')]
GemfileEntry.github('arel', 'rails/arel'),
GemfileEntry.github('rack', 'rack/rack')]
elsif options.edge?
[GemfileEntry.github('rails', 'rails/rails'),
GemfileEntry.github('arel', 'rails/arel')]
GemfileEntry.github('arel', 'rails/arel'),
GemfileEntry.github('rack', 'rack/rack')]
else
[GemfileEntry.version('rails',
Rails::VERSION::STRING,