actionpack 5.2.4.5 → 6.0.0.beta1

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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -384
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/abstract_controller/base.rb +4 -2
  6. data/lib/abstract_controller/caching/fragments.rb +6 -21
  7. data/lib/abstract_controller/callbacks.rb +12 -0
  8. data/lib/abstract_controller/collector.rb +1 -1
  9. data/lib/abstract_controller/helpers.rb +2 -2
  10. data/lib/abstract_controller/railties/routes_helpers.rb +1 -1
  11. data/lib/action_controller.rb +1 -0
  12. data/lib/action_controller/api.rb +2 -1
  13. data/lib/action_controller/base.rb +2 -7
  14. data/lib/action_controller/caching.rb +1 -1
  15. data/lib/action_controller/log_subscriber.rb +8 -5
  16. data/lib/action_controller/metal.rb +2 -2
  17. data/lib/action_controller/metal/conditional_get.rb +9 -3
  18. data/lib/action_controller/metal/data_streaming.rb +5 -6
  19. data/lib/action_controller/metal/default_headers.rb +17 -0
  20. data/lib/action_controller/metal/exceptions.rb +22 -1
  21. data/lib/action_controller/metal/flash.rb +5 -5
  22. data/lib/action_controller/metal/force_ssl.rb +17 -57
  23. data/lib/action_controller/metal/head.rb +1 -1
  24. data/lib/action_controller/metal/helpers.rb +1 -2
  25. data/lib/action_controller/metal/http_authentication.rb +20 -21
  26. data/lib/action_controller/metal/implicit_render.rb +2 -12
  27. data/lib/action_controller/metal/instrumentation.rb +3 -5
  28. data/lib/action_controller/metal/live.rb +28 -26
  29. data/lib/action_controller/metal/mime_responds.rb +13 -2
  30. data/lib/action_controller/metal/params_wrapper.rb +18 -14
  31. data/lib/action_controller/metal/redirecting.rb +32 -11
  32. data/lib/action_controller/metal/rendering.rb +1 -1
  33. data/lib/action_controller/metal/request_forgery_protection.rb +26 -40
  34. data/lib/action_controller/metal/strong_parameters.rb +57 -34
  35. data/lib/action_controller/metal/url_for.rb +1 -1
  36. data/lib/action_controller/railties/helpers.rb +1 -1
  37. data/lib/action_controller/renderer.rb +15 -2
  38. data/lib/action_controller/test_case.rb +3 -7
  39. data/lib/action_dispatch.rb +7 -6
  40. data/lib/action_dispatch/http/cache.rb +14 -10
  41. data/lib/action_dispatch/http/content_disposition.rb +45 -0
  42. data/lib/action_dispatch/http/content_security_policy.rb +9 -8
  43. data/lib/action_dispatch/http/filter_parameters.rb +8 -6
  44. data/lib/action_dispatch/http/filter_redirect.rb +1 -1
  45. data/lib/action_dispatch/http/headers.rb +1 -1
  46. data/lib/action_dispatch/http/mime_negotiation.rb +7 -10
  47. data/lib/action_dispatch/http/mime_type.rb +1 -5
  48. data/lib/action_dispatch/http/parameter_filter.rb +5 -79
  49. data/lib/action_dispatch/http/parameters.rb +13 -3
  50. data/lib/action_dispatch/http/request.rb +10 -13
  51. data/lib/action_dispatch/http/response.rb +14 -14
  52. data/lib/action_dispatch/http/upload.rb +5 -0
  53. data/lib/action_dispatch/http/url.rb +81 -81
  54. data/lib/action_dispatch/journey/formatter.rb +1 -1
  55. data/lib/action_dispatch/journey/nfa/simulator.rb +0 -2
  56. data/lib/action_dispatch/journey/nodes/node.rb +9 -8
  57. data/lib/action_dispatch/journey/path/pattern.rb +3 -4
  58. data/lib/action_dispatch/journey/router.rb +0 -3
  59. data/lib/action_dispatch/journey/router/utils.rb +10 -10
  60. data/lib/action_dispatch/journey/scanner.rb +11 -4
  61. data/lib/action_dispatch/journey/visitors.rb +1 -1
  62. data/lib/action_dispatch/middleware/callbacks.rb +2 -4
  63. data/lib/action_dispatch/middleware/cookies.rb +49 -70
  64. data/lib/action_dispatch/middleware/debug_exceptions.rb +32 -58
  65. data/lib/action_dispatch/middleware/debug_locks.rb +5 -5
  66. data/lib/action_dispatch/middleware/debug_view.rb +50 -0
  67. data/lib/action_dispatch/middleware/exception_wrapper.rb +36 -7
  68. data/lib/action_dispatch/middleware/flash.rb +1 -1
  69. data/lib/action_dispatch/middleware/host_authorization.rb +103 -0
  70. data/lib/action_dispatch/middleware/remote_ip.rb +6 -8
  71. data/lib/action_dispatch/middleware/request_id.rb +2 -2
  72. data/lib/action_dispatch/middleware/session/abstract_store.rb +0 -14
  73. data/lib/action_dispatch/middleware/session/cache_store.rb +6 -11
  74. data/lib/action_dispatch/middleware/session/cookie_store.rb +11 -27
  75. data/lib/action_dispatch/middleware/ssl.rb +8 -8
  76. data/lib/action_dispatch/middleware/stack.rb +2 -2
  77. data/lib/action_dispatch/middleware/static.rb +5 -6
  78. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +4 -2
  79. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +45 -35
  80. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
  81. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
  82. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +20 -2
  83. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +4 -4
  84. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +2 -2
  85. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
  86. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
  87. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +2 -2
  88. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -1
  89. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +2 -2
  90. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +3 -0
  91. data/lib/action_dispatch/railtie.rb +1 -0
  92. data/lib/action_dispatch/request/session.rb +8 -6
  93. data/lib/action_dispatch/routing.rb +3 -2
  94. data/lib/action_dispatch/routing/inspector.rb +99 -50
  95. data/lib/action_dispatch/routing/mapper.rb +36 -29
  96. data/lib/action_dispatch/routing/polymorphic_routes.rb +3 -4
  97. data/lib/action_dispatch/routing/route_set.rb +11 -12
  98. data/lib/action_dispatch/routing/url_for.rb +1 -0
  99. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +3 -3
  100. data/lib/action_dispatch/testing/assertions/response.rb +2 -3
  101. data/lib/action_dispatch/testing/assertions/routing.rb +7 -2
  102. data/lib/action_dispatch/testing/integration.rb +11 -4
  103. data/lib/action_dispatch/testing/test_process.rb +2 -2
  104. data/lib/action_dispatch/testing/test_response.rb +4 -32
  105. data/lib/action_pack.rb +1 -1
  106. data/lib/action_pack/gem_version.rb +4 -4
  107. metadata +22 -20
