actionpack 5.2.4.4 → 6.1.1

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.

Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +264 -322
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/abstract_controller.rb +1 -0
  6. data/lib/abstract_controller/base.rb +38 -4
  7. data/lib/abstract_controller/caching.rb +1 -1
  8. data/lib/abstract_controller/caching/fragments.rb +6 -22
  9. data/lib/abstract_controller/callbacks.rb +14 -2
  10. data/lib/abstract_controller/collector.rb +1 -2
  11. data/lib/abstract_controller/helpers.rb +106 -90
  12. data/lib/abstract_controller/railties/routes_helpers.rb +1 -1
  13. data/lib/abstract_controller/rendering.rb +9 -9
  14. data/lib/abstract_controller/translation.rb +11 -5
  15. data/lib/action_controller.rb +7 -4
  16. data/lib/action_controller/api.rb +4 -3
  17. data/lib/action_controller/base.rb +6 -9
  18. data/lib/action_controller/caching.rb +1 -3
  19. data/lib/action_controller/log_subscriber.rb +10 -7
  20. data/lib/action_controller/metal.rb +10 -8
  21. data/lib/action_controller/metal/basic_implicit_render.rb +1 -1
  22. data/lib/action_controller/metal/conditional_get.rb +19 -5
  23. data/lib/action_controller/metal/content_security_policy.rb +1 -2
  24. data/lib/action_controller/metal/cookies.rb +3 -1
  25. data/lib/action_controller/metal/data_streaming.rb +6 -7
  26. data/lib/action_controller/metal/default_headers.rb +17 -0
  27. data/lib/action_controller/metal/etag_with_template_digest.rb +3 -5
  28. data/lib/action_controller/metal/exceptions.rb +56 -2
  29. data/lib/action_controller/metal/flash.rb +5 -5
  30. data/lib/action_controller/metal/head.rb +7 -4
  31. data/lib/action_controller/metal/helpers.rb +14 -5
  32. data/lib/action_controller/metal/http_authentication.rb +24 -23
  33. data/lib/action_controller/metal/implicit_render.rb +5 -15
  34. data/lib/action_controller/metal/instrumentation.rb +13 -14
  35. data/lib/action_controller/metal/live.rb +30 -32
  36. data/lib/action_controller/metal/logging.rb +20 -0
  37. data/lib/action_controller/metal/mime_responds.rb +19 -4
  38. data/lib/action_controller/metal/parameter_encoding.rb +35 -4
  39. data/lib/action_controller/metal/params_wrapper.rb +31 -22
  40. data/lib/action_controller/metal/permissions_policy.rb +46 -0
  41. data/lib/action_controller/metal/redirecting.rb +6 -6
  42. data/lib/action_controller/metal/renderers.rb +4 -4
  43. data/lib/action_controller/metal/rendering.rb +8 -3
  44. data/lib/action_controller/metal/request_forgery_protection.rb +62 -34
  45. data/lib/action_controller/metal/rescue.rb +1 -1
  46. data/lib/action_controller/metal/streaming.rb +0 -1
  47. data/lib/action_controller/metal/strong_parameters.rb +167 -58
  48. data/lib/action_controller/metal/url_for.rb +1 -1
  49. data/lib/action_controller/railties/helpers.rb +1 -1
  50. data/lib/action_controller/renderer.rb +37 -13
  51. data/lib/action_controller/template_assertions.rb +1 -1
  52. data/lib/action_controller/test_case.rb +70 -65
  53. data/lib/action_dispatch.rb +9 -3
  54. data/lib/action_dispatch/http/cache.rb +26 -21
  55. data/lib/action_dispatch/http/content_disposition.rb +45 -0
  56. data/lib/action_dispatch/http/content_security_policy.rb +33 -19
  57. data/lib/action_dispatch/http/filter_parameters.rb +9 -8
  58. data/lib/action_dispatch/http/filter_redirect.rb +2 -3
  59. data/lib/action_dispatch/http/headers.rb +4 -4
  60. data/lib/action_dispatch/http/mime_negotiation.rb +26 -13
  61. data/lib/action_dispatch/http/mime_type.rb +42 -23
  62. data/lib/action_dispatch/http/parameters.rb +14 -23
  63. data/lib/action_dispatch/http/permissions_policy.rb +173 -0
  64. data/lib/action_dispatch/http/request.rb +45 -22
  65. data/lib/action_dispatch/http/response.rb +45 -25
  66. data/lib/action_dispatch/http/upload.rb +9 -1
  67. data/lib/action_dispatch/http/url.rb +82 -82
  68. data/lib/action_dispatch/journey.rb +0 -2
  69. data/lib/action_dispatch/journey/formatter.rb +54 -30
  70. data/lib/action_dispatch/journey/gtg/builder.rb +22 -37
  71. data/lib/action_dispatch/journey/gtg/simulator.rb +8 -7
  72. data/lib/action_dispatch/journey/gtg/transition_table.rb +6 -5
  73. data/lib/action_dispatch/journey/nfa/dot.rb +0 -11
  74. data/lib/action_dispatch/journey/nodes/node.rb +13 -11
  75. data/lib/action_dispatch/journey/parser.rb +13 -13
  76. data/lib/action_dispatch/journey/parser.y +1 -1
  77. data/lib/action_dispatch/journey/path/pattern.rb +19 -21
  78. data/lib/action_dispatch/journey/route.rb +10 -20
  79. data/lib/action_dispatch/journey/router.rb +26 -34
  80. data/lib/action_dispatch/journey/router/utils.rb +14 -12
  81. data/lib/action_dispatch/journey/routes.rb +0 -2
  82. data/lib/action_dispatch/journey/scanner.rb +10 -4
  83. data/lib/action_dispatch/journey/visitors.rb +1 -4
  84. data/lib/action_dispatch/middleware/actionable_exceptions.rb +46 -0
  85. data/lib/action_dispatch/middleware/callbacks.rb +2 -4
  86. data/lib/action_dispatch/middleware/cookies.rb +128 -109
  87. data/lib/action_dispatch/middleware/debug_exceptions.rb +43 -66
  88. data/lib/action_dispatch/middleware/debug_locks.rb +5 -5
  89. data/lib/action_dispatch/middleware/debug_view.rb +66 -0
  90. data/lib/action_dispatch/middleware/exception_wrapper.rb +75 -30
  91. data/lib/action_dispatch/middleware/flash.rb +1 -1
  92. data/lib/action_dispatch/middleware/host_authorization.rb +121 -0
  93. data/lib/action_dispatch/middleware/public_exceptions.rb +6 -3
  94. data/lib/action_dispatch/middleware/remote_ip.rb +14 -16
  95. data/lib/action_dispatch/middleware/request_id.rb +5 -6
  96. data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -3
  97. data/lib/action_dispatch/middleware/session/cookie_store.rb +3 -9
  98. data/lib/action_dispatch/middleware/show_exceptions.rb +3 -2
  99. data/lib/action_dispatch/middleware/ssl.rb +20 -15
  100. data/lib/action_dispatch/middleware/stack.rb +56 -2
  101. data/lib/action_dispatch/middleware/static.rb +153 -93
  102. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
  103. data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
  104. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +22 -0
  105. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +3 -1
  106. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +1 -1
  107. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +4 -2
  108. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +45 -35
  109. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
  110. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
  111. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +23 -4
  112. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +1 -1
  113. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +6 -3
  114. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +3 -1
  115. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +104 -8
  116. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
  117. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
  118. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +2 -2
  119. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -1
  120. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +2 -2
  121. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
  122. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +24 -1
  123. data/lib/action_dispatch/railtie.rb +8 -2
  124. data/lib/action_dispatch/request/session.rb +10 -9
  125. data/lib/action_dispatch/request/utils.rb +26 -2
  126. data/lib/action_dispatch/routing.rb +21 -20
  127. data/lib/action_dispatch/routing/inspector.rb +100 -52
  128. data/lib/action_dispatch/routing/mapper.rb +155 -103
  129. data/lib/action_dispatch/routing/polymorphic_routes.rb +13 -15
  130. data/lib/action_dispatch/routing/redirection.rb +3 -3
  131. data/lib/action_dispatch/routing/route_set.rb +71 -69
  132. data/lib/action_dispatch/routing/url_for.rb +2 -2
  133. data/lib/action_dispatch/system_test_case.rb +54 -11
  134. data/lib/action_dispatch/system_testing/browser.rb +53 -16
  135. data/lib/action_dispatch/system_testing/driver.rb +11 -3
  136. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +49 -7
  137. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +8 -10
  138. data/lib/action_dispatch/testing/assertion_response.rb +0 -1
  139. data/lib/action_dispatch/testing/assertions.rb +1 -1
  140. data/lib/action_dispatch/testing/assertions/response.rb +4 -7
  141. data/lib/action_dispatch/testing/assertions/routing.rb +20 -8
  142. data/lib/action_dispatch/testing/integration.rb +61 -28
  143. data/lib/action_dispatch/testing/request_encoder.rb +2 -2
  144. data/lib/action_dispatch/testing/test_process.rb +29 -4
  145. data/lib/action_dispatch/testing/test_request.rb +3 -3
  146. data/lib/action_dispatch/testing/test_response.rb +4 -32
  147. data/lib/action_pack.rb +1 -1
  148. data/lib/action_pack/gem_version.rb +4 -4
  149. metadata +38 -26
  150. data/lib/action_controller/metal/force_ssl.rb +0 -99
  151. data/lib/action_dispatch/http/parameter_filter.rb +0 -86
  152. data/lib/action_dispatch/journey/nfa/builder.rb +0 -78
  153. data/lib/action_dispatch/journey/nfa/simulator.rb +0 -49
  154. data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -120
  155. data/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +0 -26
