actionpack 5.0.7.2 → 5.1.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 (128) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +189 -1002
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/abstract_controller.rb +3 -3
  6. data/lib/abstract_controller/base.rb +10 -12
  7. data/lib/abstract_controller/caching.rb +6 -3
  8. data/lib/abstract_controller/caching/fragments.rb +1 -1
  9. data/lib/abstract_controller/callbacks.rb +2 -43
  10. data/lib/abstract_controller/collector.rb +2 -2
  11. data/lib/abstract_controller/helpers.rb +19 -19
  12. data/lib/abstract_controller/rendering.rb +9 -11
  13. data/lib/abstract_controller/translation.rb +3 -3
  14. data/lib/action_controller.rb +15 -13
  15. data/lib/action_controller/api.rb +3 -3
  16. data/lib/action_controller/base.rb +7 -12
  17. data/lib/action_controller/caching.rb +1 -1
  18. data/lib/action_controller/log_subscriber.rb +2 -2
  19. data/lib/action_controller/metal.rb +34 -43
  20. data/lib/action_controller/metal/conditional_get.rb +10 -9
  21. data/lib/action_controller/metal/data_streaming.rb +8 -9
  22. data/lib/action_controller/metal/etag_with_flash.rb +16 -0
  23. data/lib/action_controller/metal/etag_with_template_digest.rb +15 -15
  24. data/lib/action_controller/metal/exceptions.rb +4 -14
  25. data/lib/action_controller/metal/flash.rb +1 -1
  26. data/lib/action_controller/metal/force_ssl.rb +6 -6
  27. data/lib/action_controller/metal/head.rb +13 -19
  28. data/lib/action_controller/metal/helpers.rb +6 -6
  29. data/lib/action_controller/metal/http_authentication.rb +22 -23
  30. data/lib/action_controller/metal/implicit_render.rb +2 -5
  31. data/lib/action_controller/metal/instrumentation.rb +14 -14
  32. data/lib/action_controller/metal/live.rb +15 -16
  33. data/lib/action_controller/metal/mime_responds.rb +3 -3
  34. data/lib/action_controller/metal/parameter_encoding.rb +49 -0
  35. data/lib/action_controller/metal/params_wrapper.rb +32 -32
  36. data/lib/action_controller/metal/redirecting.rb +8 -24
  37. data/lib/action_controller/metal/renderers.rb +2 -3
  38. data/lib/action_controller/metal/rendering.rb +50 -60
  39. data/lib/action_controller/metal/request_forgery_protection.rb +51 -49
  40. data/lib/action_controller/metal/rescue.rb +1 -1
  41. data/lib/action_controller/metal/streaming.rb +4 -4
  42. data/lib/action_controller/metal/strong_parameters.rb +117 -250
  43. data/lib/action_controller/metal/testing.rb +1 -1
  44. data/lib/action_controller/metal/url_for.rb +4 -4
  45. data/lib/action_controller/railtie.rb +9 -13
  46. data/lib/action_controller/renderer.rb +17 -16
  47. data/lib/action_controller/test_case.rb +75 -148
  48. data/lib/action_dispatch.rb +20 -19
  49. data/lib/action_dispatch/http/cache.rb +9 -10
  50. data/lib/action_dispatch/http/filter_parameters.rb +8 -8
  51. data/lib/action_dispatch/http/filter_redirect.rb +2 -4
  52. data/lib/action_dispatch/http/headers.rb +10 -10
  53. data/lib/action_dispatch/http/mime_negotiation.rb +17 -22
  54. data/lib/action_dispatch/http/mime_type.rb +27 -52
  55. data/lib/action_dispatch/http/parameter_filter.rb +8 -6
  56. data/lib/action_dispatch/http/parameters.rb +40 -17
  57. data/lib/action_dispatch/http/request.rb +38 -34
  58. data/lib/action_dispatch/http/response.rb +16 -16
  59. data/lib/action_dispatch/http/upload.rb +6 -10
  60. data/lib/action_dispatch/http/url.rb +48 -74
  61. data/lib/action_dispatch/journey.rb +5 -5
  62. data/lib/action_dispatch/journey/formatter.rb +8 -4
  63. data/lib/action_dispatch/journey/gtg/builder.rb +5 -5
  64. data/lib/action_dispatch/journey/gtg/simulator.rb +1 -1
  65. data/lib/action_dispatch/journey/gtg/transition_table.rb +15 -15
  66. data/lib/action_dispatch/journey/nfa/builder.rb +3 -3
  67. data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
  68. data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
  69. data/lib/action_dispatch/journey/nfa/transition_table.rb +2 -2
  70. data/lib/action_dispatch/journey/nodes/node.rb +5 -5
  71. data/lib/action_dispatch/journey/parser.rb +23 -24
  72. data/lib/action_dispatch/journey/parser.y +3 -2
  73. data/lib/action_dispatch/journey/parser_extras.rb +2 -2
  74. data/lib/action_dispatch/journey/path/pattern.rb +10 -3
  75. data/lib/action_dispatch/journey/route.rb +19 -12
  76. data/lib/action_dispatch/journey/router.rb +19 -12
  77. data/lib/action_dispatch/journey/router/utils.rb +9 -9
  78. data/lib/action_dispatch/journey/scanner.rb +17 -15
  79. data/lib/action_dispatch/journey/visitors.rb +23 -23
  80. data/lib/action_dispatch/middleware/callbacks.rb +0 -12
  81. data/lib/action_dispatch/middleware/cookies.rb +39 -39
  82. data/lib/action_dispatch/middleware/debug_exceptions.rb +126 -112
  83. data/lib/action_dispatch/middleware/debug_locks.rb +8 -8
  84. data/lib/action_dispatch/middleware/exception_wrapper.rb +55 -55
  85. data/lib/action_dispatch/middleware/executor.rb +1 -1
  86. data/lib/action_dispatch/middleware/flash.rb +17 -16
  87. data/lib/action_dispatch/middleware/public_exceptions.rb +20 -20
  88. data/lib/action_dispatch/middleware/reloader.rb +3 -47
  89. data/lib/action_dispatch/middleware/remote_ip.rb +6 -8
  90. data/lib/action_dispatch/middleware/request_id.rb +6 -5
  91. data/lib/action_dispatch/middleware/session/abstract_store.rb +14 -26
  92. data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
  93. data/lib/action_dispatch/middleware/session/cookie_store.rb +35 -35
  94. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +2 -2
  95. data/lib/action_dispatch/middleware/show_exceptions.rb +19 -19
  96. data/lib/action_dispatch/middleware/ssl.rb +9 -27
  97. data/lib/action_dispatch/middleware/stack.rb +7 -26
  98. data/lib/action_dispatch/middleware/static.rb +13 -24
  99. data/lib/action_dispatch/railtie.rb +9 -11
  100. data/lib/action_dispatch/request/session.rb +22 -22
  101. data/lib/action_dispatch/request/utils.rb +11 -2
  102. data/lib/action_dispatch/routing.rb +8 -6
  103. data/lib/action_dispatch/routing/inspector.rb +37 -37
  104. data/lib/action_dispatch/routing/mapper.rb +296 -203
  105. data/lib/action_dispatch/routing/polymorphic_routes.rb +160 -134
  106. data/lib/action_dispatch/routing/redirection.rb +27 -22
  107. data/lib/action_dispatch/routing/route_set.rb +206 -92
  108. data/lib/action_dispatch/routing/routes_proxy.rb +2 -2
  109. data/lib/action_dispatch/routing/url_for.rb +14 -12
  110. data/lib/action_dispatch/system_test_case.rb +119 -0
  111. data/lib/action_dispatch/system_testing/browser.rb +28 -0
  112. data/lib/action_dispatch/system_testing/driver.rb +18 -0
  113. data/lib/action_dispatch/system_testing/server.rb +32 -0
  114. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +61 -0
  115. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +20 -0
  116. data/lib/action_dispatch/testing/assertion_response.rb +6 -6
  117. data/lib/action_dispatch/testing/assertions.rb +4 -4
  118. data/lib/action_dispatch/testing/assertions/response.rb +8 -3
  119. data/lib/action_dispatch/testing/assertions/routing.rb +11 -11
  120. data/lib/action_dispatch/testing/integration.rb +47 -138
  121. data/lib/action_dispatch/testing/test_process.rb +2 -2
  122. data/lib/action_dispatch/testing/test_request.rb +16 -16
  123. data/lib/action_dispatch/testing/test_response.rb +1 -1
  124. data/lib/action_pack.rb +2 -2
  125. data/lib/action_pack/gem_version.rb +3 -3
  126. data/lib/action_pack/version.rb +1 -1
  127. metadata +20 -12
  128. data/lib/action_dispatch/middleware/params_parser.rb +0 -46