@@ -50,7 +50,19 @@ module ActionDispatch
50
50
 
51
51
  private
52
52
  def constraint_args(constraint, request)
53
- constraint.arity == 1 ? [request] : [request.path_parameters, request]
53
+ arity = if constraint.respond_to?(:arity)
54
+ constraint.arity
55
+ else
56
+ constraint.method(:call).arity
57
+ end
58
+
59
+ if arity < 1
60
+ []
61
+ elsif arity == 1
62
+ [request]
63
+ else
64
+ [request.path_parameters, request]
65
+ end
54
66
  end
55
67
  end
56
68
 
@@ -148,17 +160,8 @@ module ActionDispatch
148
160
  end
149
161
 
150
162
  def make_route(name, precedence)
151
- route = Journey::Route.new(name,
152
- application,
153
- path,
154
- conditions,
155
- required_defaults,
156
- defaults,
157
- request_method,
158
- precedence,
159
- @internal)
160
-
161
- route
163
+ Journey::Route.new(name, application, path, conditions, required_defaults,
164
+ defaults, request_method, precedence, @internal)
162
165
  end
163
166
 
164
167
  def application
@@ -279,7 +282,7 @@ module ActionDispatch
279
282
 
280
283
  def verify_regexp_requirements(requirements)
281
284
  requirements.each do |requirement|
