actionpack 6.0.4.1 → 6.1.0.rc1
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 +241 -304
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/abstract_controller/base.rb +35 -2
- data/lib/abstract_controller/callbacks.rb +2 -2
- data/lib/abstract_controller/helpers.rb +105 -90
- data/lib/abstract_controller/rendering.rb +9 -9
- data/lib/abstract_controller/translation.rb +8 -2
- data/lib/abstract_controller.rb +1 -0
- data/lib/action_controller/api.rb +2 -2
- data/lib/action_controller/base.rb +4 -2
- data/lib/action_controller/caching.rb +0 -1
- data/lib/action_controller/log_subscriber.rb +3 -3
- data/lib/action_controller/metal/conditional_get.rb +10 -2
- data/lib/action_controller/metal/content_security_policy.rb +1 -1
- data/lib/action_controller/metal/data_streaming.rb +1 -1
- data/lib/action_controller/metal/etag_with_template_digest.rb +2 -4
- data/lib/action_controller/metal/exceptions.rb +33 -0
- data/lib/action_controller/metal/feature_policy.rb +46 -0
- data/lib/action_controller/metal/head.rb +7 -4
- data/lib/action_controller/metal/helpers.rb +11 -1
- data/lib/action_controller/metal/http_authentication.rb +5 -3
- data/lib/action_controller/metal/implicit_render.rb +1 -1
- data/lib/action_controller/metal/instrumentation.rb +11 -9
- data/lib/action_controller/metal/live.rb +1 -1
- data/lib/action_controller/metal/logging.rb +20 -0
- data/lib/action_controller/metal/mime_responds.rb +6 -2
- data/lib/action_controller/metal/parameter_encoding.rb +35 -4
- data/lib/action_controller/metal/params_wrapper.rb +16 -11
- data/lib/action_controller/metal/redirecting.rb +1 -1
- data/lib/action_controller/metal/rendering.rb +6 -0
- data/lib/action_controller/metal/request_forgery_protection.rb +1 -1
- data/lib/action_controller/metal/rescue.rb +1 -1
- data/lib/action_controller/metal/strong_parameters.rb +103 -15
- data/lib/action_controller/metal.rb +2 -2
- data/lib/action_controller/renderer.rb +24 -13
- data/lib/action_controller/test_case.rb +62 -56
- data/lib/action_controller.rb +2 -3
- data/lib/action_dispatch/http/cache.rb +12 -10
- data/lib/action_dispatch/http/content_security_policy.rb +5 -1
- data/lib/action_dispatch/http/feature_policy.rb +168 -0
- data/lib/action_dispatch/http/filter_parameters.rb +1 -1
- data/lib/action_dispatch/http/filter_redirect.rb +1 -1
- data/lib/action_dispatch/http/headers.rb +3 -2
- data/lib/action_dispatch/http/mime_negotiation.rb +14 -8
- data/lib/action_dispatch/http/mime_type.rb +29 -16
- data/lib/action_dispatch/http/parameters.rb +1 -19
- data/lib/action_dispatch/http/request.rb +24 -8
- data/lib/action_dispatch/http/response.rb +17 -16
- data/lib/action_dispatch/http/url.rb +3 -2
- data/lib/action_dispatch/journey/formatter.rb +53 -28
- data/lib/action_dispatch/journey/gtg/builder.rb +22 -36
- data/lib/action_dispatch/journey/gtg/simulator.rb +8 -7
- data/lib/action_dispatch/journey/gtg/transition_table.rb +6 -4
- data/lib/action_dispatch/journey/nfa/dot.rb +0 -11
- data/lib/action_dispatch/journey/nodes/node.rb +4 -3
- data/lib/action_dispatch/journey/parser.rb +13 -13
- data/lib/action_dispatch/journey/parser.y +1 -1
- data/lib/action_dispatch/journey/path/pattern.rb +13 -18
- data/lib/action_dispatch/journey/route.rb +7 -18
- data/lib/action_dispatch/journey/router/utils.rb +6 -4
- data/lib/action_dispatch/journey/router.rb +26 -30
- data/lib/action_dispatch/journey.rb +0 -2
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +1 -1
- data/lib/action_dispatch/middleware/cookies.rb +67 -32
- data/lib/action_dispatch/middleware/debug_exceptions.rb +8 -15
- data/lib/action_dispatch/middleware/debug_view.rb +1 -1
- data/lib/action_dispatch/middleware/exception_wrapper.rb +28 -16
- data/lib/action_dispatch/middleware/host_authorization.rb +29 -12
- data/lib/action_dispatch/middleware/remote_ip.rb +5 -4
- data/lib/action_dispatch/middleware/request_id.rb +4 -5
- data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -2
- data/lib/action_dispatch/middleware/session/cookie_store.rb +2 -2
- data/lib/action_dispatch/middleware/ssl.rb +9 -6
- data/lib/action_dispatch/middleware/stack.rb +18 -0
- data/lib/action_dispatch/middleware/static.rb +154 -93
- data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +18 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +2 -5
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +2 -3
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +88 -8
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +12 -1
- data/lib/action_dispatch/railtie.rb +3 -2
- data/lib/action_dispatch/request/session.rb +2 -8
- data/lib/action_dispatch/request/utils.rb +26 -2
- data/lib/action_dispatch/routing/inspector.rb +8 -7
- data/lib/action_dispatch/routing/mapper.rb +102 -71
- data/lib/action_dispatch/routing/polymorphic_routes.rb +16 -19
- data/lib/action_dispatch/routing/redirection.rb +3 -3
- data/lib/action_dispatch/routing/route_set.rb +49 -41
- data/lib/action_dispatch/system_test_case.rb +29 -24
- data/lib/action_dispatch/system_testing/browser.rb +33 -27
- data/lib/action_dispatch/system_testing/driver.rb +6 -7
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +47 -6
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +4 -7
- data/lib/action_dispatch/testing/assertions/response.rb +2 -4
- data/lib/action_dispatch/testing/assertions/routing.rb +5 -5
- data/lib/action_dispatch/testing/assertions.rb +1 -1
- data/lib/action_dispatch/testing/integration.rb +38 -27
- data/lib/action_dispatch/testing/test_process.rb +29 -4
- data/lib/action_dispatch/testing/test_request.rb +3 -3
- data/lib/action_dispatch.rb +3 -2
- data/lib/action_pack/gem_version.rb +3 -3
- data/lib/action_pack.rb +1 -1
- metadata +23 -24
- data/lib/action_controller/metal/force_ssl.rb +0 -58
- data/lib/action_dispatch/http/parameter_filter.rb +0 -12
- data/lib/action_dispatch/journey/nfa/builder.rb +0 -78
- data/lib/action_dispatch/journey/nfa/simulator.rb +0 -47
- data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -119
@@ -7,10 +7,13 @@ module ActionDispatch
|
|
7
7
|
@name = name
|
8
8
|
@browser = Browser.new(options[:using])
|
9
9
|
@screen_size = options[:screen_size]
|
10
|
-
@options = options[:options]
|
10
|
+
@options = options[:options] || {}
|
11
11
|
@capabilities = capabilities
|
12
12
|
|
13
|
-
|
13
|
+
if name == :selenium
|
14
|
+
require "selenium/webdriver"
|
15
|
+
@browser.preload
|
16
|
+
end
|
14
17
|
end
|
15
18
|
|
16
19
|
def use
|
@@ -25,7 +28,7 @@ module ActionDispatch
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def register
|
28
|
-
|
31
|
+
@browser.configure(&@capabilities)
|
29
32
|
|
30
33
|
Capybara.register_driver @name do |app|
|
31
34
|
case @name
|
@@ -36,10 +39,6 @@ module ActionDispatch
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
def define_browser_capabilities(capabilities)
|
40
|
-
@capabilities.call(capabilities) if @capabilities
|
41
|
-
end
|
42
|
-
|
43
42
|
def browser_options
|
44
43
|
@options.merge(options: @browser.options).compact
|
45
44
|
end
|
@@ -9,10 +9,16 @@ module ActionDispatch
|
|
9
9
|
#
|
10
10
|
# +take_screenshot+ can be used at any point in your system tests to take
|
11
11
|
# a screenshot of the current state. This can be useful for debugging or
|
12
|
-
# automating visual testing.
|
12
|
+
# automating visual testing. You can take multiple screenshots per test
|
13
|
+
# to investigate changes at different points during your test. These will be
|
14
|
+
# named with a sequential prefix (or 'failed' for failing tests)
|
13
15
|
#
|
14
16
|
# The screenshot will be displayed in your console, if supported.
|
15
17
|
#
|
18
|
+
# You can set the +RAILS_SYSTEM_TESTING_SCREENSHOT_HTML+ environment variable to
|
19
|
+
# save the HTML from the page that is being screenhoted so you can investigate the
|
20
|
+
# elements on the page at the time of the screenshot
|
21
|
+
#
|
16
22
|
# You can set the +RAILS_SYSTEM_TESTING_SCREENSHOT+ environment variable to
|
17
23
|
# control the output. Possible values are:
|
18
24
|
# * [+simple+ (default)] Only displays the screenshot path.
|
@@ -22,6 +28,8 @@ module ActionDispatch
|
|
22
28
|
# * [+artifact+] Display the screenshot in the terminal, using the terminal
|
23
29
|
# artifact format (https://buildkite.github.io/terminal-to-html/inline-images/).
|
24
30
|
def take_screenshot
|
31
|
+
increment_unique
|
32
|
+
save_html if save_html?
|
25
33
|
save_image
|
26
34
|
puts display_image
|
27
35
|
end
|
@@ -38,17 +46,49 @@ module ActionDispatch
|
|
38
46
|
end
|
39
47
|
|
40
48
|
private
|
49
|
+
attr_accessor :_screenshot_counter
|
50
|
+
|
51
|
+
def save_html?
|
52
|
+
ENV["RAILS_SYSTEM_TESTING_SCREENSHOT_HTML"] == "1"
|
53
|
+
end
|
54
|
+
|
55
|
+
def increment_unique
|
56
|
+
@_screenshot_counter ||= 0
|
57
|
+
@_screenshot_counter += 1
|
58
|
+
end
|
59
|
+
|
60
|
+
def unique
|
61
|
+
failed? ? "failures" : (_screenshot_counter || 0).to_s
|
62
|
+
end
|
63
|
+
|
41
64
|
def image_name
|
42
|
-
|
43
|
-
|
65
|
+
sanitized_method_name = method_name.tr("/\\", "--")
|
66
|
+
name = "#{unique}_#{sanitized_method_name}"
|
67
|
+
name[0...225]
|
44
68
|
end
|
45
69
|
|
46
70
|
def image_path
|
47
|
-
|
71
|
+
absolute_image_path.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def html_path
|
75
|
+
absolute_html_path.to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
def absolute_path
|
79
|
+
Rails.root.join("tmp/screenshots/#{image_name}")
|
48
80
|
end
|
49
81
|
|
50
82
|
def absolute_image_path
|
51
|
-
|
83
|
+
"#{absolute_path}.png"
|
84
|
+
end
|
85
|
+
|
86
|
+
def absolute_html_path
|
87
|
+
"#{absolute_path}.html"
|
88
|
+
end
|
89
|
+
|
90
|
+
def save_html
|
91
|
+
page.save_page(absolute_html_path)
|
52
92
|
end
|
53
93
|
|
54
94
|
def save_image
|
@@ -66,7 +106,8 @@ module ActionDispatch
|
|
66
106
|
end
|
67
107
|
|
68
108
|
def display_image
|
69
|
-
message = +"[Screenshot]: #{image_path}\n"
|
109
|
+
message = +"[Screenshot Image]: #{image_path}\n"
|
110
|
+
message << +"[Screenshot HTML]: #{html_path}\n" if save_html?
|
70
111
|
|
71
112
|
case output_type
|
72
113
|
when "artifact"
|
@@ -4,15 +4,12 @@ module ActionDispatch
|
|
4
4
|
module SystemTesting
|
5
5
|
module TestHelpers
|
6
6
|
module SetupAndTeardown # :nodoc:
|
7
|
-
DEFAULT_HOST = "http://127.0.0.1"
|
8
|
-
|
9
7
|
def host!(host)
|
10
|
-
|
11
|
-
|
8
|
+
ActiveSupport::Deprecation.warn \
|
9
|
+
"ActionDispatch::SystemTestCase#host! is deprecated with no replacement. " \
|
10
|
+
"Set Capybara.app_host directly or rely on Capybara's default host."
|
12
11
|
|
13
|
-
|
14
|
-
host! DEFAULT_HOST
|
15
|
-
super
|
12
|
+
Capybara.app_host = host
|
16
13
|
end
|
17
14
|
|
18
15
|
def before_teardown
|
@@ -31,15 +31,13 @@ module ActionDispatch
|
|
31
31
|
message ||= generate_response_message(type)
|
32
32
|
|
33
33
|
if RESPONSE_PREDICATES.keys.include?(type)
|
34
|
-
assert @response.
|
34
|
+
assert @response.public_send(RESPONSE_PREDICATES[type]), message
|
35
35
|
else
|
36
36
|
assert_equal AssertionResponse.new(type).code, @response.response_code, message
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
# Asserts that the
|
41
|
-
# This match can be partial, such that <tt>assert_redirected_to(controller: "weblog")</tt> will also
|
42
|
-
# match the redirection of <tt>redirect_to(controller: "weblog", action: "show")</tt> and so on.
|
40
|
+
# Asserts that the response is a redirect to a URL matching the given options.
|
43
41
|
#
|
44
42
|
# # Asserts that the redirection was to the "index" action on the WeblogController
|
45
43
|
# assert_redirected_to controller: "weblog", action: "index"
|
@@ -89,9 +89,8 @@ module ActionDispatch
|
|
89
89
|
expected_path = uri.path.to_s.empty? ? "/" : uri.path
|
90
90
|
end
|
91
91
|
else
|
92
|
-
expected_path = "/#{expected_path}" unless expected_path.
|
92
|
+
expected_path = "/#{expected_path}" unless expected_path.start_with?("/")
|
93
93
|
end
|
94
|
-
# Load routes.rb if it hasn't been loaded.
|
95
94
|
|
96
95
|
options = options.clone
|
97
96
|
generated_path, query_string_keys = @routes.generate_extras(options, defaults)
|
@@ -183,7 +182,7 @@ module ActionDispatch
|
|
183
182
|
# ROUTES TODO: These assertions should really work in an integration context
|
184
183
|
def method_missing(selector, *args, &block)
|
185
184
|
if defined?(@controller) && @controller && defined?(@routes) && @routes && @routes.named_routes.route_defined?(selector)
|
186
|
-
@controller.
|
185
|
+
@controller.public_send(selector, *args, &block)
|
187
186
|
else
|
188
187
|
super
|
189
188
|
end
|
@@ -199,7 +198,8 @@ module ActionDispatch
|
|
199
198
|
method = :get
|
200
199
|
end
|
201
200
|
|
202
|
-
|
201
|
+
controller = @controller if defined?(@controller)
|
202
|
+
request = ActionController::TestRequest.create controller&.class
|
203
203
|
|
204
204
|
if %r{://}.match?(path)
|
205
205
|
fail_on(URI::InvalidURIError, msg) do
|
@@ -210,7 +210,7 @@ module ActionDispatch
|
|
210
210
|
request.path = uri.path.to_s.empty? ? "/" : uri.path
|
211
211
|
end
|
212
212
|
else
|
213
|
-
path = "/#{path}" unless path.
|
213
|
+
path = "/#{path}" unless path.start_with?("/")
|
214
214
|
request.path = path
|
215
215
|
end
|
216
216
|
|
@@ -14,7 +14,7 @@ module ActionDispatch
|
|
14
14
|
include Rails::Dom::Testing::Assertions
|
15
15
|
|
16
16
|
def html_document
|
17
|
-
@html_document ||= if @response.media_type
|
17
|
+
@html_document ||= if @response.media_type&.end_with?("xml")
|
18
18
|
Nokogiri::XML::Document.parse(@response.body)
|
19
19
|
else
|
20
20
|
Nokogiri::HTML::Document.parse(@response.body)
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require "stringio"
|
4
4
|
require "uri"
|
5
|
-
require "active_support/core_ext/kernel/singleton_class"
|
6
|
-
require "active_support/core_ext/object/try"
|
7
5
|
require "rack/test"
|
8
6
|
require "minitest"
|
9
7
|
|
@@ -48,13 +46,29 @@ module ActionDispatch
|
|
48
46
|
process(:head, path, **args)
|
49
47
|
end
|
50
48
|
|
49
|
+
# Performs an OPTIONS request with the given parameters. See ActionDispatch::Integration::Session#process
|
50
|
+
# for more details.
|
51
|
+
def options(path, **args)
|
52
|
+
process(:options, path, **args)
|
53
|
+
end
|
54
|
+
|
51
55
|
# Follow a single redirect response. If the last response was not a
|
52
56
|
# redirect, an exception will be raised. Otherwise, the redirect is
|
53
|
-
# performed on the location header.
|
54
|
-
#
|
57
|
+
# performed on the location header. If the redirection is a 307 or 308 redirect,
|
58
|
+
# the same HTTP verb will be used when redirecting, otherwise a GET request
|
59
|
+
# will be performed. Any arguments are passed to the
|
60
|
+
# underlying request.
|
55
61
|
def follow_redirect!(**args)
|
56
62
|
raise "not a redirect! #{status} #{status_message}" unless redirect?
|
57
|
-
|
63
|
+
|
64
|
+
method =
|
65
|
+
if [307, 308].include?(response.status)
|
66
|
+
request.method.downcase
|
67
|
+
else
|
68
|
+
:get
|
69
|
+
end
|
70
|
+
|
71
|
+
public_send(method, response.location, **args)
|
58
72
|
status
|
59
73
|
end
|
60
74
|
end
|
@@ -73,13 +87,8 @@ module ActionDispatch
|
|
73
87
|
include Minitest::Assertions
|
74
88
|
include TestProcess, RequestHelpers, Assertions
|
75
89
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
%w( path ).each do |method|
|
81
|
-
delegate method, to: :request, allow_nil: true
|
82
|
-
end
|
90
|
+
delegate :status, :status_message, :headers, :body, :redirect?, to: :response, allow_nil: true
|
91
|
+
delegate :path, to: :request, allow_nil: true
|
83
92
|
|
84
93
|
# The hostname used in the last request.
|
85
94
|
def host
|
@@ -123,7 +132,7 @@ module ActionDispatch
|
|
123
132
|
|
124
133
|
def url_options
|
125
134
|
@url_options ||= default_url_options.dup.tap do |url_options|
|
126
|
-
url_options.reverse_merge!(controller.url_options) if controller
|
135
|
+
url_options.reverse_merge!(controller.url_options) if controller.respond_to?(:url_options)
|
127
136
|
|
128
137
|
if @app.respond_to?(:routes)
|
129
138
|
url_options.reverse_merge!(@app.routes.default_url_options)
|
@@ -349,20 +358,22 @@ module ActionDispatch
|
|
349
358
|
end
|
350
359
|
|
351
360
|
%w(get post patch put head delete cookies assigns follow_redirect!).each do |method|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
end
|
361
|
+
# reset the html_document variable, except for cookies/assigns calls
|
362
|
+
unless method == "cookies" || method == "assigns"
|
363
|
+
reset_html_document = "@html_document = nil"
|
364
|
+
end
|
357
365
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
366
|
+
definition = RUBY_VERSION >= "2.7" ? "..." : "*args"
|
367
|
+
|
368
|
+
module_eval <<~RUBY, __FILE__, __LINE__ + 1
|
369
|
+
def #{method}(#{definition})
|
370
|
+
#{reset_html_document}
|
371
|
+
|
372
|
+
result = integration_session.#{method}(#{definition})
|
373
|
+
copy_session_variables!
|
374
|
+
result
|
362
375
|
end
|
363
|
-
|
364
|
-
result
|
365
|
-
end
|
376
|
+
RUBY
|
366
377
|
end
|
367
378
|
|
368
379
|
# Open a new session instance. If a block is given, the new session is
|
@@ -506,7 +517,7 @@ module ActionDispatch
|
|
506
517
|
#
|
507
518
|
# A simple integration test that exercises multiple controllers:
|
508
519
|
#
|
509
|
-
# require
|
520
|
+
# require "test_helper"
|
510
521
|
#
|
511
522
|
# class UserFlowsTest < ActionDispatch::IntegrationTest
|
512
523
|
# test "login and browse site" do
|
@@ -535,7 +546,7 @@ module ActionDispatch
|
|
535
546
|
#
|
536
547
|
# Here's an example of multiple sessions and custom DSL in an integration test
|
537
548
|
#
|
538
|
-
# require
|
549
|
+
# require "test_helper"
|
539
550
|
#
|
540
551
|
# class UserFlowsTest < ActionDispatch::IntegrationTest
|
541
552
|
# test "login and browse site" do
|
@@ -6,19 +6,44 @@ require "action_dispatch/middleware/flash"
|
|
6
6
|
module ActionDispatch
|
7
7
|
module TestProcess
|
8
8
|
module FixtureFile
|
9
|
-
# Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.
|
9
|
+
# Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_fixture_path, path), type)</tt>:
|
10
10
|
#
|
11
|
-
# post :change_avatar, params: { avatar: fixture_file_upload('
|
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>.
|
12
14
|
#
|
13
15
|
# To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
|
14
16
|
# This will not affect other platforms:
|
15
17
|
#
|
16
|
-
# post :change_avatar, params: { avatar: fixture_file_upload('
|
18
|
+
# post :change_avatar, params: { avatar: fixture_file_upload('spongebob.png', 'image/png', :binary) }
|
17
19
|
def fixture_file_upload(path, mime_type = nil, binary = false)
|
18
20
|
if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
|
19
21
|
!File.exist?(path)
|
20
|
-
|
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 = path.relative_path_from(Pathname(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)
|
21
45
|
end
|
46
|
+
|
22
47
|
Rack::Test::UploadedFile.new(path, mime_type, binary)
|
23
48
|
end
|
24
49
|
end
|
@@ -6,9 +6,9 @@ require "rack/utils"
|
|
6
6
|
module ActionDispatch
|
7
7
|
class TestRequest < Request
|
8
8
|
DEFAULT_ENV = Rack::MockRequest.env_for("/",
|
9
|
-
"HTTP_HOST" => "test.host",
|
10
|
-
"REMOTE_ADDR" => "0.0.0.0",
|
11
|
-
"HTTP_USER_AGENT" => "Rails Testing",
|
9
|
+
"HTTP_HOST" => "test.host".b,
|
10
|
+
"REMOTE_ADDR" => "0.0.0.0".b,
|
11
|
+
"HTTP_USER_AGENT" => "Rails Testing".b,
|
12
12
|
)
|
13
13
|
|
14
14
|
# Create a new test request with default +env+ values.
|
data/lib/action_dispatch.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2020 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
@@ -46,6 +46,7 @@ module ActionDispatch
|
|
46
46
|
eager_autoload do
|
47
47
|
autoload_under "http" do
|
48
48
|
autoload :ContentSecurityPolicy
|
49
|
+
autoload :FeaturePolicy
|
49
50
|
autoload :Request
|
50
51
|
autoload :Response
|
51
52
|
end
|
@@ -82,7 +83,6 @@ module ActionDispatch
|
|
82
83
|
autoload :Headers
|
83
84
|
autoload :MimeNegotiation
|
84
85
|
autoload :Parameters
|
85
|
-
autoload :ParameterFilter
|
86
86
|
autoload :UploadedFile, "action_dispatch/http/upload"
|
87
87
|
autoload :URL
|
88
88
|
end
|
@@ -115,4 +115,5 @@ autoload :Mime, "action_dispatch/http/mime_type"
|
|
115
115
|
ActiveSupport.on_load(:action_view) do
|
116
116
|
ActionView::Base.default_formats ||= Mime::SET.symbols
|
117
117
|
ActionView::Template::Types.delegate_to Mime
|
118
|
+
ActionView::LookupContext::DetailsKey.clear
|
118
119
|
end
|
data/lib/action_pack.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2020 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|