@@ -51,7 +51,7 @@ module ActionController
51
51
  def unpermitted_parameters(event)
52
52
  debug do
53
53
  unpermitted_keys = event.payload[:keys]
54
- "Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{unpermitted_keys.join(", ")}"
54
+ "Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{unpermitted_keys.map { |e| ":#{e}" }.join(", ")}"
55
55
  end
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ module ActionController
59
59
  expire_fragment expire_page write_page).each do |method|
60
60
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
61
61
  def #{method}(event)
62
- return unless logger.info?
62
+ return unless logger.info? && ActionController::Base.enable_fragment_cache_logging
63
63
  key_or_path = event.payload[:key] || event.payload[:path]
64
64
  human_name = #{method.to_s.humanize.inspect}
65
65
  info("\#{human_name} \#{key_or_path} (\#{event.duration.round(1)}ms)")
@@ -1,7 +1,7 @@
1
- require 'active_support/core_ext/array/extract_options'
2
- require 'action_dispatch/middleware/stack'
3
- require 'action_dispatch/http/request'
4
- require 'action_dispatch/http/response'
1
+ require "active_support/core_ext/array/extract_options"
2
+ require "action_dispatch/middleware/stack"
3
+ require "action_dispatch/http/request"
4
+ require "action_dispatch/http/response"
5
5
 
