actionpack 4.2.11.1 → 6.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +291 -489
- data/MIT-LICENSE +1 -1
- data/README.rdoc +9 -9
- data/lib/abstract_controller/asset_paths.rb +2 -0
- data/lib/abstract_controller/base.rb +81 -51
- data/lib/{action_controller → abstract_controller}/caching/fragments.rb +64 -17
- data/lib/abstract_controller/caching.rb +66 -0
- data/lib/abstract_controller/callbacks.rb +61 -33
- data/lib/abstract_controller/collector.rb +9 -13
- data/lib/abstract_controller/error.rb +6 -0
- data/lib/abstract_controller/helpers.rb +115 -99
- data/lib/abstract_controller/logger.rb +2 -0
- data/lib/abstract_controller/railties/routes_helpers.rb +21 -3
- data/lib/abstract_controller/rendering.rb +48 -47
- data/lib/abstract_controller/translation.rb +17 -8
- data/lib/abstract_controller/url_for.rb +2 -0
- data/lib/abstract_controller.rb +13 -5
- data/lib/action_controller/api/api_rendering.rb +16 -0
- data/lib/action_controller/api.rb +150 -0
- data/lib/action_controller/base.rb +29 -24
- data/lib/action_controller/caching.rb +12 -57
- data/lib/action_controller/form_builder.rb +50 -0
- data/lib/action_controller/log_subscriber.rb +17 -19
- data/lib/action_controller/metal/basic_implicit_render.rb +13 -0
- data/lib/action_controller/metal/conditional_get.rb +134 -46
- data/lib/action_controller/metal/content_security_policy.rb +51 -0
- data/lib/action_controller/metal/cookies.rb +6 -4
- data/lib/action_controller/metal/data_streaming.rb +30 -50
- data/lib/action_controller/metal/default_headers.rb +17 -0
- data/lib/action_controller/metal/etag_with_flash.rb +18 -0
- data/lib/action_controller/metal/etag_with_template_digest.rb +21 -16
- data/lib/action_controller/metal/exceptions.rb +63 -15
- data/lib/action_controller/metal/flash.rb +9 -8
- data/lib/action_controller/metal/head.rb +26 -21
- data/lib/action_controller/metal/helpers.rb +37 -18
- data/lib/action_controller/metal/http_authentication.rb +81 -73
- data/lib/action_controller/metal/implicit_render.rb +53 -9
- data/lib/action_controller/metal/instrumentation.rb +32 -35
- data/lib/action_controller/metal/live.rb +102 -120
- data/lib/action_controller/metal/logging.rb +20 -0
- data/lib/action_controller/metal/mime_responds.rb +49 -47
- data/lib/action_controller/metal/parameter_encoding.rb +82 -0
- data/lib/action_controller/metal/params_wrapper.rb +83 -66
- data/lib/action_controller/metal/permissions_policy.rb +46 -0
- data/lib/action_controller/metal/redirecting.rb +53 -32
- data/lib/action_controller/metal/renderers.rb +87 -44
- data/lib/action_controller/metal/rendering.rb +77 -50
- data/lib/action_controller/metal/request_forgery_protection.rb +267 -103
- data/lib/action_controller/metal/rescue.rb +10 -17
- data/lib/action_controller/metal/streaming.rb +12 -11
- data/lib/action_controller/metal/strong_parameters.rb +714 -186
- data/lib/action_controller/metal/testing.rb +2 -17
- data/lib/action_controller/metal/url_for.rb +19 -10
- data/lib/action_controller/metal.rb +104 -87
- data/lib/action_controller/railtie.rb +28 -10
- data/lib/action_controller/railties/helpers.rb +3 -1
- data/lib/action_controller/renderer.rb +141 -0
- data/lib/action_controller/template_assertions.rb +11 -0
- data/lib/action_controller/test_case.rb +296 -422
- data/lib/action_controller.rb +34 -23
- data/lib/action_dispatch/http/cache.rb +107 -56
- data/lib/action_dispatch/http/content_disposition.rb +45 -0
- data/lib/action_dispatch/http/content_security_policy.rb +286 -0
- data/lib/action_dispatch/http/filter_parameters.rb +32 -25
- data/lib/action_dispatch/http/filter_redirect.rb +10 -12
- data/lib/action_dispatch/http/headers.rb +55 -22
- data/lib/action_dispatch/http/mime_negotiation.rb +79 -51
- data/lib/action_dispatch/http/mime_type.rb +153 -121
- data/lib/action_dispatch/http/mime_types.rb +20 -6
- data/lib/action_dispatch/http/parameters.rb +90 -40
- data/lib/action_dispatch/http/permissions_policy.rb +173 -0
- data/lib/action_dispatch/http/rack_cache.rb +2 -0
- data/lib/action_dispatch/http/request.rb +226 -121
- data/lib/action_dispatch/http/response.rb +248 -113
- data/lib/action_dispatch/http/upload.rb +21 -7
- data/lib/action_dispatch/http/url.rb +182 -100
- data/lib/action_dispatch/journey/formatter.rb +90 -43
- data/lib/action_dispatch/journey/gtg/builder.rb +28 -41
- data/lib/action_dispatch/journey/gtg/simulator.rb +11 -16
- data/lib/action_dispatch/journey/gtg/transition_table.rb +23 -21
- data/lib/action_dispatch/journey/nfa/dot.rb +3 -14
- data/lib/action_dispatch/journey/nodes/node.rb +29 -15
- data/lib/action_dispatch/journey/parser.rb +17 -16
- data/lib/action_dispatch/journey/parser.y +4 -3
- data/lib/action_dispatch/journey/parser_extras.rb +12 -4
- data/lib/action_dispatch/journey/path/pattern.rb +58 -54
- data/lib/action_dispatch/journey/route.rb +100 -32
- data/lib/action_dispatch/journey/router/utils.rb +29 -18
- data/lib/action_dispatch/journey/router.rb +55 -51
- data/lib/action_dispatch/journey/routes.rb +17 -17
- data/lib/action_dispatch/journey/scanner.rb +26 -17
- data/lib/action_dispatch/journey/visitors.rb +98 -54
- data/lib/action_dispatch/journey.rb +5 -5
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +46 -0
- data/lib/action_dispatch/middleware/callbacks.rb +3 -6
- data/lib/action_dispatch/middleware/cookies.rb +347 -217
- data/lib/action_dispatch/middleware/debug_exceptions.rb +135 -63
- data/lib/action_dispatch/middleware/debug_locks.rb +124 -0
- data/lib/action_dispatch/middleware/debug_view.rb +66 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +115 -71
- data/lib/action_dispatch/middleware/executor.rb +21 -0
- data/lib/action_dispatch/middleware/flash.rb +78 -54
- data/lib/action_dispatch/middleware/host_authorization.rb +130 -0
- data/lib/action_dispatch/middleware/public_exceptions.rb +32 -27
- data/lib/action_dispatch/middleware/reloader.rb +5 -91
- data/lib/action_dispatch/middleware/remote_ip.rb +53 -45
- data/lib/action_dispatch/middleware/request_id.rb +17 -10
- data/lib/action_dispatch/middleware/session/abstract_store.rb +41 -26
- data/lib/action_dispatch/middleware/session/cache_store.rb +24 -14
- data/lib/action_dispatch/middleware/session/cookie_store.rb +74 -75
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +8 -2
- data/lib/action_dispatch/middleware/show_exceptions.rb +28 -23
- data/lib/action_dispatch/middleware/ssl.rb +118 -35
- data/lib/action_dispatch/middleware/stack.rb +82 -41
- data/lib/action_dispatch/middleware/static.rb +156 -89
- data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
- data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
- data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +22 -0
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +4 -14
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/{_source.erb → _source.html.erb} +4 -2
- data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +45 -35
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +23 -4
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +24 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +15 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +105 -8
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +87 -64
- data/lib/action_dispatch/railtie.rb +27 -13
- data/lib/action_dispatch/request/session.rb +109 -61
- data/lib/action_dispatch/request/utils.rb +90 -23
- data/lib/action_dispatch/routing/endpoint.rb +9 -2
- data/lib/action_dispatch/routing/inspector.rb +141 -102
- data/lib/action_dispatch/routing/mapper.rb +811 -473
- data/lib/action_dispatch/routing/polymorphic_routes.rb +167 -143
- data/lib/action_dispatch/routing/redirection.rb +37 -27
- data/lib/action_dispatch/routing/route_set.rb +363 -331
- data/lib/action_dispatch/routing/routes_proxy.rb +32 -5
- data/lib/action_dispatch/routing/url_for.rb +66 -26
- data/lib/action_dispatch/routing.rb +36 -36
- data/lib/action_dispatch/system_test_case.rb +190 -0
- data/lib/action_dispatch/system_testing/browser.rb +86 -0
- data/lib/action_dispatch/system_testing/driver.rb +67 -0
- data/lib/action_dispatch/system_testing/server.rb +31 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +138 -0
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +29 -0
- data/lib/action_dispatch/testing/assertion_response.rb +46 -0
- data/lib/action_dispatch/testing/assertions/response.rb +44 -22
- data/lib/action_dispatch/testing/assertions/routing.rb +47 -31
- data/lib/action_dispatch/testing/assertions.rb +6 -4
- data/lib/action_dispatch/testing/integration.rb +391 -220
- data/lib/action_dispatch/testing/request_encoder.rb +55 -0
- data/lib/action_dispatch/testing/test_process.rb +53 -22
- data/lib/action_dispatch/testing/test_request.rb +27 -34
- data/lib/action_dispatch/testing/test_response.rb +11 -11
- data/lib/action_dispatch.rb +35 -21
- data/lib/action_pack/gem_version.rb +6 -4
- data/lib/action_pack/version.rb +3 -1
- data/lib/action_pack.rb +4 -2
- metadata +78 -48
- data/lib/action_controller/metal/force_ssl.rb +0 -97
- data/lib/action_controller/metal/hide_actions.rb +0 -40
- data/lib/action_controller/metal/rack_delegation.rb +0 -32
- data/lib/action_controller/middleware.rb +0 -39
- data/lib/action_controller/model_naming.rb +0 -12
- data/lib/action_dispatch/http/parameter_filter.rb +0 -72
- data/lib/action_dispatch/journey/backwards.rb +0 -5
- data/lib/action_dispatch/journey/nfa/builder.rb +0 -76
- data/lib/action_dispatch/journey/nfa/simulator.rb +0 -47
- data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -163
- data/lib/action_dispatch/journey/router/strexp.rb +0 -27
- data/lib/action_dispatch/middleware/params_parser.rb +0 -60
- data/lib/action_dispatch/testing/assertions/dom.rb +0 -3
- data/lib/action_dispatch/testing/assertions/selector.rb +0 -3
- data/lib/action_dispatch/testing/assertions/tag.rb +0 -3
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionDispatch
|
4
|
+
class RequestEncoder # :nodoc:
|
5
|
+
class IdentityEncoder
|
6
|
+
def content_type; end
|
7
|
+
def accept_header; end
|
8
|
+
def encode_params(params); params; end
|
9
|
+
def response_parser; -> body { body }; end
|
10
|
+
end
|
11
|
+
|
12
|
+
@encoders = { identity: IdentityEncoder.new }
|
13
|
+
|
14
|
+
attr_reader :response_parser
|
15
|
+
|
16
|
+
def initialize(mime_name, param_encoder, response_parser)
|
17
|
+
@mime = Mime[mime_name]
|
18
|
+
|
19
|
+
unless @mime
|
20
|
+
raise ArgumentError, "Can't register a request encoder for " \
|
21
|
+
"unregistered MIME Type: #{mime_name}. See `Mime::Type.register`."
|
22
|
+
end
|
23
|
+
|
24
|
+
@response_parser = response_parser || -> body { body }
|
25
|
+
@param_encoder = param_encoder || :"to_#{@mime.symbol}".to_proc
|
26
|
+
end
|
27
|
+
|
28
|
+
def content_type
|
29
|
+
@mime.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def accept_header
|
33
|
+
@mime.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
def encode_params(params)
|
37
|
+
@param_encoder.call(params) if params
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.parser(content_type)
|
41
|
+
type = Mime::Type.lookup(content_type).ref if content_type
|
42
|
+
encoder(type).response_parser
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.encoder(name)
|
46
|
+
@encoders[name] || @encoders[:identity]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.register_encoder(mime_name, param_encoder: nil, response_parser: nil)
|
50
|
+
@encoders[mime_name] = new(mime_name, param_encoder, response_parser)
|
51
|
+
end
|
52
|
+
|
53
|
+
register_encoder :json, response_parser: -> body { JSON.parse(body) }
|
54
|
+
end
|
55
|
+
end
|
@@ -1,13 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_dispatch/middleware/cookies"
|
4
|
+
require "action_dispatch/middleware/flash"
|
4
5
|
|
5
6
|
module ActionDispatch
|
6
7
|
module TestProcess
|
8
|
+
module FixtureFile
|
9
|
+
# Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_fixture_path, path), type)</tt>:
|
10
|
+
#
|
11
|
+
# post :change_avatar, params: { avatar: fixture_file_upload('spongebob.png', 'image/png') }
|
12
|
+
#
|
13
|
+
# Default fixture files location is <tt>test/fixtures/files</tt>.
|
14
|
+
#
|
15
|
+
# To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
|
16
|
+
# This will not affect other platforms:
|
17
|
+
#
|
18
|
+
# post :change_avatar, params: { avatar: fixture_file_upload('spongebob.png', 'image/png', :binary) }
|
19
|
+
def fixture_file_upload(path, mime_type = nil, binary = false)
|
20
|
+
if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
|
21
|
+
!File.exist?(path)
|
22
|
+
original_path = path
|
23
|
+
path = Pathname.new(self.class.fixture_path).join(path)
|
24
|
+
|
25
|
+
if !self.class.file_fixture_path
|
26
|
+
ActiveSupport::Deprecation.warn(<<~EOM)
|
27
|
+
Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
|
28
|
+
In Rails 6.2, the path needs to be relative to `file_fixture_path` which you
|
29
|
+
haven't set yet. Set `file_fixture_path` to discard this warning.
|
30
|
+
EOM
|
31
|
+
elsif path.exist?
|
32
|
+
non_deprecated_path = Pathname(File.absolute_path(path)).relative_path_from(Pathname(File.absolute_path(self.class.file_fixture_path)))
|
33
|
+
ActiveSupport::Deprecation.warn(<<~EOM)
|
34
|
+
Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
|
35
|
+
In Rails 6.2, the path needs to be relative to `file_fixture_path`.
|
36
|
+
|
37
|
+
Please modify the call from
|
38
|
+
`fixture_file_upload("#{original_path}")` to `fixture_file_upload("#{non_deprecated_path}")`.
|
39
|
+
EOM
|
40
|
+
else
|
41
|
+
path = file_fixture(original_path)
|
42
|
+
end
|
43
|
+
elsif self.class.file_fixture_path && !File.exist?(path)
|
44
|
+
path = file_fixture(path)
|
45
|
+
end
|
46
|
+
|
47
|
+
Rack::Test::UploadedFile.new(path, mime_type, binary)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
include FixtureFile
|
52
|
+
|
7
53
|
def assigns(key = nil)
|
8
|
-
|
9
|
-
|
10
|
-
|
54
|
+
raise NoMethodError,
|
55
|
+
"assigns has been extracted to a gem. To continue using it,
|
56
|
+
add `gem 'rails-controller-testing'` to your Gemfile."
|
11
57
|
end
|
12
58
|
|
13
59
|
def session
|
@@ -19,26 +65,11 @@ module ActionDispatch
|
|
19
65
|
end
|
20
66
|
|
21
67
|
def cookies
|
22
|
-
@request.
|
68
|
+
@cookie_jar ||= Cookies::CookieJar.build(@request, @request.cookies)
|
23
69
|
end
|
24
70
|
|
25
71
|
def redirect_to_url
|
26
72
|
@response.redirect_url
|
27
73
|
end
|
28
|
-
|
29
|
-
# Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, path), type)</tt>:
|
30
|
-
#
|
31
|
-
# post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png')
|
32
|
-
#
|
33
|
-
# To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
|
34
|
-
# This will not affect other platforms:
|
35
|
-
#
|
36
|
-
# post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary)
|
37
|
-
def fixture_file_upload(path, mime_type = nil, binary = false)
|
38
|
-
if self.class.respond_to?(:fixture_path) && self.class.fixture_path
|
39
|
-
path = File.join(self.class.fixture_path, path)
|
40
|
-
end
|
41
|
-
Rack::Test::UploadedFile.new(path, mime_type, binary)
|
42
|
-
end
|
43
74
|
end
|
44
75
|
end
|
@@ -1,41 +1,46 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/hash/indifferent_access"
|
4
|
+
require "rack/utils"
|
3
5
|
|
4
6
|
module ActionDispatch
|
5
7
|
class TestRequest < Request
|
6
|
-
DEFAULT_ENV = Rack::MockRequest.env_for(
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
DEFAULT_ENV = Rack::MockRequest.env_for("/",
|
9
|
+
"HTTP_HOST" => "test.host".b,
|
10
|
+
"REMOTE_ADDR" => "0.0.0.0".b,
|
11
|
+
"HTTP_USER_AGENT" => "Rails Testing".b,
|
10
12
|
)
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
# Create a new test request with default +env+ values.
|
15
|
+
def self.create(env = {})
|
16
|
+
env = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application
|
17
|
+
env["rack.request.cookie_hash"] ||= {}.with_indifferent_access
|
18
|
+
new(default_env.merge(env))
|
14
19
|
end
|
15
20
|
|
16
|
-
def
|
17
|
-
|
18
|
-
super(default_env.merge(env))
|
21
|
+
def self.default_env
|
22
|
+
DEFAULT_ENV
|
19
23
|
end
|
24
|
+
private_class_method :default_env
|
20
25
|
|
21
26
|
def request_method=(method)
|
22
|
-
|
27
|
+
super(method.to_s.upcase)
|
23
28
|
end
|
24
29
|
|
25
30
|
def host=(host)
|
26
|
-
|
31
|
+
set_header("HTTP_HOST", host)
|
27
32
|
end
|
28
33
|
|
29
34
|
def port=(number)
|
30
|
-
|
35
|
+
set_header("SERVER_PORT", number.to_i)
|
31
36
|
end
|
32
37
|
|
33
38
|
def request_uri=(uri)
|
34
|
-
|
39
|
+
set_header("REQUEST_URI", uri)
|
35
40
|
end
|
36
41
|
|
37
42
|
def path=(path)
|
38
|
-
|
43
|
+
set_header("PATH_INFO", path)
|
39
44
|
end
|
40
45
|
|
41
46
|
def action=(action_name)
|
@@ -43,36 +48,24 @@ module ActionDispatch
|
|
43
48
|
end
|
44
49
|
|
45
50
|
def if_modified_since=(last_modified)
|
46
|
-
|
51
|
+
set_header("HTTP_IF_MODIFIED_SINCE", last_modified)
|
47
52
|
end
|
48
53
|
|
49
54
|
def if_none_match=(etag)
|
50
|
-
|
55
|
+
set_header("HTTP_IF_NONE_MATCH", etag)
|
51
56
|
end
|
52
57
|
|
53
58
|
def remote_addr=(addr)
|
54
|
-
|
59
|
+
set_header("REMOTE_ADDR", addr)
|
55
60
|
end
|
56
61
|
|
57
62
|
def user_agent=(user_agent)
|
58
|
-
|
63
|
+
set_header("HTTP_USER_AGENT", user_agent)
|
59
64
|
end
|
60
65
|
|
61
66
|
def accept=(mime_types)
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
alias :rack_cookies :cookies
|
67
|
-
|
68
|
-
def cookies
|
69
|
-
@cookies ||= {}.with_indifferent_access
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def default_env
|
75
|
-
DEFAULT_ENV
|
67
|
+
delete_header("action_dispatch.request.accepts")
|
68
|
+
set_header("HTTP_ACCEPT", Array(mime_types).collect(&:to_s).join(","))
|
76
69
|
end
|
77
70
|
end
|
78
71
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_dispatch/testing/request_encoder"
|
4
|
+
|
1
5
|
module ActionDispatch
|
2
6
|
# Integration test methods such as ActionDispatch::Integration::Session#get
|
3
7
|
# and ActionDispatch::Integration::Session#post return objects of class
|
@@ -7,19 +11,15 @@ module ActionDispatch
|
|
7
11
|
# See Response for more information on controller response objects.
|
8
12
|
class TestResponse < Response
|
9
13
|
def self.from_response(response)
|
10
|
-
new response.status, response.headers, response.body
|
14
|
+
new response.status, response.headers, response.body
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# Was the URL not found?
|
17
|
-
alias_method :missing?, :not_found?
|
18
|
-
|
19
|
-
# Were we redirected?
|
20
|
-
alias_method :redirect?, :redirection?
|
17
|
+
def parsed_body
|
18
|
+
@parsed_body ||= response_parser.call(body)
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
def response_parser
|
22
|
+
@response_parser ||= RequestEncoder.parser(media_type)
|
23
|
+
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/action_dispatch.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2020 David Heinemeier Hansson
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
7
|
# a copy of this software and associated documentation files (the
|
@@ -21,15 +23,15 @@
|
|
21
23
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
24
|
#++
|
23
25
|
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
26
|
+
require "active_support"
|
27
|
+
require "active_support/rails"
|
28
|
+
require "active_support/core_ext/module/attribute_accessors"
|
27
29
|
|
28
|
-
require
|
29
|
-
require
|
30
|
+
require "action_pack"
|
31
|
+
require "rack"
|
30
32
|
|
31
33
|
module Rack
|
32
|
-
autoload :Test,
|
34
|
+
autoload :Test, "rack/test"
|
33
35
|
end
|
34
36
|
|
35
37
|
module ActionDispatch
|
@@ -38,21 +40,30 @@ module ActionDispatch
|
|
38
40
|
class IllegalStateError < StandardError
|
39
41
|
end
|
40
42
|
|
43
|
+
class MissingController < NameError
|
44
|
+
end
|
45
|
+
|
41
46
|
eager_autoload do
|
42
|
-
autoload_under
|
47
|
+
autoload_under "http" do
|
48
|
+
autoload :ContentSecurityPolicy
|
49
|
+
autoload :PermissionsPolicy
|
43
50
|
autoload :Request
|
44
51
|
autoload :Response
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
48
|
-
autoload_under
|
55
|
+
autoload_under "middleware" do
|
56
|
+
autoload :HostAuthorization
|
49
57
|
autoload :RequestId
|
50
58
|
autoload :Callbacks
|
51
59
|
autoload :Cookies
|
60
|
+
autoload :ActionableExceptions
|
52
61
|
autoload :DebugExceptions
|
62
|
+
autoload :DebugLocks
|
63
|
+
autoload :DebugView
|
53
64
|
autoload :ExceptionWrapper
|
65
|
+
autoload :Executor
|
54
66
|
autoload :Flash
|
55
|
-
autoload :ParamsParser
|
56
67
|
autoload :PublicExceptions
|
57
68
|
autoload :Reloader
|
58
69
|
autoload :RemoteIp
|
@@ -62,7 +73,7 @@ module ActionDispatch
|
|
62
73
|
end
|
63
74
|
|
64
75
|
autoload :Journey
|
65
|
-
autoload :MiddlewareStack,
|
76
|
+
autoload :MiddlewareStack, "action_dispatch/middleware/stack"
|
66
77
|
autoload :Routing
|
67
78
|
|
68
79
|
module Http
|
@@ -72,34 +83,37 @@ module ActionDispatch
|
|
72
83
|
autoload :Headers
|
73
84
|
autoload :MimeNegotiation
|
74
85
|
autoload :Parameters
|
75
|
-
autoload :
|
76
|
-
autoload :Upload
|
77
|
-
autoload :UploadedFile, 'action_dispatch/http/upload'
|
86
|
+
autoload :UploadedFile, "action_dispatch/http/upload"
|
78
87
|
autoload :URL
|
79
88
|
end
|
80
89
|
|
81
90
|
module Session
|
82
|
-
autoload :AbstractStore,
|
83
|
-
autoload :
|
84
|
-
autoload :
|
85
|
-
autoload :
|
91
|
+
autoload :AbstractStore, "action_dispatch/middleware/session/abstract_store"
|
92
|
+
autoload :AbstractSecureStore, "action_dispatch/middleware/session/abstract_store"
|
93
|
+
autoload :CookieStore, "action_dispatch/middleware/session/cookie_store"
|
94
|
+
autoload :MemCacheStore, "action_dispatch/middleware/session/mem_cache_store"
|
95
|
+
autoload :CacheStore, "action_dispatch/middleware/session/cache_store"
|
86
96
|
end
|
87
97
|
|
88
98
|
mattr_accessor :test_app
|
89
99
|
|
90
|
-
autoload_under
|
100
|
+
autoload_under "testing" do
|
91
101
|
autoload :Assertions
|
92
102
|
autoload :Integration
|
93
|
-
autoload :IntegrationTest,
|
103
|
+
autoload :IntegrationTest, "action_dispatch/testing/integration"
|
94
104
|
autoload :TestProcess
|
95
105
|
autoload :TestRequest
|
96
106
|
autoload :TestResponse
|
107
|
+
autoload :AssertionResponse
|
97
108
|
end
|
109
|
+
|
110
|
+
autoload :SystemTestCase, "action_dispatch/system_test_case"
|
98
111
|
end
|
99
112
|
|
100
|
-
autoload :Mime,
|
113
|
+
autoload :Mime, "action_dispatch/http/mime_type"
|
101
114
|
|
102
115
|
ActiveSupport.on_load(:action_view) do
|
103
116
|
ActionView::Base.default_formats ||= Mime::SET.symbols
|
104
117
|
ActionView::Template::Types.delegate_to Mime
|
118
|
+
ActionView::LookupContext::DetailsKey.clear
|
105
119
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionPack
|
2
4
|
# Returns the version of the currently loaded Action Pack as a <tt>Gem::Version</tt>
|
3
5
|
def self.gem_version
|
@@ -5,10 +7,10 @@ module ActionPack
|
|
5
7
|
end
|
6
8
|
|
7
9
|
module VERSION
|
8
|
-
MAJOR =
|
9
|
-
MINOR =
|
10
|
-
TINY =
|
11
|
-
PRE = "
|
10
|
+
MAJOR = 6
|
11
|
+
MINOR = 1
|
12
|
+
TINY = 3
|
13
|
+
PRE = "2"
|
12
14
|
|
13
15
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
14
16
|
end
|
data/lib/action_pack/version.rb
CHANGED
data/lib/action_pack.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2020 David Heinemeier Hansson
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
7
|
# a copy of this software and associated documentation files (the
|
@@ -21,4 +23,4 @@
|
|
21
23
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
24
|
#++
|
23
25
|
|
24
|
-
require
|
26
|
+
require "action_pack/version"
|