actionpack 7.0.8.1 → 7.2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +94 -500
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -2
- data/lib/abstract_controller/asset_paths.rb +2 -0
- data/lib/abstract_controller/base.rb +119 -106
- data/lib/abstract_controller/caching/fragments.rb +51 -52
- data/lib/abstract_controller/caching.rb +2 -0
- data/lib/abstract_controller/callbacks.rb +94 -67
- data/lib/abstract_controller/collector.rb +6 -6
- data/lib/abstract_controller/deprecator.rb +9 -0
- data/lib/abstract_controller/error.rb +2 -0
- data/lib/abstract_controller/helpers.rb +121 -91
- data/lib/abstract_controller/logger.rb +2 -0
- data/lib/abstract_controller/railties/routes_helpers.rb +3 -16
- data/lib/abstract_controller/rendering.rb +14 -13
- data/lib/abstract_controller/translation.rb +12 -30
- data/lib/abstract_controller/url_for.rb +9 -5
- data/lib/abstract_controller.rb +8 -0
- data/lib/action_controller/api/api_rendering.rb +2 -0
- data/lib/action_controller/api.rb +78 -73
- data/lib/action_controller/base.rb +199 -141
- data/lib/action_controller/caching.rb +16 -11
- data/lib/action_controller/deprecator.rb +9 -0
- data/lib/action_controller/form_builder.rb +21 -16
- data/lib/action_controller/log_subscriber.rb +19 -5
- data/lib/action_controller/metal/allow_browser.rb +123 -0
- data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
- data/lib/action_controller/metal/conditional_get.rb +187 -174
- data/lib/action_controller/metal/content_security_policy.rb +26 -25
- data/lib/action_controller/metal/cookies.rb +4 -2
- data/lib/action_controller/metal/data_streaming.rb +65 -54
- data/lib/action_controller/metal/default_headers.rb +6 -2
- data/lib/action_controller/metal/etag_with_flash.rb +4 -0
- data/lib/action_controller/metal/etag_with_template_digest.rb +18 -14
- data/lib/action_controller/metal/exceptions.rb +19 -9
- data/lib/action_controller/metal/flash.rb +12 -10
- data/lib/action_controller/metal/head.rb +20 -16
- data/lib/action_controller/metal/helpers.rb +64 -67
- data/lib/action_controller/metal/http_authentication.rb +214 -200
- data/lib/action_controller/metal/implicit_render.rb +21 -17
- data/lib/action_controller/metal/instrumentation.rb +22 -12
- data/lib/action_controller/metal/live.rb +125 -92
- data/lib/action_controller/metal/logging.rb +6 -4
- data/lib/action_controller/metal/mime_responds.rb +151 -142
- data/lib/action_controller/metal/parameter_encoding.rb +34 -32
- data/lib/action_controller/metal/params_wrapper.rb +58 -58
- data/lib/action_controller/metal/permissions_policy.rb +14 -13
- data/lib/action_controller/metal/rate_limiting.rb +62 -0
- data/lib/action_controller/metal/redirecting.rb +110 -84
- data/lib/action_controller/metal/renderers.rb +50 -49
- data/lib/action_controller/metal/rendering.rb +103 -82
- data/lib/action_controller/metal/request_forgery_protection.rb +279 -161
- data/lib/action_controller/metal/rescue.rb +12 -8
- data/lib/action_controller/metal/streaming.rb +174 -132
- data/lib/action_controller/metal/strong_parameters.rb +598 -473
- data/lib/action_controller/metal/testing.rb +2 -0
- data/lib/action_controller/metal/url_for.rb +23 -14
- data/lib/action_controller/metal.rb +145 -61
- data/lib/action_controller/railtie.rb +25 -9
- data/lib/action_controller/railties/helpers.rb +2 -0
- data/lib/action_controller/renderer.rb +105 -66
- data/lib/action_controller/template_assertions.rb +4 -2
- data/lib/action_controller/test_case.rb +157 -128
- data/lib/action_controller.rb +17 -3
- data/lib/action_dispatch/constants.rb +34 -0
- data/lib/action_dispatch/deprecator.rb +9 -0
- data/lib/action_dispatch/http/cache.rb +28 -29
- data/lib/action_dispatch/http/content_disposition.rb +2 -0
- data/lib/action_dispatch/http/content_security_policy.rb +69 -49
- data/lib/action_dispatch/http/filter_parameters.rb +27 -12
- data/lib/action_dispatch/http/filter_redirect.rb +22 -1
- data/lib/action_dispatch/http/headers.rb +23 -21
- data/lib/action_dispatch/http/mime_negotiation.rb +37 -48
- data/lib/action_dispatch/http/mime_type.rb +60 -30
- data/lib/action_dispatch/http/mime_types.rb +5 -1
- data/lib/action_dispatch/http/parameters.rb +12 -10
- data/lib/action_dispatch/http/permissions_policy.rb +32 -34
- data/lib/action_dispatch/http/rack_cache.rb +4 -0
- data/lib/action_dispatch/http/request.rb +132 -79
- data/lib/action_dispatch/http/response.rb +136 -103
- data/lib/action_dispatch/http/upload.rb +19 -15
- data/lib/action_dispatch/http/url.rb +75 -73
- data/lib/action_dispatch/journey/formatter.rb +19 -6
- data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
- data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
- data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
- data/lib/action_dispatch/journey/nodes/node.rb +6 -5
- data/lib/action_dispatch/journey/parser.rb +4 -3
- data/lib/action_dispatch/journey/parser_extras.rb +2 -0
- data/lib/action_dispatch/journey/path/pattern.rb +18 -15
- data/lib/action_dispatch/journey/route.rb +12 -9
- data/lib/action_dispatch/journey/router/utils.rb +16 -15
- data/lib/action_dispatch/journey/router.rb +13 -10
- data/lib/action_dispatch/journey/routes.rb +6 -4
- data/lib/action_dispatch/journey/scanner.rb +4 -2
- data/lib/action_dispatch/journey/visitors.rb +2 -0
- data/lib/action_dispatch/journey.rb +2 -0
- data/lib/action_dispatch/log_subscriber.rb +25 -0
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +7 -6
- data/lib/action_dispatch/middleware/assume_ssl.rb +27 -0
- data/lib/action_dispatch/middleware/callbacks.rb +4 -0
- data/lib/action_dispatch/middleware/cookies.rb +192 -194
- data/lib/action_dispatch/middleware/debug_exceptions.rb +36 -27
- data/lib/action_dispatch/middleware/debug_locks.rb +18 -13
- data/lib/action_dispatch/middleware/debug_view.rb +9 -2
- data/lib/action_dispatch/middleware/exception_wrapper.rb +181 -27
- data/lib/action_dispatch/middleware/executor.rb +9 -1
- data/lib/action_dispatch/middleware/flash.rb +65 -46
- data/lib/action_dispatch/middleware/host_authorization.rb +22 -17
- data/lib/action_dispatch/middleware/public_exceptions.rb +12 -8
- data/lib/action_dispatch/middleware/reloader.rb +9 -5
- data/lib/action_dispatch/middleware/remote_ip.rb +88 -83
- data/lib/action_dispatch/middleware/request_id.rb +15 -8
- data/lib/action_dispatch/middleware/server_timing.rb +8 -6
- data/lib/action_dispatch/middleware/session/abstract_store.rb +7 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +14 -7
- data/lib/action_dispatch/middleware/session/cookie_store.rb +32 -25
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +9 -3
- data/lib/action_dispatch/middleware/show_exceptions.rb +42 -28
- data/lib/action_dispatch/middleware/ssl.rb +60 -45
- data/lib/action_dispatch/middleware/stack.rb +15 -9
- data/lib/action_dispatch/middleware/static.rb +40 -34
- data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +8 -1
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +7 -7
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +17 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +16 -12
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +3 -0
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +47 -38
- data/lib/action_dispatch/railtie.rb +12 -4
- data/lib/action_dispatch/request/session.rb +39 -27
- data/lib/action_dispatch/request/utils.rb +10 -3
- data/lib/action_dispatch/routing/endpoint.rb +2 -0
- data/lib/action_dispatch/routing/inspector.rb +59 -9
- data/lib/action_dispatch/routing/mapper.rb +686 -639
- data/lib/action_dispatch/routing/polymorphic_routes.rb +70 -61
- data/lib/action_dispatch/routing/redirection.rb +52 -38
- data/lib/action_dispatch/routing/route_set.rb +106 -62
- data/lib/action_dispatch/routing/routes_proxy.rb +16 -19
- data/lib/action_dispatch/routing/url_for.rb +131 -122
- data/lib/action_dispatch/routing.rb +152 -150
- data/lib/action_dispatch/system_test_case.rb +91 -81
- data/lib/action_dispatch/system_testing/browser.rb +27 -19
- data/lib/action_dispatch/system_testing/driver.rb +16 -22
- data/lib/action_dispatch/system_testing/server.rb +2 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +53 -31
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
- data/lib/action_dispatch/testing/assertion_response.rb +9 -7
- data/lib/action_dispatch/testing/assertions/response.rb +36 -26
- data/lib/action_dispatch/testing/assertions/routing.rb +203 -95
- data/lib/action_dispatch/testing/assertions.rb +5 -1
- data/lib/action_dispatch/testing/integration.rb +240 -229
- data/lib/action_dispatch/testing/request_encoder.rb +6 -1
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
- data/lib/action_dispatch/testing/test_process.rb +14 -9
- data/lib/action_dispatch/testing/test_request.rb +4 -2
- data/lib/action_dispatch/testing/test_response.rb +34 -19
- data/lib/action_dispatch.rb +52 -21
- data/lib/action_pack/gem_version.rb +5 -3
- data/lib/action_pack/version.rb +3 -1
- data/lib/action_pack.rb +18 -17
- metadata +91 -32
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
5
|
+
require "nokogiri"
|
6
|
+
|
3
7
|
module ActionDispatch
|
4
8
|
class RequestEncoder # :nodoc:
|
5
9
|
class IdentityEncoder
|
@@ -50,6 +54,7 @@ module ActionDispatch
|
|
50
54
|
@encoders[mime_name] = new(mime_name, param_encoder, response_parser)
|
51
55
|
end
|
52
56
|
|
53
|
-
register_encoder :
|
57
|
+
register_encoder :html, response_parser: -> body { Rails::Dom::Testing.html_document.parse(body) }
|
58
|
+
register_encoder :json, response_parser: -> body { JSON.parse(body, object_class: ActiveSupport::HashWithIndifferentAccess) }
|
54
59
|
end
|
55
60
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionDispatch
|
4
|
+
module TestHelpers
|
5
|
+
module PageDumpHelper
|
6
|
+
class InvalidResponse < StandardError; end
|
7
|
+
|
8
|
+
# Saves the content of response body to a file and tries to open it in your browser.
|
9
|
+
# Launchy must be present in your Gemfile for the page to open automatically.
|
10
|
+
def save_and_open_page(path = html_dump_default_path)
|
11
|
+
save_page(path).tap { |s_path| open_file(s_path) }
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def save_page(path = html_dump_default_path)
|
16
|
+
raise InvalidResponse.new("Response is a redirection!") if response.redirection?
|
17
|
+
path = Pathname.new(path)
|
18
|
+
path.dirname.mkpath
|
19
|
+
File.write(path, response.body)
|
20
|
+
path
|
21
|
+
end
|
22
|
+
|
23
|
+
def open_file(path)
|
24
|
+
require "launchy"
|
25
|
+
Launchy.open(path)
|
26
|
+
rescue LoadError
|
27
|
+
warn "File saved to #{path}.\nPlease install the launchy gem to open the file automatically."
|
28
|
+
end
|
29
|
+
|
30
|
+
def html_dump_default_path
|
31
|
+
Rails.root.join("tmp/html_dump", "#{method_name}_#{DateTime.current.to_i}.html").to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,36 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require "action_dispatch/middleware/cookies"
|
4
6
|
require "action_dispatch/middleware/flash"
|
5
7
|
|
6
8
|
module ActionDispatch
|
7
9
|
module TestProcess
|
8
10
|
module FixtureFile
|
9
|
-
# Shortcut for
|
11
|
+
# Shortcut for
|
12
|
+
# `Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_f
|
13
|
+
# ixture_path, path), type)`:
|
10
14
|
#
|
11
|
-
#
|
15
|
+
# post :change_avatar, params: { avatar: file_fixture_upload('david.png', 'image/png') }
|
12
16
|
#
|
13
|
-
# Default fixture files location is
|
17
|
+
# Default fixture files location is `test/fixtures/files`.
|
14
18
|
#
|
15
|
-
# To upload binary files on Windows, pass
|
16
|
-
#
|
19
|
+
# To upload binary files on Windows, pass `:binary` as the last parameter. This
|
20
|
+
# will not affect other platforms:
|
17
21
|
#
|
18
|
-
#
|
19
|
-
def
|
22
|
+
# post :change_avatar, params: { avatar: file_fixture_upload('david.png', 'image/png', :binary) }
|
23
|
+
def file_fixture_upload(path, mime_type = nil, binary = false)
|
20
24
|
if self.class.file_fixture_path && !File.exist?(path)
|
21
25
|
path = file_fixture(path)
|
22
26
|
end
|
23
27
|
|
24
28
|
Rack::Test::UploadedFile.new(path, mime_type, binary)
|
25
29
|
end
|
30
|
+
alias_method :fixture_file_upload, :file_fixture_upload
|
26
31
|
end
|
27
32
|
|
28
33
|
include FixtureFile
|
29
34
|
|
30
35
|
def assigns(key = nil)
|
31
36
|
raise NoMethodError,
|
32
|
-
|
33
|
-
add `gem
|
37
|
+
'assigns has been extracted to a gem. To continue using it,
|
38
|
+
add `gem "rails-controller-testing"` to your Gemfile.'
|
34
39
|
end
|
35
40
|
|
36
41
|
def session
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require "active_support/core_ext/hash/indifferent_access"
|
4
6
|
require "rack/utils"
|
5
7
|
|
@@ -11,7 +13,7 @@ module ActionDispatch
|
|
11
13
|
"HTTP_USER_AGENT" => "Rails Testing".b,
|
12
14
|
)
|
13
15
|
|
14
|
-
# Create a new test request with default
|
16
|
+
# Create a new test request with default `env` values.
|
15
17
|
def self.create(env = {})
|
16
18
|
env = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application
|
17
19
|
env["rack.request.cookie_hash"] ||= {}.with_indifferent_access
|
@@ -32,7 +34,7 @@ module ActionDispatch
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def port=(number)
|
35
|
-
set_header("SERVER_PORT", number
|
37
|
+
set_header("SERVER_PORT", number)
|
36
38
|
end
|
37
39
|
|
38
40
|
def request_uri=(uri)
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require "action_dispatch/testing/request_encoder"
|
4
6
|
|
5
7
|
module ActionDispatch
|
6
|
-
# Integration test methods such as Integration::RequestHelpers#get
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# controller actions.
|
8
|
+
# Integration test methods such as Integration::RequestHelpers#get and
|
9
|
+
# Integration::RequestHelpers#post return objects of class TestResponse, which
|
10
|
+
# represent the HTTP response results of the requested controller actions.
|
10
11
|
#
|
11
12
|
# See Response for more information on controller response objects.
|
12
13
|
class TestResponse < Response
|
@@ -17,21 +18,35 @@ module ActionDispatch
|
|
17
18
|
# Returns a parsed body depending on the response MIME type. When a parser
|
18
19
|
# corresponding to the MIME type is not found, it returns the raw body.
|
19
20
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
21
|
+
# #### Examples
|
22
|
+
# get "/posts"
|
23
|
+
# response.content_type # => "text/html; charset=utf-8"
|
24
|
+
# response.parsed_body.class # => Nokogiri::HTML5::Document
|
25
|
+
# response.parsed_body.to_html # => "<!DOCTYPE html>\n<html>\n..."
|
26
|
+
#
|
27
|
+
# assert_pattern { response.parsed_body.at("main") => { content: "Hello, world" } }
|
28
|
+
#
|
29
|
+
# response.parsed_body.at("main") => {name:, content:}
|
30
|
+
# assert_equal "main", name
|
31
|
+
# assert_equal "Some main content", content
|
32
|
+
#
|
33
|
+
# get "/posts.json"
|
34
|
+
# response.content_type # => "application/json; charset=utf-8"
|
35
|
+
# response.parsed_body.class # => Array
|
36
|
+
# response.parsed_body # => [{"id"=>42, "title"=>"Title"},...
|
37
|
+
#
|
38
|
+
# assert_pattern { response.parsed_body => [{ id: 42 }] }
|
39
|
+
#
|
40
|
+
# get "/posts/42.json"
|
41
|
+
# response.content_type # => "application/json; charset=utf-8"
|
42
|
+
# response.parsed_body.class # => ActiveSupport::HashWithIndifferentAccess
|
43
|
+
# response.parsed_body # => {"id"=>42, "title"=>"Title"}
|
44
|
+
#
|
45
|
+
# assert_pattern { response.parsed_body => [{ title: /title/i }] }
|
46
|
+
#
|
47
|
+
# response.parsed_body => {id:, title:}
|
48
|
+
# assert_equal 42, id
|
49
|
+
# assert_equal "Title", title
|
35
50
|
def parsed_body
|
36
51
|
@parsed_body ||= response_parser.call(body)
|
37
52
|
end
|
data/lib/action_dispatch.rb
CHANGED
@@ -1,44 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c)
|
4
|
+
# Copyright (c) David Heinemeier Hansson
|
5
5
|
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# the following conditions:
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
13
12
|
#
|
14
|
-
# The above copyright notice and this permission notice shall be
|
15
|
-
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
16
15
|
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# OF
|
23
|
-
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
24
23
|
#++
|
25
24
|
|
25
|
+
# :markup: markdown
|
26
|
+
|
26
27
|
require "active_support"
|
27
28
|
require "active_support/rails"
|
28
29
|
require "active_support/core_ext/module/attribute_accessors"
|
29
30
|
|
30
31
|
require "action_pack"
|
31
32
|
require "rack"
|
33
|
+
require "uri"
|
34
|
+
require "action_dispatch/deprecator"
|
32
35
|
|
33
|
-
module Rack
|
36
|
+
module Rack # :nodoc:
|
34
37
|
autoload :Test, "rack/test"
|
35
38
|
end
|
36
39
|
|
40
|
+
# # Action Dispatch
|
41
|
+
#
|
42
|
+
# Action Dispatch is a module of Action Pack.
|
43
|
+
#
|
44
|
+
# Action Dispatch parses information about the web request, handles routing as
|
45
|
+
# defined by the user, and does advanced processing related to HTTP such as
|
46
|
+
# MIME-type negotiation, decoding parameters in POST, PATCH, or PUT bodies,
|
47
|
+
# handling HTTP caching logic, cookies and sessions.
|
37
48
|
module ActionDispatch
|
38
49
|
extend ActiveSupport::Autoload
|
39
50
|
|
40
|
-
|
41
|
-
|
51
|
+
RFC2396_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
|
52
|
+
private_constant :RFC2396_PARSER
|
42
53
|
|
43
54
|
class MissingController < NameError
|
44
55
|
end
|
@@ -53,6 +64,7 @@ module ActionDispatch
|
|
53
64
|
end
|
54
65
|
|
55
66
|
autoload_under "middleware" do
|
67
|
+
autoload :AssumeSSL
|
56
68
|
autoload :HostAuthorization
|
57
69
|
autoload :RequestId
|
58
70
|
autoload :Callbacks
|
@@ -73,6 +85,7 @@ module ActionDispatch
|
|
73
85
|
autoload :Static
|
74
86
|
end
|
75
87
|
|
88
|
+
autoload :Constants
|
76
89
|
autoload :Journey
|
77
90
|
autoload :MiddlewareStack, "action_dispatch/middleware/stack"
|
78
91
|
autoload :Routing
|
@@ -94,6 +107,19 @@ module ActionDispatch
|
|
94
107
|
autoload :CookieStore, "action_dispatch/middleware/session/cookie_store"
|
95
108
|
autoload :MemCacheStore, "action_dispatch/middleware/session/mem_cache_store"
|
96
109
|
autoload :CacheStore, "action_dispatch/middleware/session/cache_store"
|
110
|
+
|
111
|
+
def self.resolve_store(session_store) # :nodoc:
|
112
|
+
self.const_get(session_store.to_s.camelize)
|
113
|
+
rescue NameError
|
114
|
+
raise <<~ERROR
|
115
|
+
Unable to resolve session store #{session_store.inspect}.
|
116
|
+
|
117
|
+
#{session_store.inspect} resolves to ActionDispatch::Session::#{session_store.to_s.camelize},
|
118
|
+
but that class is undefined.
|
119
|
+
|
120
|
+
Is #{session_store.inspect} spelled correctly, and are any necessary gems installed?
|
121
|
+
ERROR
|
122
|
+
end
|
97
123
|
end
|
98
124
|
|
99
125
|
mattr_accessor :test_app
|
@@ -109,12 +135,17 @@ module ActionDispatch
|
|
109
135
|
end
|
110
136
|
|
111
137
|
autoload :SystemTestCase, "action_dispatch/system_test_case"
|
138
|
+
|
139
|
+
def eager_load!
|
140
|
+
super
|
141
|
+
Routing.eager_load!
|
142
|
+
end
|
112
143
|
end
|
113
144
|
|
114
145
|
autoload :Mime, "action_dispatch/http/mime_type"
|
115
146
|
|
116
147
|
ActiveSupport.on_load(:action_view) do
|
117
148
|
ActionView::Base.default_formats ||= Mime::SET.symbols
|
118
|
-
ActionView::Template
|
149
|
+
ActionView::Template.mime_types_implementation = Mime
|
119
150
|
ActionView::LookupContext::DetailsKey.clear
|
120
151
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
module ActionPack
|
4
|
-
# Returns the currently loaded version of Action Pack as a
|
6
|
+
# Returns the currently loaded version of Action Pack as a `Gem::Version`.
|
5
7
|
def self.gem_version
|
6
8
|
Gem::Version.new VERSION::STRING
|
7
9
|
end
|
8
10
|
|
9
11
|
module VERSION
|
10
12
|
MAJOR = 7
|
11
|
-
MINOR =
|
12
|
-
TINY =
|
13
|
+
MINOR = 2
|
14
|
+
TINY = 2
|
13
15
|
PRE = "1"
|
14
16
|
|
15
17
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
data/lib/action_pack/version.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require_relative "gem_version"
|
4
6
|
|
5
7
|
module ActionPack
|
6
|
-
# Returns the currently loaded version of Action Pack as a
|
8
|
+
# Returns the currently loaded version of Action Pack as a `Gem::Version`.
|
7
9
|
def self.version
|
8
10
|
gem_version
|
9
11
|
end
|
data/lib/action_pack.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c)
|
4
|
+
# Copyright (c) David Heinemeier Hansson
|
5
5
|
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# the following conditions:
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
13
12
|
#
|
14
|
-
# The above copyright notice and this permission notice shall be
|
15
|
-
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
16
15
|
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# OF
|
23
|
-
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
24
23
|
#++
|
25
24
|
|
25
|
+
# :markup: markdown
|
26
|
+
|
26
27
|
require "action_pack/version"
|