6
6
  module ActionController
7
7
  # Extend ActionDispatch middleware stack to make it aware of options
@@ -34,29 +34,29 @@ module ActionController
34
34
 
35
35
  private
36
36
 
37
- INCLUDE = ->(list, action) { list.include? action }
38
- EXCLUDE = ->(list, action) { !list.include? action }
39
- NULL = ->(list, action) { true }
40
-
41
- def build_middleware(klass, args, block)
42
- options = args.extract_options!
43
- only = Array(options.delete(:only)).map(&:to_s)
44
- except = Array(options.delete(:except)).map(&:to_s)
45
- args << options unless options.empty?
46
-
47
- strategy = NULL
48
- list = nil
49
-
50
- if only.any?
51
- strategy = INCLUDE
52
- list = only
53
- elsif except.any?
54
- strategy = EXCLUDE
55
- list = except
56
- end
37
+ INCLUDE = ->(list, action) { list.include? action }
38
+ EXCLUDE = ->(list, action) { !list.include? action }
39
+ NULL = ->(list, action) { true }
40
+
41
+ def build_middleware(klass, args, block)
42
+ options = args.extract_options!
43
+ only = Array(options.delete(:only)).map(&:to_s)
44
+ except = Array(options.delete(:except)).map(&:to_s)
45
+ args << options unless options.empty?
46
+
47
+ strategy = NULL
48
+ list = nil
49
+
50
+ if only.any?
51
+ strategy = INCLUDE
52
+ list = only
53
+ elsif except.any?
54
+ strategy = EXCLUDE
55
+ list = except
56
+ end
57
57
 
58
- Middleware.new(get_class(klass), args, list, strategy, block)
59
- end
58
+ Middleware.new(klass, args, list, strategy, block)
59
+ end
60
60
  end
61
61
 
62
62
  # <tt>ActionController::Metal</tt> is the simplest possible controller, providing a