282
- if requirement.source =~ ANCHOR_CHARACTERS_REGEX
285
+ if ANCHOR_CHARACTERS_REGEX.match?(requirement.source)
283
286
  raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
284
287
  end
285
288
 
@@ -308,8 +311,8 @@ module ActionDispatch
308
311
  def check_controller_and_action(path_params, controller, action)
309
312
  hash = check_part(:controller, controller, path_params, {}) do |part|
310
313
  translate_controller(part) {
311
- message = "'#{part}' is not a supported controller name. This can lead to potential routing problems.".dup
312
- message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use"
314
+ message = +"'#{part}' is not a supported controller name. This can lead to potential routing problems."
315
+ message << " See https://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use"
313
316
 
314
317
  raise ArgumentError, message
315
318
  }
@@ -333,7 +336,7 @@ module ActionDispatch
333
336
  end
334
337
 
335
338
  def split_to(to)
336
- if to =~ /#/
339
+ if /#/.match?(to)
337
340
  to.split("#")
338
341
  else
339
342
  []
@@ -342,7 +345,7 @@ module ActionDispatch
342
345
 
343
346
  def add_controller_module(controller, modyoule)
344
347
  if modyoule && !controller.is_a?(Regexp)
345
- if controller =~ %r{\A/}
348
+ if %r{\A/}.match?(controller)
346
349
  controller[1..-1]
347
350
  else
348
351
  [modyoule, controller].compact.join("/")
@@ -553,10 +556,10 @@ module ActionDispatch
553
556
  #
554
557
  # match 'json_only', constraints: { format: 'json' }, via: :get
555
558
  #
556
- # class Whitelist
559
+ # class PermitList
557
560
  # def matches?(request) request.remote_ip == '1.2.3.4' end
558
561
  # end
559
- # match 'path', to: 'c#a', constraints: Whitelist.new, via: :get
562
+ # match 'path', to: 'c#a', constraints: PermitList.new, via: :get
560
563
  #
561
564
  # See <tt>Scoping#constraints</tt> for more examples with its scope
562
565
  # equivalent.
@@ -611,7 +614,7 @@ module ActionDispatch
611
614
  end
612
615
 
613
616
  raise ArgumentError, "A rack application must be specified" unless app.respond_to?(:call)
614
- raise ArgumentError, <<-MSG.strip_heredoc unless path
617
+ raise ArgumentError, <<~MSG unless path
615
618
  Must be called with mount point
616
619
 
617
620
  mount SomeRackApp, at: "some_route"
@@ -644,7 +647,7 @@ module ActionDispatch
644
647
 
645
648
  # Query if the following named route was already defined.
646
649
  def has_named_route?(name)
647
- @set.named_routes.key? name
650
+ @set.named_routes.key?(name)
648
651
  end
649
652
 
650
653
  private
@@ -668,7 +671,7 @@ module ActionDispatch
668
671
 
669
672
  script_namer = ->(options) do
670
673
  prefix_options = options.slice(*_route.segment_keys)
671
- prefix_options[:relative_url_root] = "".freeze
674
+ prefix_options[:relative_url_root] = ""
672
675
 
673
676
  if options[:_recall]
674
677
  prefix_options.reverse_merge!(options[:_recall].slice(*_route.segment_keys))
@@ -1159,10 +1162,16 @@ module ActionDispatch
1159
1162
  end
1160
1163
 
1161
1164
  def actions
