diff options
Diffstat (limited to 'actionpack/lib/action_dispatch')
6 files changed, 35 insertions, 29 deletions
diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index 0528a6ad08..3c03976f03 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -115,8 +115,8 @@ module ActionDispatch private - # Converts an HTTP header name to an environment variable name if it is - # not contained within the headers hash. + # Converts an HTTP header name to an environment variable name if it is + # not contained within the headers hash. def env_name(key) key = key.to_s if key =~ HTTP_HEADER diff --git a/actionpack/lib/action_dispatch/journey/parser.rb b/actionpack/lib/action_dispatch/journey/parser.rb index 7ec9d63859..01ff2109cb 100644 --- a/actionpack/lib/action_dispatch/journey/parser.rb +++ b/actionpack/lib/action_dispatch/journey/parser.rb @@ -10,7 +10,7 @@ require "action_dispatch/journey/parser_extras" module ActionDispatch module Journey class Parser < Racc::Parser -##### State transition tables begin ### + ##### State transition tables begin ### racc_action_table = [ 13, 15, 14, 7, 21, 16, 8, 19, 13, 15, @@ -128,9 +128,9 @@ module ActionDispatch Racc_debug_parser = false -##### State transition tables end ##### + ##### State transition tables end ##### -# reduce 0 omitted + # reduce 0 omitted def _reduce_1(val, _values) Cat.new(val.first, val.last) @@ -140,13 +140,13 @@ module ActionDispatch val.first end -# reduce 3 omitted + # reduce 3 omitted -# reduce 4 omitted + # reduce 4 omitted -# reduce 5 omitted + # reduce 5 omitted -# reduce 6 omitted + # reduce 6 omitted def _reduce_7(val, _values) Group.new(val[1]) @@ -164,13 +164,13 @@ module ActionDispatch Star.new(Symbol.new(val.last)) end -# reduce 11 omitted + # reduce 11 omitted -# reduce 12 omitted + # reduce 12 omitted -# reduce 13 omitted + # reduce 13 omitted -# reduce 14 omitted + # reduce 14 omitted def _reduce_15(val, _values) Slash.new("/") diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8d0bf680c8..5abf59402d 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -264,19 +264,19 @@ module ActionDispatch end private - # Create a url helper allowing ordered parameters to be associated - # with corresponding dynamic segments, so you can do: - # - # foo_url(bar, baz, bang) - # - # Instead of: - # - # foo_url(bar: bar, baz: baz, bang: bang) - # - # Also allow options hash, so you can do: - # - # foo_url(bar, baz, bang, sort_by: 'baz') - # + # Create a url helper allowing ordered parameters to be associated + # with corresponding dynamic segments, so you can do: + # + # foo_url(bar, baz, bang) + # + # Instead of: + # + # foo_url(bar: bar, baz: baz, bang: bang) + # + # Also allow options hash, so you can do: + # + # foo_url(bar, baz, bang, sort_by: 'baz') + # def define_url_helper(mod, route, name, opts, route_key, url_strategy) helper = UrlHelper.create(route, opts, route_key, url_strategy) mod.module_eval do diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index a00602ed70..a2eaccd9ef 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -79,7 +79,12 @@ module ActionDispatch def generate_response_message(expected, actual = @response.response_code) "Expected response to be a <#{code_with_name(expected)}>,"\ " but was a <#{code_with_name(actual)}>" - .concat location_if_redirected + .concat(location_if_redirected).concat(response_body_if_short) + end + + def response_body_if_short + return "" if @response.body.size > 500 + "\nResponse body: #{@response.body}" end def location_if_redirected diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 1456a0afcf..8b03b776fa 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -34,7 +34,8 @@ module ActionDispatch # # post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) def fixture_file_upload(path, mime_type = nil, binary = false) - if self.class.respond_to?(:fixture_path) && self.class.fixture_path + if self.class.respond_to?(:fixture_path) && self.class.fixture_path && + !File.exist?(path) path = File.join(self.class.fixture_path, path) end Rack::Test::UploadedFile.new(path, mime_type, binary) diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index d0beb72a41..91b25ec155 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -22,7 +22,7 @@ module ActionDispatch private_class_method :default_env def request_method=(method) - set_header("REQUEST_METHOD", method.to_s.upcase) + super(method.to_s.upcase) end def host=(host) |