@@ -118,11 +118,6 @@ module ActionController
118
118
  class Metal < AbstractController::Base
119
119
  abstract!
120
120
 
121
- def env
122
- @_request.env
123
- end
124
- deprecate :env
125
-
126
121
  # Returns the last part of the controller's name, underscored, without the ending
127
122
  # <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
128
123
  # Namespaces are left out, so Admin::PostsController returns <tt>posts</tt> as well.
@@ -130,24 +125,28 @@ module ActionController
130
125
  # ==== Returns
131
126
  # * <tt>string</tt>
132
127
  def self.controller_name
133
- @controller_name ||= name.demodulize.sub(/Controller$/, '').underscore
128
+ @controller_name ||= name.demodulize.sub(/Controller$/, "").underscore
134
129
  end
135
130
 
136
131
  def self.make_response!(request)
137
- ActionDispatch::Response.new.tap do |res|
132
+ ActionDispatch::Response.create.tap do |res|
138
133
  res.request = request
139
134
  end
140
135
  end
141
136
 
137
+ def self.binary_params_for?(action) # :nodoc:
138
+ false
139
+ end
140
+
142
141
  # Delegates to the class' <tt>controller_name</tt>
143
142
  def controller_name
144
143
  self.class.controller_name
145
144
  end
146
145
 
147
146
  attr_internal :response, :request
148
- delegate :session, :to => "@_request"
147
+ delegate :session, to: "@_request"
149
148
  delegate :headers, :status=, :location=, :content_type=,
150
- :status, :location, :content_type, :to => "@_response"
149
+ :status, :location, :content_type, to: "@_response"
151
150
 
152
151
  def initialize
153
152
  @_request = nil
@@ -228,14 +227,6 @@ module ActionController
228
227
  middleware_stack
229
228
  end
230
229
 
231
- # Makes the controller a Rack endpoint that runs the action in the given
232
- # +env+'s +action_dispatch.request.path_parameters+ key.
233
- def self.call(env)
234
- req = ActionDispatch::Request.new env
235
- action(req.path_parameters[:action]).call(env)
236
- end
237
- class << self; deprecate :call; end
238
-
239
230
  # Returns a Rack endpoint for the given action name.
240
231
  def self.action(name)
241
232
  if middleware_stack.any?
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/hash/keys'
1
+ require "active_support/core_ext/hash/keys"
2
2
 
3
3
  module ActionController
4
4
  module ConditionalGet
@@ -129,7 +129,7 @@ module ActionController
129
129
  # * <tt>:etag</tt> Sets a "weak" ETag validator on the response. See the
130
130
  # +:weak_etag+ option.
131
131
  # * <tt>:weak_etag</tt> Sets a "weak" ETag validator on the response.
132
- # requests that set If-None-Match header may return a 304 Not Modified
132
+ # Requests that set If-None-Match header may return a 304 Not Modified
133
133
  # response if it matches the ETag exactly. A weak ETag indicates semantic
134
134
  # equivalence, not byte-for-byte equality, so they're good for caching
135
135
  # HTML pages in browser caches. They can't be used for responses that
@@ -232,20 +232,21 @@ module ActionController
232
232
  # The method will also ensure an HTTP Date header for client compatibility.
233
233
  def expires_in(seconds, options = {})
234
234
  response.cache_control.merge!(
235
- :max_age => seconds,
236
- :public => options.delete(:public),
237
- :must_revalidate => options.delete(:must_revalidate)
235
+ max_age: seconds,
236
+ public: options.delete(:public),
237
+ must_revalidate: options.delete(:must_revalidate)
238
238
  )
239
239
  options.delete(:private)
240
240
 
241
- response.cache_control[:extras] = options.map {|k,v| "#{k}=#{v}"}
241
+ response.cache_control[:extras] = options.map { |k, v| "#{k}=#{v}" }
242
242
  response.date = Time.now unless response.date?
243
243
  end
244
244
 