1165
+ if @except
1166
+ available_actions - Array(@except).map(&:to_sym)
1167
+ else
1168
+ available_actions
1169
+ end
1170
+ end
1171
+
1172
+ def available_actions
1162
1173
  if @only
1163
1174
  Array(@only).map(&:to_sym)
1164
- elsif @except
1165
- default_actions - Array(@except).map(&:to_sym)
1166
1175
  else
1167
1176
  default_actions
1168
1177
  end
@@ -1588,7 +1597,7 @@ module ActionDispatch
1588
1597
  when Symbol
1589
1598
  options[:action] = to
1590
1599
  when String
1591
- if to =~ /#/
1600
+ if /#/.match?(to)
1592
1601
  options[:to] = to
1593
1602
  else
1594
1603
  options[:controller] = to
@@ -1914,7 +1923,7 @@ module ActionDispatch
1914
1923
 
1915
1924
  default_action = options.delete(:action) || @scope[:action]
1916
1925
 
1917
- if action =~ /^[\w\-\/]+$/
1926
+ if /^[\w\-\/]+$/.match?(action)
1918
1927
  default_action ||= action.tr("-", "_") unless action.include?("/")
1919
1928
  else
1920
1929
  action = nil
@@ -1934,9 +1943,7 @@ module ActionDispatch
1934
1943
  end
1935
1944
 
1936
1945
  def match_root_route(options)
1937
- name = has_named_route?(name_for_action(:root, nil)) ? nil : :root
1938
- args = ["/", { as: name, via: :get }.merge!(options)]
1939
-
1946
+ args = ["/", { as: :root, via: :get }.merge(options)]
1940
1947
  match(*args)
1941
1948
  end
1942
1949
  end
@@ -120,8 +120,7 @@ module ActionDispatch
120
120
  opts
121
121
  end
122
122
 
123
- # Returns the path component of a URL for the given record. It uses
124
- # <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
123
+ # Returns the path component of a URL for the given record.
125
124
  def polymorphic_path(record_or_hash_or_array, options = {})
126
125
  if Hash === record_or_hash_or_array
127
126
  options = record_or_hash_or_array.merge(options)
@@ -182,8 +181,8 @@ module ActionDispatch
182
181
  CACHE[type].fetch(action) { build action, type }
183
182
  end
184
183
 
185
- def self.url; CACHE["url".freeze][nil]; end
186
- def self.path; CACHE["path".freeze][nil]; end
184
+ def self.url; CACHE["url"][nil]; end
185
+ def self.path; CACHE["path"][nil]; end
187
186
 
188
187
  def self.build(action, type)
189
188
  prefix = action ? "#{action}_" : ""
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "action_dispatch/journey"
4
4
  require "active_support/core_ext/object/to_query"
5
- require "active_support/core_ext/hash/slice"
6
5
  require "active_support/core_ext/module/redefine_method"
7
6
  require "active_support/core_ext/module/remove_method"
8
7
  require "active_support/core_ext/array/extract_options"
@@ -36,7 +35,7 @@ module ActionDispatch
36
35
  if @raise_on_name_error
37
36
  raise
38
37
  else
39
- return [404, { "X-Cascade" => "pass" }, []]
38
+ [404, { "X-Cascade" => "pass" }, []]
40
39
  end
41
40
  end
42
41
 
@@ -91,11 +90,11 @@ module ActionDispatch
91
90
 
92
91
  def clear!
93
92
  @path_helpers.each do |helper|
94
- @path_helpers_module.send :remove_method, helper
93
+ @path_helpers_module.remove_method helper
95
94
  end
96
95
 
97
96
  @url_helpers.each do |helper|
98
- @url_helpers_module.send :remove_method, helper
97
+ @url_helpers_module.remove_method helper
99
98
  end
100
99
 
101
100
  @routes.clear
@@ -109,8 +108,8 @@ module ActionDispatch
109
108
  url_name = :"#{name}_url"
110
109
 