@@ -9,6 +9,11 @@ module ActionDispatch
9
9
  module Assertions
10
10
  # Suite of assertions to test routes generated by \Rails and the handling of requests made to them.
11
11
  module RoutingAssertions
12
+ def setup # :nodoc:
13
+ @routes ||= nil
14
+ super
15
+ end
16
+
12
17
  # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
13
18
  # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
14
19
  #
@@ -78,15 +83,14 @@ module ActionDispatch
78
83
  # # Asserts that the generated route gives us our custom route
79
84
  # assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" }
80
85
  def assert_generates(expected_path, options, defaults = {}, extras = {}, message = nil)
81
- if expected_path =~ %r{://}
86
+ if %r{://}.match?(expected_path)
82
87
  fail_on(URI::InvalidURIError, message) do
83
88
  uri = URI.parse(expected_path)
84
89
  expected_path = uri.path.to_s.empty? ? "/" : uri.path
85
90
  end
86
91
  else
87
- expected_path = "/#{expected_path}" unless expected_path.first == "/"
92
+ expected_path = "/#{expected_path}" unless expected_path.start_with?("/")
88
93
  end
89
- # Load routes.rb if it hasn't been loaded.
90
94
 
91
95
  options = options.clone
92
96
  generated_path, query_string_keys = @routes.generate_extras(options, defaults)
@@ -155,9 +159,16 @@ module ActionDispatch
155
159
  @controller.singleton_class.include(_routes.url_helpers)
156
160
 
157
161
  if @controller.respond_to? :view_context_class
158
- @controller.view_context_class = Class.new(@controller.view_context_class) do
162
+ view_context_class = Class.new(@controller.view_context_class) do
159
163
  include _routes.url_helpers
160
164
  end
165
+
166
+ custom_view_context = Module.new {
167
+ define_method(:view_context_class) do
168
+ view_context_class
169
+ end
170
+ }
171
+ @controller.extend(custom_view_context)
161
172
  end
162
173
  end
163
174
  yield @routes
@@ -171,7 +182,7 @@ module ActionDispatch
171
182
  # ROUTES TODO: These assertions should really work in an integration context
172
183
  def method_missing(selector, *args, &block)
173
184
  if defined?(@controller) && @controller && defined?(@routes) && @routes && @routes.named_routes.route_defined?(selector)
174
- @controller.send(selector, *args, &block)
185
+ @controller.public_send(selector, *args, &block)
175
186
  else
176
187
  super
177
188
  end
@@ -187,9 +198,10 @@ module ActionDispatch
187
198
  method = :get
188
199
  end
189
200
 
190
- request = ActionController::TestRequest.create @controller.class
201
+ controller = @controller if defined?(@controller)
202
+ request = ActionController::TestRequest.create controller&.class
191
203
 
192
- if path =~ %r{://}
204
+ if %r{://}.match?(path)
193
205
  fail_on(URI::InvalidURIError, msg) do
194
206
  uri = URI.parse(path)
195
207
  request.env["rack.url_scheme"] = uri.scheme || "http"
@@ -198,7 +210,7 @@ module ActionDispatch
198
210
  request.path = uri.path.to_s.empty? ? "/" : uri.path
199
211
  end
200
212
  else
201
- path = "/#{path}" unless path.first == "/"
213
+ path = "/#{path}" unless path.start_with?("/")
202
214
  request.path = path
203
215
  end
204
216
 
@@ -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
 
@@ -44,16 +42,33 @@ module ActionDispatch
44
42
 
45
43
  # Performs a HEAD request with the given parameters. See ActionDispatch::Integration::Session#process
46
44
  # for more details.
47
- def head(path, *args)
48
- process(:head, path, *args)
45
+ def head(path, **args)
46
+ process(:head, path, **args)
47
+ end
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)
49
53
  end
50
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
- def follow_redirect!
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.
61
+ def follow_redirect!(**args)
55
62
  raise "not a redirect! #{status} #{status_message}" unless redirect?
56
- get(response.location)
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)
57
72
  status
58
73
  end
59
74
  end
@@ -72,13 +87,8 @@ module ActionDispatch
72
87
  include Minitest::Assertions
73
88
  include TestProcess, RequestHelpers, Assertions
74
89
 
75
- %w( status status_message headers body redirect? ).each do |method|
76
- delegate method, to: :response, allow_nil: true
77
- end
78
-
79
- %w( path ).each do |method|
80
- delegate method, to: :request, allow_nil: true
81
- end
90
+ delegate :status, :status_message, :headers, :body, :redirect?, to: :response, allow_nil: true
91
+ delegate :path, to: :request, allow_nil: true
82
92
 
83
93
  # The hostname used in the last request.
84
94
  def host
@@ -122,7 +132,7 @@ module ActionDispatch
122
132
 
123
133
  def url_options
124
134
  @url_options ||= default_url_options.dup.tap do |url_options|
125
- url_options.reverse_merge!(controller.url_options) if controller
135
+ url_options.reverse_merge!(controller.url_options) if controller.respond_to?(:url_options)
126
136
 
127
137
  if @app.respond_to?(:routes)
128
138
  url_options.reverse_merge!(@app.routes.default_url_options)
@@ -189,6 +199,12 @@ module ActionDispatch
189
199
  # merged into the Rack env hash.
190
200
  # - +env+: Additional env to pass, as a Hash. The headers will be
191
201
  # merged into the Rack env hash.
202
+ # - +xhr+: Set to `true` if you want to make and Ajax request.
203
+ # Adds request headers characteristic of XMLHttpRequest e.g. HTTP_X_REQUESTED_WITH.
204
+ # The headers will be merged into the Rack env hash.
205
+ # - +as+: Used for encoding the request with different content type.
206
+ # Supports `:json` by default and will set the appropriate request headers.
207
+ # The headers will be merged into the Rack env hash.
192
208
  #
193
209
  # This method is rarely used directly. Use +#get+, +#post+, or other standard
194
210
  # HTTP methods in integration tests. +#process+ is only required when using a
@@ -210,7 +226,7 @@ module ActionDispatch
210
226
  method = :post
211
227
  end
212
228
 
213
- if path =~ %r{://}
229
+ if %r{://}.match?(path)
214
230
  path = build_expanded_path(path) do |location|
215
231
  https! URI::HTTPS === location if location.scheme
216
232
 
@@ -303,6 +319,7 @@ module ActionDispatch
303
319
  APP_SESSIONS = {}
304
320
 
305
321
  attr_reader :app
322
+ attr_accessor :root_session # :nodoc:
306
323
 
307
324
  def initialize(*args, &blk)
308
325
  super(*args, &blk)
@@ -328,7 +345,7 @@ module ActionDispatch
328
345
  klass = APP_SESSIONS[app] ||= Class.new(Integration::Session) {
329
346
  # If the app is a Rails app, make url_helpers available on the session.
330
347
  # This makes app.url_for and app.foo_path available in the console.
331
- if app.respond_to?(:routes)
348
+ if app.respond_to?(:routes) && app.routes.is_a?(ActionDispatch::Routing::RouteSet)
332
349
  include app.routes.url_helpers
333
350
  include app.routes.mounted_helpers
334
351
  end
@@ -341,16 +358,22 @@ module ActionDispatch
341
358
  end
342
359
 
343
360
  %w(get post patch put head delete cookies assigns follow_redirect!).each do |method|
344
- define_method(method) do |*args|
345
- # reset the html_document variable, except for cookies/assigns calls
346
- unless method == "cookies" || method == "assigns"
347
- @html_document = nil
348
- 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
365
+
366
+ definition = RUBY_VERSION >= "2.7" ? "..." : "*args"
367
+
368
+ module_eval <<~RUBY, __FILE__, __LINE__ + 1
369
+ def #{method}(#{definition})
370
+ #{reset_html_document}
349
371
 
350
- integration_session.__send__(method, *args).tap do
372
+ result = integration_session.#{method}(#{definition})
351
373
  copy_session_variables!
374
+ result
352
375
  end
353
- end
376
+ RUBY
354
377
  end
355
378
 
356
379
  # Open a new session instance. If a block is given, the new session is
@@ -366,10 +389,19 @@ module ActionDispatch
366
389
  def open_session
367
390
  dup.tap do |session|
368
391
  session.reset!
392
+ session.root_session = self.root_session || self
369
393
  yield session if block_given?
370
394
  end
371
395
  end
372
396
 
397
+ def assertions # :nodoc:
398
+ root_session ? root_session.assertions : super
399
+ end
400
+
401
+ def assertions=(assertions) # :nodoc:
402
+ root_session ? root_session.assertions = assertions : super
403
+ end
404
+
373
405
  # Copy the instance variables from the current session instance into the
374
406
  # test instance.
375
407
  def copy_session_variables! #:nodoc:
@@ -401,6 +433,7 @@ module ActionDispatch
401
433
  super
402
434
  end
403
435
  end
436
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
404
437
  end
405
438
  end
406
439
 
@@ -484,7 +517,7 @@ module ActionDispatch
484
517
  #
485
518
  # A simple integration test that exercises multiple controllers:
486
519
  #
487
- # require 'test_helper'
520
+ # require "test_helper"
488
521
  #
489
522
  # class UserFlowsTest < ActionDispatch::IntegrationTest
490
523
  # test "login and browse site" do
@@ -513,7 +546,7 @@ module ActionDispatch
513
546
  #
514
547
  # Here's an example of multiple sessions and custom DSL in an integration test
515
548
  #
516
- # require 'test_helper'
549
+ # require "test_helper"
517
550
  #
518
551
  # class UserFlowsTest < ActionDispatch::IntegrationTest
519
552
  # test "login and browse site" do
@@ -633,8 +666,8 @@ module ActionDispatch
633
666
  @@app = app
634
667
  end
635
668
 
636
- def register_encoder(*args)
637
- RequestEncoder.register_encoder(*args)
669
+ def register_encoder(*args, **options)
670
+ RequestEncoder.register_encoder(*args, **options)
638
671
  end
639
672
  end
640
673
 
@@ -38,8 +38,8 @@ module ActionDispatch
38
38
  end
39
39
 
40
40
  def self.parser(content_type)
41
- mime = Mime::Type.lookup(content_type)
42
- encoder(mime ? mime.ref : nil).response_parser
41
+ type = Mime::Type.lookup(content_type).ref if content_type
42
+ encoder(type).response_parser
43
43
  end
44
44
 
45
45
  def self.encoder(name)
@@ -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.fixture_path, path), type)</tt>:
9
+ # Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.file_fixture_path, path), type)</tt>:
10
10
  #
11
- # post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png')
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, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary)
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
- path = File.join(self.class.fixture_path, 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 = 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.
@@ -14,40 +14,12 @@ module ActionDispatch
14
14
  new response.status, response.headers, response.body
15
15
  end
16
16
 
17
- def initialize(*) # :nodoc:
18
- super
19
- @response_parser = RequestEncoder.parser(content_type)
20
- end
21
-
22
- # Was the response successful?
23
- def success?
24
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
25
- The success? predicate is deprecated and will be removed in Rails 6.0.
26
- Please use successful? as provided by Rack::Response::Helpers.
27
- MSG
28
- successful?
29
- end
30
-
31
- # Was the URL not found?
32
- def missing?
33
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
34
- The missing? predicate is deprecated and will be removed in Rails 6.0.
35
- Please use not_found? as provided by Rack::Response::Helpers.
36
- MSG
37
- not_found?
38
- end
39
-
40
- # Was there a server-side error?
41
- def error?
42
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
43
- The error? predicate is deprecated and will be removed in Rails 6.0.
44
- Please use server_error? as provided by Rack::Response::Helpers.
45
- MSG
46
- server_error?
17
+ def parsed_body
18
+ @parsed_body ||= response_parser.call(body)
47
19
  end
48
20
 
49
- def parsed_body
50
- @parsed_body ||= @response_parser.call(body)
21
+ def response_parser
22
+ @response_parser ||= RequestEncoder.parser(media_type)
51
23
  end
52
24
  end
53
25
  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-2018 David Heinemeier Hansson
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
@@ -7,10 +7,10 @@ module ActionPack
7
7
  end
8
8
 
9
9
  module VERSION
10
- MAJOR = 5
11
- MINOR = 2
12
- TINY = 4
13
- PRE = "4"
10
+ MAJOR = 6
11
+ MINOR = 1
12
+ TINY = 1
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.4.4
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.4.4
19
+ version: 6.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.4.4
26
+ version: 6.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '2.0'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 2.0.8
36
+ version: 2.0.9
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.0'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.8
46
+ version: 2.0.9
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '1.0'
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 1.0.2
70
+ version: 1.2.0
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '1.0'
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 1.0.2
80
+ version: 1.2.0
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rails-dom-testing
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 5.2.4.4
101
+ version: 6.1.1
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 5.2.4.4
108
+ version: 6.1.1
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 5.2.4.4
115
+ version: 6.1.1
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 5.2.4.4
122
+ version: 6.1.1
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -157,20 +157,22 @@ files:
157
157
  - lib/action_controller/metal/content_security_policy.rb
158
158
  - lib/action_controller/metal/cookies.rb
159
159
  - lib/action_controller/metal/data_streaming.rb
160
+ - lib/action_controller/metal/default_headers.rb
160
161
  - lib/action_controller/metal/etag_with_flash.rb
161
162
  - lib/action_controller/metal/etag_with_template_digest.rb
162
163
  - lib/action_controller/metal/exceptions.rb
163
164
  - lib/action_controller/metal/flash.rb
164
- - lib/action_controller/metal/force_ssl.rb
165
165
  - lib/action_controller/metal/head.rb
166
166
  - lib/action_controller/metal/helpers.rb
167
167
  - lib/action_controller/metal/http_authentication.rb
168
168
  - lib/action_controller/metal/implicit_render.rb
169
169
  - lib/action_controller/metal/instrumentation.rb
170
170
  - lib/action_controller/metal/live.rb
171
+ - lib/action_controller/metal/logging.rb
171
172
  - lib/action_controller/metal/mime_responds.rb
172
173
  - lib/action_controller/metal/parameter_encoding.rb
173
174
  - lib/action_controller/metal/params_wrapper.rb
175
+ - lib/action_controller/metal/permissions_policy.rb
174
176
  - lib/action_controller/metal/redirecting.rb
175
177
  - lib/action_controller/metal/renderers.rb
176
178
  - lib/action_controller/metal/rendering.rb
@@ -187,6 +189,7 @@ files:
187
189
  - lib/action_controller/test_case.rb
188
190
  - lib/action_dispatch.rb
189
191
  - lib/action_dispatch/http/cache.rb
192
+ - lib/action_dispatch/http/content_disposition.rb
190
193
  - lib/action_dispatch/http/content_security_policy.rb
191
194
  - lib/action_dispatch/http/filter_parameters.rb
192
195
  - lib/action_dispatch/http/filter_redirect.rb
@@ -194,8 +197,8 @@ files:
194
197
  - lib/action_dispatch/http/mime_negotiation.rb
195
198
  - lib/action_dispatch/http/mime_type.rb
196
199
  - lib/action_dispatch/http/mime_types.rb
197
- - lib/action_dispatch/http/parameter_filter.rb
198
200
  - lib/action_dispatch/http/parameters.rb
201
+ - lib/action_dispatch/http/permissions_policy.rb
199
202
  - lib/action_dispatch/http/rack_cache.rb
200
203
  - lib/action_dispatch/http/request.rb
201
204
  - lib/action_dispatch/http/response.rb
@@ -206,10 +209,7 @@ files:
206
209
  - lib/action_dispatch/journey/gtg/builder.rb
207
210
  - lib/action_dispatch/journey/gtg/simulator.rb
208
211
  - lib/action_dispatch/journey/gtg/transition_table.rb
209
- - lib/action_dispatch/journey/nfa/builder.rb
210
212
  - lib/action_dispatch/journey/nfa/dot.rb
211
- - lib/action_dispatch/journey/nfa/simulator.rb
212
- - lib/action_dispatch/journey/nfa/transition_table.rb
213
213
  - lib/action_dispatch/journey/nodes/node.rb
214
214
  - lib/action_dispatch/journey/parser.rb
215
215
  - lib/action_dispatch/journey/parser.y
@@ -224,13 +224,16 @@ files:
224
224
  - lib/action_dispatch/journey/visualizer/fsm.css
225
225
  - lib/action_dispatch/journey/visualizer/fsm.js
226
226
  - lib/action_dispatch/journey/visualizer/index.html.erb
227
+ - lib/action_dispatch/middleware/actionable_exceptions.rb
227
228
  - lib/action_dispatch/middleware/callbacks.rb
228
229
  - lib/action_dispatch/middleware/cookies.rb
229
230
  - lib/action_dispatch/middleware/debug_exceptions.rb
230
231
  - lib/action_dispatch/middleware/debug_locks.rb
232
+ - lib/action_dispatch/middleware/debug_view.rb
231
233
  - lib/action_dispatch/middleware/exception_wrapper.rb
232
234
  - lib/action_dispatch/middleware/executor.rb
233
235
  - lib/action_dispatch/middleware/flash.rb
236
+ - lib/action_dispatch/middleware/host_authorization.rb
234
237
  - lib/action_dispatch/middleware/public_exceptions.rb
235
238
  - lib/action_dispatch/middleware/reloader.rb
236
239
  - lib/action_dispatch/middleware/remote_ip.rb
@@ -243,17 +246,24 @@ files:
243
246
  - lib/action_dispatch/middleware/ssl.rb
244
247
  - lib/action_dispatch/middleware/stack.rb
245
248
  - lib/action_dispatch/middleware/static.rb
249
+ - lib/action_dispatch/middleware/templates/rescues/_actions.html.erb
250
+ - lib/action_dispatch/middleware/templates/rescues/_actions.text.erb
251
+ - lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb
246
252
  - lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
247
253
  - lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb
248
254
  - lib/action_dispatch/middleware/templates/rescues/_source.html.erb
249
255
  - lib/action_dispatch/middleware/templates/rescues/_source.text.erb
250
256
  - lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
251
257
  - lib/action_dispatch/middleware/templates/rescues/_trace.text.erb
258
+ - lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb
259
+ - lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb
252
260
  - lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb
253
261
  - lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb
254
262
  - lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb
255
263
  - lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb
256
264
  - lib/action_dispatch/middleware/templates/rescues/layout.erb
265
+ - lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb
266
+ - lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb
257
267
  - lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb
258
268
  - lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb
259
269
  - lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb
@@ -282,7 +292,6 @@ files:
282
292
  - lib/action_dispatch/system_testing/server.rb
283
293
  - lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
284
294
  - lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
285
- - lib/action_dispatch/system_testing/test_helpers/undef_methods.rb
286
295
  - lib/action_dispatch/testing/assertion_response.rb
287
296
  - lib/action_dispatch/testing/assertions.rb
288
297
  - lib/action_dispatch/testing/assertions/response.rb
@@ -295,13 +304,16 @@ files:
295
304
  - lib/action_pack.rb
296
305
  - lib/action_pack/gem_version.rb
297
306
  - lib/action_pack/version.rb
298
- homepage: http://rubyonrails.org
307
+ homepage: https://rubyonrails.org
299
308
  licenses:
300
309
  - MIT
301
310
  metadata:
302
- source_code_uri: https://github.com/rails/rails/tree/v5.2.4.4/actionpack
303
- changelog_uri: https://github.com/rails/rails/blob/v5.2.4.4/actionpack/CHANGELOG.md
304
- post_install_message:
311
+ bug_tracker_uri: https://github.com/rails/rails/issues
312
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.1/actionpack/CHANGELOG.md
313
+ documentation_uri: https://api.rubyonrails.org/v6.1.1/
314
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
315
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.1/actionpack
316
+ post_install_message:
305
317
  rdoc_options: []
306
318
  require_paths:
307
319
  - lib
@@ -309,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
309
321
  requirements:
310
322
  - - ">="
311
323
  - !ruby/object:Gem::Version
312
- version: 2.2.2
324
+ version: 2.5.0
313
325
  required_rubygems_version: !ruby/object:Gem::Requirement
314
326
  requirements:
315
327
  - - ">="
@@ -317,8 +329,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
329
  version: '0'
318
330
  requirements:
319
331
  - none
320
- rubygems_version: 3.1.2
321
- signing_key:
332
+ rubygems_version: 3.2.3
333
+ signing_key:
322
334
  specification_version: 4
323
335
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
324
336
  test_files: []