245
- # Sets an HTTP 1.1 Cache-Control header of <tt>no-cache</tt> so no caching should
246
- # occur by the browser or intermediate caches (like caching proxy servers).
245
+ # Sets an HTTP 1.1 Cache-Control header of <tt>no-cache</tt>. This means the
246
+ # resource will be marked as stale, so clients must always revalidate.
247
+ # Intermediate/browser caches may still store the asset.
247
248
  def expires_now
248
- response.cache_control.replace(:no_cache => true)
249
+ response.cache_control.replace(no_cache: true)
249
250
  end
250
251
 
251
252
  # Cache or yield the block. The cache is supposed to never expire.
@@ -1,4 +1,4 @@
1
- require 'action_controller/metal/exceptions'
1
+ require "action_controller/metal/exceptions"
2
2
 
3
3
  module ActionController #:nodoc:
4
4
  # Methods for sending arbitrary data and for streaming files to the browser,
@@ -8,10 +8,10 @@ module ActionController #:nodoc:
8
8
 
9
9
  include ActionController::Rendering
10
10
 
11
- DEFAULT_SEND_FILE_TYPE = 'application/octet-stream'.freeze #:nodoc:
12
- DEFAULT_SEND_FILE_DISPOSITION = 'attachment'.freeze #:nodoc:
11
+ DEFAULT_SEND_FILE_TYPE = "application/octet-stream".freeze #:nodoc:
12
+ DEFAULT_SEND_FILE_DISPOSITION = "attachment".freeze #:nodoc:
13
13
 
14
- protected
14
+ private
15
15
  # Sends the file. This uses a server-appropriate method (such as X-Sendfile)
16
16
  # via the Rack::Sendfile middleware. The header to use is set via
17
17
  # +config.action_dispatch.x_sendfile_header+.
@@ -64,7 +64,7 @@ module ActionController #:nodoc:
64
64
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
65
65
  # for the Cache-Control header spec.
66
66
  def send_file(path, options = {}) #:doc:
67
- raise MissingFile, "Cannot read file #{path}" unless File.file?(path) and File.readable?(path)
67
+ raise MissingFile, "Cannot read file #{path}" unless File.file?(path) && File.readable?(path)
68
68
 
69
69
  options[:filename] ||= File.basename(path) unless options[:url_based_filename]
70
70
  send_file_headers! options
@@ -108,7 +108,6 @@ module ActionController #:nodoc:
108
108
  render options.slice(:status, :content_type).merge(body: data)
109
109
  end
110
110
 
111
- private
112
111
  def send_file_headers!(options)
113
112
  type_provided = options.has_key?(:type)
114
113
 
@@ -125,7 +124,7 @@ module ActionController #:nodoc:
125
124
  else
126
125
  if !type_provided && options[:filename]
127
126
  # If type wasn't provided, try guessing from file extension.
128
- content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.delete('.')) || content_type
127
+ content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.delete(".")) || content_type
129
128
  end
130
129
  self.content_type = content_type
131
130
  end
@@ -134,10 +133,10 @@ module ActionController #:nodoc:
134
133
  unless disposition.nil?
135
134
  disposition = disposition.to_s
136
135
  disposition += %(; filename="#{options[:filename]}") if options[:filename]
137
- headers['Content-Disposition'] = disposition
136
+ headers["Content-Disposition"] = disposition
138
137
  end
139
138
 
140
- headers['Content-Transfer-Encoding'] = 'binary'
139
+ headers["Content-Transfer-Encoding"] = "binary"
141
140
 
142
141
  # Fix a problem with IE 6.0 on opening downloaded files:
143
142
  # If Cache-Control: no-cache is set (which Rails does by default),
@@ -0,0 +1,16 @@
1
+ module ActionController
2
+ # When you're using the flash, it's generally used as a conditional on the view.
3
+ # This means the content of the view depends on the flash. Which in turn means
4
+ # that the etag for a response should be computed with the content of the flash
5
+ # in mind. This does that by including the content of the flash as a component
6
+ # in the etag that's generated for a response.
7
+ module EtagWithFlash
8
+ extend ActiveSupport::Concern
9
+
10
+ include ActionController::ConditionalGet
11
+
12
+ included do
13
+ etag { flash unless flash.empty? }
14
+ end
15
+ end
16
+ end
@@ -33,24 +33,24 @@ module ActionController
33
33
  end