111
110
  if routes.key? key
112
- @path_helpers_module.send :undef_method, path_name
113
- @url_helpers_module.send :undef_method, url_name
111
+ @path_helpers_module.undef_method path_name
112
+ @url_helpers_module.undef_method url_name
114
113
  end
115
114
  routes[key] = route
116
115
  define_url_helper @path_helpers_module, route, path_name, route.defaults, name, PATH
@@ -154,13 +153,13 @@ module ActionDispatch
154
153
  url_name = :"#{name}_url"
155
154
 
156
155
  @path_helpers_module.module_eval do
157
- define_method(path_name) do |*args|
156
+ redefine_method(path_name) do |*args|
158
157
  helper.call(self, args, true)
159
158
  end
160
159
  end
161
160
 
162
161
  @url_helpers_module.module_eval do
163
- define_method(url_name) do |*args|
162
+ redefine_method(url_name) do |*args|
164
163
  helper.call(self, args, false)
165
164
  end
166
165
  end
@@ -246,7 +245,7 @@ module ActionDispatch
246
245
  missing_keys << missing_key
247
246
  }
248
247
  constraints = Hash[@route.requirements.merge(params).sort_by { |k, v| k.to_s }]
249
- message = "No route matches #{constraints.inspect}".dup
248
+ message = +"No route matches #{constraints.inspect}"
250
249
  message << ", missing required keys: #{missing_keys.sort.inspect}"
251
250
 
252
251
  raise ActionController::UrlGenerationError, message
@@ -378,7 +377,7 @@ module ActionDispatch
378
377
  @prepend = []
379
378
  @disable_clear_and_finalize = false
380
379
  @finalized = false
381
- @env_key = "ROUTES_#{object_id}_SCRIPT_NAME".freeze
380
+ @env_key = "ROUTES_#{object_id}_SCRIPT_NAME"
382
381
 
383
382
  @set = Journey::Routes.new
384
383
  @router = Journey::Router.new @set
@@ -585,7 +584,7 @@ module ActionDispatch
585
584
  "You may have defined two routes with the same name using the `:as` option, or " \
586
585
  "you may be overriding a route already defined by a resource with the same naming. " \
587
586
  "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
588
- "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
587
+ "https://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
589
588
  end
590
589
 
591
590
  route = @set.add_route(name, mapping)
@@ -730,7 +729,7 @@ module ActionDispatch
730
729
  # Remove leading slashes from controllers
731
730
  def normalize_controller!
732
731
  if controller
733
- if controller.start_with?("/".freeze)
732
+ if controller.start_with?("/")
734
733
  @options[:controller] = controller[1..-1]
735
734
  else
736
735
  @options[:controller] = controller
@@ -133,6 +133,7 @@ module ActionDispatch
133
133
  # <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
134
134
  # * <tt>:port</tt> - Optionally specify the port to connect to.
135
135
  # * <tt>:anchor</tt> - An anchor name to be appended to the path.
136
+ # * <tt>:params</tt> - The query parameters to be appended to the path.
136
137
  # * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in "/archive/2009/"
137
138
  # * <tt>:script_name</tt> - Specifies application path relative to domain root. If provided, prepends application path.
138
139
  #
@@ -43,7 +43,7 @@ module ActionDispatch
43
43
  end
44
44
 
45
45
  def image_path
46
- @image_path ||= absolute_image_path.relative_path_from(Pathname.pwd).to_s
46
+ @image_path ||= absolute_image_path.to_s
47
47
  end
48
48
 
49
49
  def absolute_image_path
@@ -65,7 +65,7 @@ module ActionDispatch
65
65
  end
66
66
 
67
67
  def display_image
68
- message = "[Screenshot]: #{image_path}\n".dup
68
+ message = +"[Screenshot]: #{image_path}\n"
69
69
 
70
70
  case output_type
71
71
  when "artifact"
@@ -80,7 +80,7 @@ module ActionDispatch
80
80
  end