34
34
 
35
35
  private
36
- def determine_template_etag(options)
37
- if template = pick_template_for_etag(options)
38
- lookup_and_digest_template(template)
36
+ def determine_template_etag(options)
37
+ if template = pick_template_for_etag(options)
38
+ lookup_and_digest_template(template)
39
+ end
39
40
  end
40
- end
41
41
 
42
- # Pick the template digest to include in the ETag. If the +:template+ option
43
- # is present, use the named template. If +:template+ is nil or absent, use
44
- # the default controller/action template. If +:template+ is false, omit the
45
- # template digest from the ETag.
46
- def pick_template_for_etag(options)
47
- unless options[:template] == false
48
- options[:template] || "#{controller_path}/#{action_name}"
42
+ # Pick the template digest to include in the ETag. If the +:template+ option
43
+ # is present, use the named template. If +:template+ is +nil+ or absent, use
44
+ # the default controller/action template. If +:template+ is false, omit the
45
+ # template digest from the ETag.
46
+ def pick_template_for_etag(options)
47
+ unless options[:template] == false
48
+ options[:template] || "#{controller_path}/#{action_name}"
49
+ end
49
50
  end
50
- end
51
51
 
52
- def lookup_and_digest_template(template)
53
- ActionView::Digestor.digest name: template, finder: lookup_context
54
- end
52
+ def lookup_and_digest_template(template)
53
+ ActionView::Digestor.digest name: template, finder: lookup_context
54
+ end
55
55
  end
56
56
  end
@@ -3,20 +3,10 @@ module ActionController
3
3
  end
4
4
 
5
5
  class BadRequest < ActionControllerError #:nodoc:
6
- def initialize(msg = nil, e = nil)
7
- if e
8
- ActiveSupport::Deprecation.warn("Passing #original_exception is deprecated and has no effect. " \
9
- "Exceptions will automatically capture the original exception.", caller)
10
- end
11
-
6
+ def initialize(msg = nil)
12
7
  super(msg)
13
8
  set_backtrace $!.backtrace if $!
14
9
  end
15
-
16
- def original_exception
17
- ActiveSupport::Deprecation.warn("#original_exception is deprecated. Use #cause instead.", caller)
18
- cause
19
- end
20
10
  end
21
11
 
22
12
  class RenderError < ActionControllerError #:nodoc:
@@ -24,7 +14,7 @@ module ActionController
24
14
 
25
15
  class RoutingError < ActionControllerError #:nodoc:
26
16
  attr_reader :failures
27
- def initialize(message, failures=[])
17
+ def initialize(message, failures = [])
28
18
  super(message)
29
19
  @failures = failures
30
20
  end
@@ -35,7 +25,7 @@ module ActionController
35
25
 
36
26
  class MethodNotAllowed < ActionControllerError #:nodoc:
37
27
  def initialize(*allowed_methods)
38
- super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
28
+ super("Only #{allowed_methods.to_sentence(locale: :en)} requests are allowed.")
39
29
  end
40
30
  end
41
31
 
@@ -49,7 +39,7 @@ module ActionController
49
39
  end
50
40
 
51
41
  class SessionOverflowError < ActionControllerError #:nodoc:
52
- DEFAULT_MESSAGE = 'Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data.'
42
+ DEFAULT_MESSAGE = "Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data."
53
43
 
54
44
  def initialize(message = nil)
55
45
  super(message || DEFAULT_MESSAGE)
@@ -42,7 +42,7 @@ module ActionController #:nodoc:
42
42
  end
43
43
  end
44
44
 
45
- protected
45
+ private
46
46
  def redirect_to(options = {}, response_status_and_flash = {}) #:doc:
47
47
  self.class._flash_types.each do |flash_type|
48
48
  if type = response_status_and_flash.delete(flash_type)