81
81
 
82
82
  def inline_base64(path)
83
- Base64.encode64(path).gsub("\n", "")
83
+ Base64.strict_encode64(path)
84
84
  end
85
85
 
86
86
  def failed?
@@ -79,9 +79,8 @@ module ActionDispatch
79
79
  end
80
80
 
81
81
  def generate_response_message(expected, actual = @response.response_code)
82
- "Expected response to be a <#{code_with_name(expected)}>,"\
83
- " but was a <#{code_with_name(actual)}>"
84
- .dup.concat(location_if_redirected).concat(response_body_if_short)
82
+ (+"Expected response to be a <#{code_with_name(expected)}>,"\
83
+ " but was a <#{code_with_name(actual)}>").concat(location_if_redirected).concat(response_body_if_short)
85
84
  end
86
85
 
87
86
  def response_body_if_short
@@ -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,7 +83,7 @@ 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
@@ -189,7 +194,7 @@ module ActionDispatch
189
194
 
190
195
  request = ActionController::TestRequest.create @controller.class
191
196
 
192
- if path =~ %r{://}
197
+ if %r{://}.match?(path)
193
198
  fail_on(URI::InvalidURIError, msg) do
194
199
  uri = URI.parse(path)
195
200
  request.env["rack.url_scheme"] = uri.scheme || "http"
@@ -50,10 +50,11 @@ module ActionDispatch
50
50
 
51
51
  # Follow a single redirect response. If the last response was not a
52
52
  # redirect, an exception will be raised. Otherwise, the redirect is
53
- # performed on the location header.
54
- def follow_redirect!
53
+ # performed on the location header. Any arguments are passed to the
54
+ # underlying call to `get`.
55
+ def follow_redirect!(**args)
55
56
  raise "not a redirect! #{status} #{status_message}" unless redirect?
56
- get(response.location)
57
+ get(response.location, **args)
57
58
  status
58
59
  end
59
60
  end
@@ -189,6 +190,12 @@ module ActionDispatch
189
190
  # merged into the Rack env hash.
190
191
  # - +env+: Additional env to pass, as a Hash. The headers will be
191
192
  # merged into the Rack env hash.
193
+ # - +xhr+: Set to `true` if you want to make and Ajax request.
194
+ # Adds request headers characteristic of XMLHttpRequest e.g. HTTP_X_REQUESTED_WITH.
195
+ # The headers will be merged into the Rack env hash.
196
+ # - +as+: Used for encoding the request with different content type.
197
+ # Supports `:json` by default and will set the approriate request headers.
198
+ # The headers will be merged into the Rack env hash.
192
199
  #
193
200
  # This method is rarely used directly. Use +#get+, +#post+, or other standard
194
201
  # HTTP methods in integration tests. +#process+ is only required when using a
@@ -210,7 +217,7 @@ module ActionDispatch
210
217
  method = :post
211
218
  end
212
219
 
213
- if path =~ %r{://}
220
+ if %r{://}.match?(path)
214
221
  path = build_expanded_path(path) do |location|
215
222
  https! URI::HTTPS === location if location.scheme
216
223
 
@@ -8,12 +8,12 @@ module ActionDispatch
8
8
  module FixtureFile
9
9
  # Shortcut for <tt>Rack::Test::UploadedFile.new(File.join(ActionDispatch::IntegrationTest.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('files/spongebob.png', 'image/png') }
12
12
  #
13
13
  # To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
14
14
  # This will not affect other platforms:
15
15
  #
16
- # post :change_avatar, avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary)
16
+ # post :change_avatar, params: { avatar: fixture_file_upload('files/spongebob.png', 'image/png', :binary) }
17
17
  def fixture_file_upload(path, mime_type = nil, binary = false)
18
18
  if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
19
19
  !File.exist?(path)
@@ -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(content_type)
51
23
  end
52
24
  end
53
25
  end