@@ -1,5 +1,5 @@
1
- require 'active_support/core_ext/hash/except'
2
- require 'active_support/core_ext/hash/slice'
1
+ require "active_support/core_ext/hash/except"
2
+ require "active_support/core_ext/hash/slice"
3
3
 
4
4
  module ActionController
5
5
  # This module provides a method which will redirect the browser to use HTTPS
@@ -76,10 +76,10 @@ module ActionController
76
76
  def force_ssl_redirect(host_or_options = nil)
77
77
  unless request.ssl?
78
78
  options = {
79
- :protocol => 'https://',
80
- :host => request.host,
81
- :path => request.fullpath,
82
- :status => :moved_permanently
79
+ protocol: "https://",
80
+ host: request.host,
81
+ path: request.fullpath,
82
+ status: :moved_permanently
83
83
  }
84
84
 
85
85
  if host_or_options.is_a?(Hash)
@@ -18,13 +18,7 @@ module ActionController
18
18
  # See Rack::Utils::SYMBOL_TO_STATUS_CODE for a full list of valid +status+ symbols.
19
19
  def head(status, options = {})
20
20
  if status.is_a?(Hash)
21
- msg = status[:status] ? 'The :status option' : 'The implicit :ok status'
22
- options, status = status, status.delete(:status)
23
-
24
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
25
- #{msg} on `head` has been deprecated and will be removed in Rails 5.1.
26
- Please pass the status as a separate parameter before the options, instead.
27
- MSG
21
+ raise ArgumentError, "#{status.inspect} is not a valid value for `status`."
28
22
  end
29
23
 
30
24
  status ||= :ok
@@ -33,7 +27,7 @@ module ActionController
33
27
  content_type = options.delete(:content_type)
34
28
 
35
29
  options.each do |key, value|
36
- headers[key.to_s.dasherize.split('-').each { |v| v[0] = v[0].chr.upcase }.join('-')] = value.to_s
30
+ headers[key.to_s.dasherize.split("-").each { |v| v[0] = v[0].chr.upcase }.join("-")] = value.to_s
37
31
  end
38
32
 
39
33
  self.status = status
@@ -41,24 +35,24 @@ module ActionController
41
35
 
42
36
  self.response_body = ""
43
37
 
44
- if include_content?(self.response_code)
38
+ if include_content?(response_code)
45
39
  self.content_type = content_type || (Mime[formats.first] if formats)
46
- self.response.charset = false
40
+ response.charset = false
47
41
  end
48
42
 
49
43
  true
50
44
  end
51
45
 
52
46
  private
53
- def include_content?(status)
54
- case status
55
- when 100..199
56
- false
57
- when 204, 205, 304
58
- false
59
- else
60
- true
47
+ def include_content?(status)
48
+ case status
49
+ when 100..199
50
+ false
51
+ when 204, 205, 304
52
+ false
53
+ else
54
+ true
55
+ end
61
56
  end
62
- end
63
57
  end
64
58
  end
@@ -71,7 +71,7 @@ module ActionController
71
71
  attrs.flatten.each { |attr| helper_method(attr, "#{attr}=") }
72
72
  end
73
73
 
74
- # Provides a proxy to access helpers methods from outside the view.
74
+ # Provides a proxy to access helper methods from outside the view.
75
75
  def helpers
76
76
  @helper_proxy ||= begin
77
77
  proxy = ActionView::Base.new
@@ -108,13 +108,13 @@ module ActionController
108
108
  end
109
109
 
110
110
  private
111
- # Extract helper names from files in <tt>app/helpers/**/*_helper.rb</tt>
112
- def all_application_helpers
113
- all_helpers_from_path(helpers_path)
114
- end
111
+ # Extract helper names from files in <tt>app/helpers/**/*_helper.rb</tt>
112
+ def all_application_helpers
113
+ all_helpers_from_path(helpers_path)
114
+ end
115
115
  end
116
116
 
117
- # Provides a proxy to access helpers methods from outside the view.
117
+ # Provides a proxy to access helper methods from outside the view.
118
118
  def helpers
119
119
  @_helper_proxy ||= view_context
120
120
  end