actionpack 4.2.10 → 5.0.0

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 (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +553 -401
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +2 -3
  5. data/lib/abstract_controller/base.rb +28 -38
  6. data/lib/{action_controller → abstract_controller}/caching/fragments.rb +51 -11
  7. data/lib/abstract_controller/caching.rb +62 -0
  8. data/lib/abstract_controller/callbacks.rb +52 -19
  9. data/lib/abstract_controller/collector.rb +4 -9
  10. data/lib/abstract_controller/error.rb +4 -0
  11. data/lib/abstract_controller/helpers.rb +4 -3
  12. data/lib/abstract_controller/railties/routes_helpers.rb +2 -2
  13. data/lib/abstract_controller/rendering.rb +28 -18
  14. data/lib/abstract_controller/translation.rb +8 -7
  15. data/lib/abstract_controller.rb +6 -2
  16. data/lib/action_controller/api/api_rendering.rb +14 -0
  17. data/lib/action_controller/api.rb +147 -0
  18. data/lib/action_controller/base.rb +10 -13
  19. data/lib/action_controller/caching.rb +13 -58
  20. data/lib/action_controller/form_builder.rb +48 -0
  21. data/lib/action_controller/log_subscriber.rb +3 -10
  22. data/lib/action_controller/metal/basic_implicit_render.rb +11 -0
  23. data/lib/action_controller/metal/conditional_get.rb +106 -34
  24. data/lib/action_controller/metal/cookies.rb +1 -3
  25. data/lib/action_controller/metal/data_streaming.rb +11 -32
  26. data/lib/action_controller/metal/etag_with_template_digest.rb +1 -1
  27. data/lib/action_controller/metal/exceptions.rb +11 -6
  28. data/lib/action_controller/metal/force_ssl.rb +10 -10
  29. data/lib/action_controller/metal/head.rb +14 -8
  30. data/lib/action_controller/metal/helpers.rb +15 -6
  31. data/lib/action_controller/metal/http_authentication.rb +44 -35
  32. data/lib/action_controller/metal/implicit_render.rb +61 -6
  33. data/lib/action_controller/metal/instrumentation.rb +5 -5
  34. data/lib/action_controller/metal/live.rb +66 -88
  35. data/lib/action_controller/metal/mime_responds.rb +27 -42
  36. data/lib/action_controller/metal/params_wrapper.rb +8 -8
  37. data/lib/action_controller/metal/redirecting.rb +32 -9
  38. data/lib/action_controller/metal/renderers.rb +85 -40
  39. data/lib/action_controller/metal/rendering.rb +38 -6
  40. data/lib/action_controller/metal/request_forgery_protection.rb +126 -48
  41. data/lib/action_controller/metal/rescue.rb +3 -12
  42. data/lib/action_controller/metal/streaming.rb +4 -4
  43. data/lib/action_controller/metal/strong_parameters.rb +293 -90
  44. data/lib/action_controller/metal/testing.rb +1 -12
  45. data/lib/action_controller/metal/url_for.rb +12 -5
  46. data/lib/action_controller/metal.rb +88 -63
  47. data/lib/action_controller/renderer.rb +111 -0
  48. data/lib/action_controller/template_assertions.rb +9 -0
  49. data/lib/action_controller/test_case.rb +288 -368
  50. data/lib/action_controller.rb +12 -9
  51. data/lib/action_dispatch/http/cache.rb +73 -34
  52. data/lib/action_dispatch/http/filter_parameters.rb +15 -11
  53. data/lib/action_dispatch/http/filter_redirect.rb +7 -8
  54. data/lib/action_dispatch/http/headers.rb +44 -13
  55. data/lib/action_dispatch/http/mime_negotiation.rb +41 -23
  56. data/lib/action_dispatch/http/mime_type.rb +126 -90
  57. data/lib/action_dispatch/http/mime_types.rb +3 -4
  58. data/lib/action_dispatch/http/parameter_filter.rb +18 -8
  59. data/lib/action_dispatch/http/parameters.rb +54 -41
  60. data/lib/action_dispatch/http/request.rb +149 -82
  61. data/lib/action_dispatch/http/response.rb +206 -102
  62. data/lib/action_dispatch/http/url.rb +117 -8
  63. data/lib/action_dispatch/journey/formatter.rb +39 -28
  64. data/lib/action_dispatch/journey/gtg/transition_table.rb +1 -1
  65. data/lib/action_dispatch/journey/nfa/dot.rb +0 -2
  66. data/lib/action_dispatch/journey/nfa/transition_table.rb +1 -46
  67. data/lib/action_dispatch/journey/nodes/node.rb +14 -4
  68. data/lib/action_dispatch/journey/parser_extras.rb +4 -0
  69. data/lib/action_dispatch/journey/path/pattern.rb +38 -42
  70. data/lib/action_dispatch/journey/route.rb +74 -19
  71. data/lib/action_dispatch/journey/router/utils.rb +5 -5
  72. data/lib/action_dispatch/journey/router.rb +5 -9
  73. data/lib/action_dispatch/journey/routes.rb +14 -15
  74. data/lib/action_dispatch/journey/visitors.rb +86 -43
  75. data/lib/action_dispatch/middleware/callbacks.rb +10 -1
  76. data/lib/action_dispatch/middleware/cookies.rb +189 -135
  77. data/lib/action_dispatch/middleware/debug_exceptions.rb +124 -49
  78. data/lib/action_dispatch/middleware/exception_wrapper.rb +21 -21
  79. data/lib/action_dispatch/middleware/executor.rb +19 -0
  80. data/lib/action_dispatch/middleware/flash.rb +66 -45
  81. data/lib/action_dispatch/middleware/params_parser.rb +32 -46
  82. data/lib/action_dispatch/middleware/public_exceptions.rb +2 -2
  83. data/lib/action_dispatch/middleware/reloader.rb +14 -58
  84. data/lib/action_dispatch/middleware/remote_ip.rb +29 -19
  85. data/lib/action_dispatch/middleware/request_id.rb +11 -6
  86. data/lib/action_dispatch/middleware/session/abstract_store.rb +23 -11
  87. data/lib/action_dispatch/middleware/session/cache_store.rb +9 -6
  88. data/lib/action_dispatch/middleware/session/cookie_store.rb +30 -24
  89. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +4 -0
  90. data/lib/action_dispatch/middleware/show_exceptions.rb +11 -9
  91. data/lib/action_dispatch/middleware/ssl.rb +115 -36
  92. data/lib/action_dispatch/middleware/stack.rb +44 -40
  93. data/lib/action_dispatch/middleware/static.rb +51 -35
  94. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +2 -14
  95. data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  96. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -1
  97. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +1 -1
  98. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +4 -4
  99. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +59 -63
  100. data/lib/action_dispatch/railtie.rb +2 -2
  101. data/lib/action_dispatch/request/session.rb +69 -33
  102. data/lib/action_dispatch/request/utils.rb +51 -19
  103. data/lib/action_dispatch/routing/inspector.rb +32 -43
  104. data/lib/action_dispatch/routing/mapper.rb +491 -338
  105. data/lib/action_dispatch/routing/polymorphic_routes.rb +8 -14
  106. data/lib/action_dispatch/routing/redirection.rb +3 -3
  107. data/lib/action_dispatch/routing/route_set.rb +145 -238
  108. data/lib/action_dispatch/routing/url_for.rb +27 -10
  109. data/lib/action_dispatch/routing.rb +17 -13
  110. data/lib/action_dispatch/testing/assertion_response.rb +45 -0
  111. data/lib/action_dispatch/testing/assertions/response.rb +38 -20
  112. data/lib/action_dispatch/testing/assertions/routing.rb +11 -10
  113. data/lib/action_dispatch/testing/assertions.rb +1 -1
  114. data/lib/action_dispatch/testing/integration.rb +368 -97
  115. data/lib/action_dispatch/testing/test_process.rb +5 -6
  116. data/lib/action_dispatch/testing/test_request.rb +22 -31
  117. data/lib/action_dispatch/testing/test_response.rb +7 -4
  118. data/lib/action_dispatch.rb +3 -1
  119. data/lib/action_pack/gem_version.rb +3 -3
  120. data/lib/action_pack.rb +1 -1
  121. metadata +30 -34
  122. data/lib/action_controller/metal/hide_actions.rb +0 -40
  123. data/lib/action_controller/metal/rack_delegation.rb +0 -32
  124. data/lib/action_controller/middleware.rb +0 -39
  125. data/lib/action_controller/model_naming.rb +0 -12
  126. data/lib/action_dispatch/journey/backwards.rb +0 -5
  127. data/lib/action_dispatch/journey/router/strexp.rb +0 -27
  128. data/lib/action_dispatch/testing/assertions/dom.rb +0 -3
  129. data/lib/action_dispatch/testing/assertions/selector.rb +0 -3
  130. data/lib/action_dispatch/testing/assertions/tag.rb +0 -3
  131. /data/lib/action_dispatch/middleware/templates/rescues/{_source.erb → _source.html.erb} +0 -0
data/CHANGELOG.md CHANGED
@@ -1,670 +1,822 @@
1
- ## Rails 4.2.10 (September 27, 2017) ##
1
+ ## Rails 5.0.0 (June 30, 2016) ##
2
2
 
3
- * Fix regression in behavior of `normalize_path`.
3
+ * Add `ActionController#helpers` to get access to the view context at the controller
4
+ level.
4
5
 
5
- In Rails 5 there was a change to ensure the encoding of the original string
6
- in a path was maintained. This was incorrectly backported to Rails 4.2 which
7
- caused a regression.
6
+ *Rafael Mendonça França*
8
7
 
9
- *Eileen M. Uchitelle*
8
+ * Routing: Refactor `:action` default handling to ensure that path
9
+ parameters are not mutated during route generation.
10
10
 
11
- ## Rails 4.2.9 (June 26, 2017) ##
11
+ *Andrew White*
12
12
 
13
- * Use more specific check for :format in route path
13
+ * Add extension synonyms `yml` and `yaml` for MIME type `application/x-yaml`.
14
14
 
15
- The current check for whether to add an optional format to the path is very lax
16
- and will match things like `:format_id` where there are nested resources, e.g:
15
+ *bogdanvlviv*
17
16
 
18
- ``` ruby
19
- resources :formats do
20
- resources :items
21
- end
22
- ```
17
+ * Adds support for including ActionController::Cookies in API controllers.
18
+ Previously, including the module would raise when trying to define
19
+ a `cookies` helper method. Skip calling #helper_method if it is not
20
+ defined -- if we don't have helpers, we needn't define one.
23
21
 
24
- Fix this by using a more restrictive regex pattern that looks for the patterns
25
- `(.:format)`, `.:format` or `/` at the end of the path. Note that we need to
26
- allow for multiple closing parenthesis since the route may be of this form:
22
+ Fixes #24304
27
23
 
28
- ``` ruby
29
- get "/books(/:action(.:format))", controller: "books"
30
- ```
24
+ *Ryan T. Hosford*
31
25
 
32
- This probably isn't what's intended since it means that the default index action
33
- route doesn't support a format but we have a test for it so we need to allow it.
26
+ * ETags: Introduce `Response#strong_etag=` and `#weak_etag=` and analogous
27
+ options for `fresh_when` and `stale?`. `Response#etag=` sets a weak ETag.
34
28
 
35
- Fixes #28517.
29
+ Strong ETags are desirable when you're serving byte-for-byte identical
30
+ responses that support Range requests, like PDFs or videos (typically
31
+ done by reproxying the response from a backend storage service).
32
+ Also desirable when fronted by some CDNs that support strong ETags
33
+ only, like Akamai.
36
34
 
37
- *Andrew White*
35
+ *Jeremy Daer*
38
36
 
37
+ * ETags: No longer strips quotes (") from ETag values before comparing them.
38
+ Quotes are significant, part of the ETag. A quoted ETag and an unquoted
39
+ one are not the same entity.
39
40
 
40
- ## Rails 4.2.8 (February 21, 2017) ##
41
+ *Jeremy Daer*
41
42
 
42
- * No changes.
43
+ * ETags: Support `If-None-Match: *`. Rarely useful for GET requests; meant
44
+ to provide some optimistic concurrency control for PUT requests.
43
45
 
46
+ *Jeremy Daer*
44
47
 
45
- ## Rails 4.2.7 (July 12, 2016) ##
48
+ * `ActionDispatch::ParamsParser` is deprecated and was removed from the middleware
49
+ stack. To configure the parameter parsers use `ActionDispatch::Request.parameter_parsers=`.
46
50
 
47
- * No changes.
51
+ *tenderlove*
48
52
 
53
+ * When a `respond_to` collector with a block doesn't have a response, then
54
+ a `:no_content` response should be rendered. This brings the default
55
+ rendering behavior introduced by https://github.com/rails/rails/issues/19036
56
+ to controller methods employing `respond_to`.
49
57
 
50
- ## Rails 4.2.6 (March 07, 2016) ##
58
+ *Justin Coyne*
51
59
 
52
- * No changes.
60
+ * Add `ActionController::Parameters#dig` on Ruby 2.3 and greater, which
61
+ behaves the same as `Hash#dig`.
53
62
 
63
+ *Sean Griffin*
54
64
 
55
- ## Rails 4.2.5.2 (February 26, 2016) ##
65
+ * Add request headers in the payload of the `start_processing.action_controller`
66
+ and `process_action.action_controller` notifications.
56
67
 
57
- * Do not allow render with unpermitted parameter.
68
+ *Gareth du Plooy*
58
69
 
59
- Fixes CVE-2016-2098.
70
+ * Add `action_dispatch_integration_test` load hook. The hook can be used to
71
+ extend `ActionDispatch::IntegrationTest` once it has been loaded.
60
72
 
61
- *Arthur Neves*
73
+ *Yuichiro Kaneko*
62
74
 
75
+ * Update default rendering policies when the controller action did
76
+ not explicitly indicate a response.
63
77
 
64
- ## Rails 4.2.5.1 (January 25, 2015) ##
78
+ For API controllers, the implicit render always renders "204 No Content"
79
+ and does not account for any templates.
65
80
 
66
- * No changes.
81
+ For other controllers, the following conditions are checked:
67
82
 
83
+ First, if a template exists for the controller action, it is rendered.
84
+ This template lookup takes into account the action name, locales, format,
85
+ variant, template handlers, etc. (see `render` for details).
68
86
 
69
- ## Rails 4.2.5 (November 12, 2015) ##
87
+ Second, if other templates exist for the controller action but is not in
88
+ the right format (or variant, etc.), an `ActionController::UnknownFormat`
89
+ is raised. The list of available templates is assumed to be a complete
90
+ enumeration of all the possible formats (or variants, etc.); that is,
91
+ having only HTML and JSON templates indicate that the controller action is
92
+ not meant to handle XML requests.
70
93
 
71
- * `ActionController::TestCase` can teardown gracefully if an error is raised
72
- early in the `setup` chain.
94
+ Third, if the current request is an "interactive" browser request (the user
95
+ navigated here by entering the URL in the address bar, submitting a form,
96
+ clicking on a link, etc. as opposed to an XHR or non-browser API request),
97
+ `ActionView::UnknownFormat` is raised to display a helpful error
98
+ message.
73
99
 
74
- *Yves Senn*
100
+ Finally, it falls back to the same "204 No Content" behavior as API controllers.
75
101
 
76
- * Parse RSS/ATOM responses as XML, not HTML.
102
+ *Godfrey Chan*, *Jon Moss*, *Kasper Timm Hansen*, *Mike Clark*, *Matthew Draper*
77
103
 
78
- *Alexander Kaupanin*
104
+ * Add "application/gzip" as a default mime type.
79
105
 
80
- * Fix regression in mounted engine named routes generation for app deployed to
81
- a subdirectory. `relative_url_root` was prepended to the path twice (e.g.
82
- "/subdir/subdir/engine_path" instead of "/subdir/engine_path")
106
+ *Mehmet Emin İNAÇ*
83
107
 
84
- Fixes #20920. Fixes #21459.
108
+ * Add request encoding and response parsing to integration tests.
85
109
 
86
- *Matthew Erhard*
110
+ What previously was:
87
111
 
88
- * `url_for` does not modify its arguments when generating polymorphic URLs.
112
+ ```ruby
113
+ require 'test_helper'
114
+
115
+ class ApiTest < ActionDispatch::IntegrationTest
116
+ test 'creates articles' do
117
+ assert_difference -> { Article.count } do
118
+ post articles_path(format: :json),
119
+ params: { article: { title: 'Ahoy!' } }.to_json,
120
+ headers: { 'Content-Type' => 'application/json' }
121
+ end
122
+
123
+ assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, JSON.parse(response.body))
124
+ end
125
+ end
126
+ ```
89
127
 
90
- *Bernerd Schaefer*
128
+ Can now be written as:
91
129
 
92
- * Update `ActionController::TestSession#fetch` to behave more like
93
- `ActionDispatch::Request::Session#fetch` when using non-string keys.
130
+ ```ruby
131
+ require 'test_helper'
94
132
 
95
- *Jeremy Friesen*
133
+ class ApiTest < ActionDispatch::IntegrationTest
134
+ test 'creates articles' do
135
+ assert_difference -> { Article.count } do
136
+ post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json
137
+ end
96
138
 
139
+ assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, response.parsed_body)
140
+ end
141
+ end
142
+ ```
97
143
 
98
- ## Rails 4.2.4 (August 24, 2015) ##
144
+ Passing `as: :json` to integration test request helpers will set the format,
145
+ content type and encode the parameters as JSON.
99
146
 
100
- * ActionController::TestSession now accepts a default value as well as
101
- a block for generating a default value based off the key provided.
147
+ Then on the response side, `parsed_body` will parse the body according to the
148
+ content type the response has.
102
149
 
103
- This fixes calls to session#fetch in ApplicationController instances that
104
- take more two arguments or a block from raising `ArgumentError: wrong
105
- number of arguments (2 for 1)` when performing controller tests.
150
+ Currently JSON is the only supported MIME type. Add your own with
151
+ `ActionDispatch::IntegrationTest.register_encoder`.
106
152
 
107
- *Matthew Gerrior*
153
+ *Kasper Timm Hansen*
108
154
 
109
- * Fix to keep original header instance in `ActionDispatch::SSL`
155
+ * Add "image/svg+xml" as a default mime type.
110
156
 
111
- `ActionDispatch::SSL` changes headers to `Hash`.
112
- So some headers will be broken if there are some middlewares
113
- on `ActionDispatch::SSL` and if it uses `Rack::Utils::HeaderHash`.
157
+ *DHH*
114
158
 
115
- *Fumiaki Matsushima*
159
+ * Add `-g` and `-c` options to `bin/rails routes`. These options return the url `name`, `verb` and
160
+ `path` field that match the pattern or match a specific controller.
116
161
 
162
+ Deprecate `CONTROLLER` env variable in `bin/rails routes`.
117
163
 
118
- ## Rails 4.2.3 (June 25, 2015) ##
164
+ See #18902.
119
165
 
120
- * Fix rake routes not showing the right format when
121
- nesting multiple routes.
166
+ *Anton Davydov*, *Vipul A M*
122
167
 
123
- See #18373.
168
+ * Response etags to always be weak: Prefixes 'W/' to value returned by
169
+ `ActionDispatch::Http::Cache::Response#etag=`, such that etags set in
170
+ `fresh_when` and `stale?` are weak.
124
171
 
125
- *Ravil Bayramgalin*
172
+ Fixes #17556.
126
173
 
127
- * Fix regression where a gzip file response would have a Content-type,
128
- even when it was a 304 status code.
174
+ *Abhishek Yadav*
129
175
 
130
- See #19271.
176
+ * Provide the name of HTTP Status code in assertions.
131
177
 
132
- *Kohei Suzuki*
178
+ *Sean Collins*
133
179
 
134
- * Fix handling of empty X_FORWARDED_HOST header in raw_host_with_port
180
+ * More explicit error message when running `rake routes`. `CONTROLLER` argument
181
+ can now be supplied in different ways:
182
+ `Rails::WelcomeController`, `Rails::Welcome`, `rails/welcome`.
135
183
 
136
- Previously, an empty X_FORWARDED_HOST header would cause
137
- Actiondispatch::Http:URL.raw_host_with_port to return nil, causing
138
- Actiondispatch::Http:URL.host to raise a NoMethodError.
184
+ Fixes #22918.
139
185
 
140
- *Adam Forsyth*
186
+ *Edouard Chin*
141
187
 
142
- * Fallback to `ENV['RAILS_RELATIVE_URL_ROOT']` in `url_for`.
188
+ * Allow `ActionController::Parameters` instances as an argument to URL
189
+ helper methods. An `ArgumentError` will be raised if the passed parameters
190
+ are not secure.
143
191
 
144
- Fixed an issue where the `RAILS_RELATIVE_URL_ROOT` environment variable is not
145
- prepended to the path when `url_for` is called. If `SCRIPT_NAME` (used by Rack)
146
- is set, it takes precedence.
192
+ Fixes #22832.
147
193
 
148
- Fixes #5122.
194
+ *Prathamesh Sonpatki*
149
195
 
150
- *Yasyf Mohamedali*
196
+ * Add option for per-form CSRF tokens.
151
197
 
152
- * Fix regression in functional tests. Responses should have default headers
153
- assigned.
198
+ *Greg Ose*, *Ben Toews*
154
199
 
155
- See #18423.
200
+ * Fix `ActionController::Parameters#convert_parameters_to_hashes` to return filtered
201
+ or unfiltered values based on from where it is called, `to_h` or `to_unsafe_h`
202
+ respectively.
156
203
 
157
- *Jeremy Kemper*, *Yves Senn*
204
+ Fixes #22841.
158
205
 
206
+ *Prathamesh Sonpatki*
159
207
 
160
- ## Rails 4.2.2 (June 16, 2015) ##
208
+ * Add `ActionController::Parameters#include?`
161
209
 
162
- * No Changes *
210
+ *Justin Coyne*
163
211
 
212
+ * Deprecate `redirect_to :back` in favor of `redirect_back`, which accepts a
213
+ required `fallback_location` argument, thus eliminating the possibility of a
214
+ `RedirectBackError`.
164
215
 
165
- ## Rails 4.2.1 (March 19, 2015) ##
216
+ *Derek Prior*
166
217
 
167
- * Non-string authenticity tokens do not raise NoMethodError when decoding
168
- the masked token.
218
+ * Add `redirect_back` method to `ActionController::Redirecting` to provide a
219
+ way to safely redirect to the `HTTP_REFERER` if it is present, falling back
220
+ to a provided redirect otherwise.
169
221
 
170
- *Ville Lautanala*
222
+ *Derek Prior*
171
223
 
172
- * Explicitly ignored wildcard verbs when searching for HEAD routes before fallback
224
+ * `ActionController::TestCase` will be moved to its own gem in Rails 5.1.
173
225
 
174
- Fixes an issue where a mounted rack app at root would intercept the HEAD
175
- request causing an incorrect behavior during the fall back to GET requests.
226
+ With the speed improvements made to `ActionDispatch::IntegrationTest` we no
227
+ longer need to keep two separate code bases for testing controllers. In
228
+ Rails 5.1 `ActionController::TestCase` will be deprecated and moved into a
229
+ gem outside of Rails source.
230
+
231
+ This is a documentation deprecation so that going forward new tests will use
232
+ `ActionDispatch::IntegrationTest` instead of `ActionController::TestCase`.
233
+
234
+ *Eileen M. Uchitelle*
235
+
236
+ * Add a `response_format` option to `ActionDispatch::DebugExceptions`
237
+ to configure the format of the response when errors occur in
238
+ development mode.
239
+
240
+ If `response_format` is `:default` the debug info will be rendered
241
+ in an HTML page. In the other hand, if the provided value is `:api`
242
+ the debug info will be rendered in the original response format.
243
+
244
+ *Jorge Bejar*
245
+
246
+ * Change the `protect_from_forgery` prepend default to `false`.
247
+
248
+ Per this comment
249
+ https://github.com/rails/rails/pull/18334#issuecomment-69234050 we want
250
+ `protect_from_forgery` to default to `prepend: false`.
251
+
252
+ `protect_from_forgery` will now be inserted into the callback chain at the
253
+ point it is called in your application. This is useful for cases where you
254
+ want to `protect_from_forgery` after you perform required authentication
255
+ callbacks or other callbacks that are required to run after forgery protection.
256
+
257
+ If you want `protect_from_forgery` callbacks to always run first, regardless of
258
+ position they are called in your application then you can add `prepend: true`
259
+ to your `protect_from_forgery` call.
176
260
 
177
261
  Example:
262
+
178
263
  ```ruby
179
- draw do
180
- get '/home' => 'test#index'
181
- mount rack_app, at: '/'
182
- end
183
- head '/home'
184
- assert_response :success
264
+ protect_from_forgery prepend: true
185
265
  ```
186
- In this case, a HEAD request runs through the routes the first time and fails
187
- to match anything. Then, it runs through the list with the fallback and matches
188
- `get '/home'`. The original behavior would match the rack app in the first pass.
189
266
 
190
- *Terence Sun*
267
+ *Eileen M. Uchitelle*
191
268
 
192
- * Preserve default format when generating URLs
269
+ * In url_for, never append a question mark to the URL when the query string
270
+ is empty anyway. (It used to do that when called like `url_for(controller:
271
+ 'x', action: 'y', q: {})`.)
193
272
 
194
- Fixes an issue that would cause the format set in default_url_options to be
195
- lost when generating URLs with fewer positional arguments than parameters in
196
- the route definition.
273
+ *Paul Grayson*
197
274
 
198
- Backport of #18627
275
+ * Catch invalid UTF-8 querystring values and respond with BadRequest
199
276
 
200
- *Tekin Suleyman*, *Dominic Baggott*
277
+ Check querystring params for invalid UTF-8 characters, and raise an
278
+ ActionController::BadRequest error if present. Previously these strings
279
+ would typically trigger errors further down the stack.
201
280
 
202
- * Default headers, removed in controller actions, are no longer reapplied on
203
- the test response.
281
+ *Grey Baker*
204
282
 
205
- *Jonas Baumann*
283
+ * Parse RSS/ATOM responses as XML, not HTML.
206
284
 
207
- * Ensure `append_info_to_payload` is called even if an exception is raised.
285
+ *Alexander Kaupanin*
208
286
 
209
- Fixes an issue where when an exception is raised in the request the additonal
210
- payload data is not available.
287
+ * Show helpful message in `BadRequest` exceptions due to invalid path
288
+ parameter encodings.
211
289
 
212
- See:
213
- * #14903
214
- * https://github.com/roidrage/lograge/issues/37
290
+ Fixes #21923.
215
291
 
216
- *Dieter Komendera*, *Margus Pärt*
292
+ *Agis Anastasopoulos*
217
293
 
218
- * Correctly rely on the response's status code to handle calls to `head`.
294
+ * Add the ability of returning arbitrary headers to `ActionDispatch::Static`.
219
295
 
220
- *Robin Dupret*
296
+ Now ActionDispatch::Static can accept HTTP headers so that developers
297
+ will have control of returning arbitrary headers like
298
+ 'Access-Control-Allow-Origin' when a response is delivered. They can be
299
+ configured with `#config`:
221
300
 
222
- * Using `head` method returns empty response_body instead
223
- of returning a single space " ".
301
+ Example:
224
302
 
225
- The old behavior was added as a workaround for a bug in an early
226
- version of Safari, where the HTTP headers are not returned correctly
227
- if the response body has a 0-length. This is been fixed since and
228
- the workaround is no longer necessary.
303
+ config.public_file_server.headers = {
304
+ "Cache-Control" => "public, max-age=60",
305
+ "Access-Control-Allow-Origin" => "http://rubyonrails.org"
306
+ }
229
307
 
230
- Fixes #18253.
308
+ *Yuki Nishijima*
231
309
 
232
- *Prathamesh Sonpatki*
310
+ * Allow multiple `root` routes in same scope level. Example:
233
311
 
234
- * Fix how polymorphic routes works with objects that implement `to_model`.
312
+ Example:
235
313
 
236
- *Travis Grathwell*
314
+ root 'blog#show', constraints: ->(req) { Hostname.blog_site?(req.host) }
315
+ root 'landing#show'
237
316
 
238
- * Fixed handling of positional url helper arguments when `format: false`.
317
+ *Rafael Sales*
239
318
 
240
- Fixes #17819.
319
+ * Fix regression in mounted engine named routes generation for app deployed to
320
+ a subdirectory. `relative_url_root` was prepended to the path twice (e.g.
321
+ "/subdir/subdir/engine_path" instead of "/subdir/engine_path")
241
322
 
242
- *Andrew White*, *Tatiana Soukiassian*
323
+ Fixes #20920. Fixes #21459.
243
324
 
244
- * Fixed usage of optional scopes in URL helpers.
325
+ *Matthew Erhard*
245
326
 
246
- *Alex Robbin*
327
+ * `ActionDispatch::Response#new` no longer applies default headers. If you want
328
+ default headers applied to the response object, then call
329
+ `ActionDispatch::Response.create`. This change only impacts people who are
330
+ directly constructing an `ActionDispatch::Response` object.
247
331
 
332
+ * Accessing mime types via constants like `Mime::HTML` is deprecated. Please
333
+ change code like this:
248
334
 
249
- ## Rails 4.2.0 (December 20, 2014) ##
335
+ Mime::HTML
250
336
 
251
- * Add `ActionController::Parameters#to_unsafe_h` to return an unfiltered
252
- `Hash` representation of Parameters object. This is now a preferred way to
253
- retrieve unfiltered parameters as we will stop inheriting `AC::Parameters`
254
- object in Rails 5.0.
337
+ To this:
255
338
 
256
- *Prem Sichanugrist*
339
+ Mime[:html]
257
340
 
258
- * Restore handling of a bare `Authorization` header, without `token=`
259
- prefix.
341
+ This change is so that Rails will not manage a list of constants, and fixes
342
+ an issue where if a type isn't registered you could possibly get the wrong
343
+ object.
260
344
 
261
- Fixes #17108.
345
+ `Mime[:html]` is available in older versions of Rails, too, so you can
346
+ safely change libraries and plugins and maintain compatibility with
347
+ multiple versions of Rails.
262
348
 
263
- *Guo Xiang Tan*
349
+ * `url_for` does not modify its arguments when generating polymorphic URLs.
264
350
 
265
- * Deprecate use of string keys in URL helpers.
351
+ *Bernerd Schaefer*
266
352
 
267
- Use symbols instead.
268
- Fixes #16958.
353
+ * Make it easier to opt in to `config.force_ssl` and `config.ssl_options` by
354
+ making them less dangerous to try and easier to disable.
355
+
356
+ SSL redirect:
357
+ * Move `:host` and `:port` options within `redirect: { … }`. Deprecate.
358
+ * Introduce `:status` and `:body` to customize the redirect response.
359
+ The 301 permanent default makes it difficult to test the redirect and
360
+ back out of it since browsers remember the 301. Test with a 302 or 307
361
+ instead, then switch to 301 once you're confident that all is well.
362
+
363
+ HTTP Strict Transport Security (HSTS):
364
+ * Shorter max-age. Shorten the default max-age from 1 year to 180 days,
365
+ the low end for https://www.ssllabs.com/ssltest/ grading and greater
366
+ than the 18-week minimum to qualify for browser preload lists.
367
+ * Disabling HSTS. Setting `hsts: false` now sets `hsts { expires: 0 }`
368
+ instead of omitting the header. Omitting does nothing to disable HSTS
369
+ since browsers hang on to your previous settings until they expire.
370
+ Sending `{ hsts: { expires: 0 }}` flushes out old browser settings and
371
+ actually disables HSTS:
372
+ http://tools.ietf.org/html/rfc6797#section-6.1.1
373
+ * HSTS Preload. Introduce `preload: true` to set the `preload` flag,
374
+ indicating that your site may be included in browser preload lists,
375
+ including Chrome, Firefox, Safari, IE11, and Edge. Submit your site:
376
+ https://hstspreload.appspot.com
377
+
378
+ *Jeremy Daer*
269
379
 
270
- *Byron Bischoff*, *Melanie Gilman*
380
+ * Update `ActionController::TestSession#fetch` to behave more like
381
+ `ActionDispatch::Request::Session#fetch` when using non-string keys.
271
382
 
272
- * Deprecate the `only_path` option on `*_path` helpers.
383
+ *Jeremy Friesen*
273
384
 
274
- In cases where this option is set to `true`, the option is redundant and can
275
- be safely removed; otherwise, the corresponding `*_url` helper should be
276
- used instead.
385
+ * Using strings or symbols for middleware class names is deprecated. Convert
386
+ things like this:
277
387
 
278
- Fixes #17294.
388
+ middleware.use "Foo::Bar"
279
389
 
280
- *Dan Olson*, *Godfrey Chan*
390
+ to this:
281
391
 
282
- * Improve Journey compliance to RFC 3986.
392
+ middleware.use Foo::Bar
283
393
 
284
- The scanner in Journey failed to recognize routes that use literals
285
- from the sub-delims section of RFC 3986. It's now able to parse those
286
- authorized delimiters and route as expected.
394
+ * `ActionController::TestSession` now accepts a default value as well as
395
+ a block for generating a default value based off the key provided.
287
396
 
288
- Fixes #17212.
397
+ This fixes calls to `session#fetch` in `ApplicationController` instances that
398
+ take more two arguments or a block from raising `ArgumentError: wrong
399
+ number of arguments (2 for 1)` when performing controller tests.
289
400
 
290
- *Nicolas Cavigneaux*
401
+ *Matthew Gerrior*
291
402
 
292
- * Deprecate implicit Array conversion for Response objects. It was added
293
- (using `#to_ary`) so we could conveniently use implicit splatting:
403
+ * Fix `ActionController::Parameters#fetch` overwriting `KeyError` returned by
404
+ default block.
294
405
 
295
- status, headers, body = response
406
+ *Jonas Schuber Erlandsson*, *Roque Pinel*
296
407
 
297
- But it also means `response + response` works and `[response].flatten`
298
- cascades down to the Rack body. Nonsense behavior. Instead, rely on
299
- explicit conversion and splatting with `#to_a`:
408
+ * `ActionController::Parameters` no longer inherits from
409
+ `HashWithIndifferentAccess`
300
410
 
301
- status, header, body = *response
411
+ Inheriting from `HashWithIndifferentAccess` allowed users to call any
412
+ enumerable methods on `Parameters` object, resulting in a risk of losing the
413
+ `permitted?` status or even getting back a pure `Hash` object instead of
414
+ a `Parameters` object with proper sanitization.
302
415
 
303
- *Jeremy Kemper*
416
+ By not inheriting from `HashWithIndifferentAccess`, we are able to make
417
+ sure that all methods that are defined in `Parameters` object will return
418
+ a proper `Parameters` object with a correct `permitted?` flag.
304
419
 
305
- * Don't rescue `IPAddr::InvalidAddressError`.
420
+ *Prem Sichanugrist*
306
421
 
307
- `IPAddr::InvalidAddressError` does not exist in Ruby 1.9.3
308
- and fails for JRuby in 1.9 mode.
422
+ * Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
423
+ from the concurrent-ruby gem.
309
424
 
310
- *Peter Suschlik*
425
+ *Jerry D'Antonio*
311
426
 
312
- * Fix bug where the router would ignore any constraints added to redirect
313
- routes.
427
+ * Add ability to filter parameters based on parent keys.
314
428
 
315
- Fixes #16605.
429
+ # matches {credit_card: {code: "xxxx"}}
430
+ # doesn't match {file: { code: "xxxx"}}
431
+ config.filter_parameters += [ "credit_card.code" ]
316
432
 
317
- *Agis Anastasopoulos*
433
+ See #13897.
318
434
 
319
- * Allow `config.action_dispatch.trusted_proxies` to accept an IPAddr object.
435
+ *Guillaume Malette*
320
436
 
321
- Example:
437
+ * Deprecate passing first parameter as `Hash` and default status code for `head` method.
322
438
 
323
- # config/environments/production.rb
324
- config.action_dispatch.trusted_proxies = IPAddr.new('4.8.15.0/16')
439
+ *Mehmet Emin İNAÇ*
325
440
 
326
- *Sam Aarons*
441
+ * Adds`Rack::Utils::ParameterTypeError` and `Rack::Utils::InvalidParameterError`
442
+ to the rescue_responses hash in `ExceptionWrapper` (Rack recommends
443
+ integrators serve 400s for both of these).
327
444
 
328
- * Avoid duplicating routes for HEAD requests.
445
+ *Grey Baker*
329
446
 
330
- Instead of duplicating the routes, we will first match the HEAD request to
331
- HEAD routes. If no match is found, we will then map the HEAD request to
332
- GET routes.
447
+ * Add support for API only apps.
448
+ `ActionController::API` is added as a replacement of
449
+ `ActionController::Base` for this kind of applications.
333
450
 
334
- *Guo Xiang Tan*, *Andrew White*
451
+ *Santiago Pastorino*, *Jorge Bejar*
335
452
 
336
- * Requests that hit `ActionDispatch::Static` can now take advantage
337
- of gzipped assets on disk. By default a gzip asset will be served if
338
- the client supports gzip and a compressed file is on disk.
453
+ * Remove `assigns` and `assert_template`. Both methods have been extracted
454
+ into a gem at https://github.com/rails/rails-controller-testing.
339
455
 
340
- *Richard Schneeman*
456
+ See #18950.
341
457
 
342
- * `ActionController::Parameters` will stop inheriting from `Hash` and
343
- `HashWithIndifferentAccess` in the next major release. If you use any method
344
- that is not available on `ActionController::Parameters` you should consider
345
- calling `#to_h` to convert it to a `Hash` first before calling that method.
458
+ *Alan Guo Xiang Tan*
346
459
 
347
- *Prem Sichanugrist*
460
+ * `FileHandler` and `Static` middleware initializers accept `index` argument
461
+ to configure the directory index file name. Defaults to `index` (as in
462
+ `index.html`).
348
463
 
349
- * `ActionController::Parameters#to_h` now returns a `Hash` with unpermitted
350
- keys removed. This change is to reflect on a security concern where some
351
- method performed on an `ActionController::Parameters` may yield a `Hash`
352
- object which does not maintain `permitted?` status. If you would like to
353
- get a `Hash` with all the keys intact, duplicate and mark it as permitted
354
- before calling `#to_h`.
464
+ See #20017.
355
465
 
356
- params = ActionController::Parameters.new({
357
- name: 'Senjougahara Hitagi',
358
- oddity: 'Heavy stone crab'
359
- })
360
- params.to_h
361
- # => {}
466
+ *Eliot Sykes*
362
467
 
363
- unsafe_params = params.dup.permit!
364
- unsafe_params.to_h
365
- # => {"name"=>"Senjougahara Hitagi", "oddity"=>"Heavy stone crab"}
468
+ * Deprecate `:nothing` option for `render` method.
366
469
 
367
- safe_params = params.permit(:name)
368
- safe_params.to_h
369
- # => {"name"=>"Senjougahara Hitagi"}
470
+ *Mehmet Emin İNAÇ*
370
471
 
371
- This change is consider a stopgap as we cannot change the code to stop
372
- `ActionController::Parameters` to inherit from `HashWithIndifferentAccess`
373
- in the next minor release.
472
+ * Fix `rake routes` not showing the right format when
473
+ nesting multiple routes.
374
474
 
375
- *Prem Sichanugrist*
475
+ See #18373.
376
476
 
377
- * Deprecated `TagAssertions`.
477
+ *Ravil Bayramgalin*
378
478
 
379
- *Kasper Timm Hansen*
479
+ * Add ability to override default form builder for a controller.
380
480
 
381
- * Use the Active Support JSON encoder for cookie jars using the `:json` or
382
- `:hybrid` serializer. This allows you to serialize custom Ruby objects into
383
- cookies by defining the `#as_json` hook on such objects.
481
+ class AdminController < ApplicationController
482
+ default_form_builder AdminFormBuilder
483
+ end
384
484
 
385
- Fixes #16520.
485
+ *Kevin McPhillips*
386
486
 
387
- *Godfrey Chan*
487
+ * For actions with no corresponding templates, render `head :no_content`
488
+ instead of raising an error. This allows for slimmer API controller
489
+ methods that simply work, without needing further instructions.
388
490
 
389
- * Add `config.action_dispatch.cookies_digest` option for setting custom
390
- digest. The default remains the same - 'SHA1'.
491
+ See #19036.
391
492
 
392
- *Łukasz Strzałkowski*
493
+ *Stephen Bussey*
393
494
 
394
- * Move `respond_with` (and the class-level `respond_to`) to
395
- the `responders` gem.
495
+ * Provide friendlier access to request variants.
396
496
 
397
- *José Valim*
497
+ request.variant = :phone
498
+ request.variant.phone? # true
499
+ request.variant.tablet? # false
398
500
 
399
- * When your templates change, browser caches bust automatically.
501
+ request.variant = [:phone, :tablet]
502
+ request.variant.phone? # true
503
+ request.variant.desktop? # false
504
+ request.variant.any?(:phone, :desktop) # true
505
+ request.variant.any?(:desktop, :watch) # false
400
506
 
401
- New default: the template digest is automatically included in your ETags.
402
- When you call `fresh_when @post`, the digest for `posts/show.html.erb`
403
- is mixed in so future changes to the HTML will blow HTTP caches for you.
404
- This makes it easy to HTTP-cache many more of your actions.
507
+ *George Claghorn*
405
508
 
406
- If you render a different template, you can now pass the `:template`
407
- option to include its digest instead:
509
+ * Fix regression where a gzip file response would have a Content-type,
510
+ even when it was a 304 status code.
511
+
512
+ See #19271.
408
513
 
409
- fresh_when @post, template: 'widgets/show'
514
+ *Kohei Suzuki*
410
515
 
411
- Pass `template: false` to skip the lookup. To turn this off entirely, set:
516
+ * Fix handling of empty `X_FORWARDED_HOST` header in `raw_host_with_port`.
412
517
 
413
- config.action_controller.etag_with_template_digest = false
518
+ Previously, an empty `X_FORWARDED_HOST` header would cause
519
+ `Actiondispatch::Http:URL.raw_host_with_port` to return `nil`, causing
520
+ `Actiondispatch::Http:URL.host` to raise a `NoMethodError`.
414
521
 
415
- *Jeremy Kemper*
522
+ *Adam Forsyth*
416
523
 
417
- * Remove deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
418
- in favor of `AbstractController::Helpers::MissingHelperError`.
524
+ * Allow `Bearer` as token-keyword in `Authorization-Header`.
419
525
 
420
- *Yves Senn*
526
+ Additionally to `Token`, the keyword `Bearer` is acceptable as a keyword
527
+ for the auth-token. The `Bearer` keyword is described in the original
528
+ OAuth RFC and used in libraries like Angular-JWT.
421
529
 
422
- * Fix `assert_template` not being able to assert that no files were rendered.
530
+ See #19094.
531
+
532
+ *Peter Schröder*
533
+
534
+ * Drop request class from `RouteSet` constructor.
535
+
536
+ If you would like to use a custom request class, please subclass and implement
537
+ the `request_class` method.
538
+
539
+ *tenderlove@ruby-lang.org*
540
+
541
+ * Fallback to `ENV['RAILS_RELATIVE_URL_ROOT']` in `url_for`.
542
+
543
+ Fixed an issue where the `RAILS_RELATIVE_URL_ROOT` environment variable is not
544
+ prepended to the path when `url_for` is called. If `SCRIPT_NAME` (used by Rack)
545
+ is set, it takes precedence.
546
+
547
+ Fixes #5122.
548
+
549
+ *Yasyf Mohamedali*
550
+
551
+ * Partitioning of routes is now done when the routes are being drawn. This
552
+ helps to decrease the time spent filtering the routes during the first request.
423
553
 
424
554
  *Guo Xiang Tan*
425
555
 
426
- * Extract source code for the entire exception stack trace for
427
- better debugging and diagnosis.
556
+ * Fix regression in functional tests. Responses should have default headers
557
+ assigned.
428
558
 
429
- *Ryan Dao*
559
+ See #18423.
430
560
 
431
- * Allows ActionDispatch::Request::LOCALHOST to match any IPv4 127.0.0.0/8
432
- loopback address.
561
+ *Jeremy Kemper*, *Yves Senn*
433
562
 
434
- *Earl St Sauver*, *Sven Riedel*
563
+ * Deprecate `AbstractController#skip_action_callback` in favor of individual skip_callback methods
564
+ (which can be made to raise an error if no callback was removed).
435
565
 
436
- * Preserve original path in `ShowExceptions` middleware by stashing it as
437
- `env["action_dispatch.original_path"]`
566
+ *Iain Beeston*
438
567
 
439
- `ActionDispatch::ShowExceptions` overwrites `PATH_INFO` with the status code
440
- for the exception defined in `ExceptionWrapper`, so the path
441
- the user was visiting when an exception occurred was not previously
442
- available to any custom exceptions_app. The original `PATH_INFO` is now
443
- stashed in `env["action_dispatch.original_path"]`.
568
+ * Alias the `ActionDispatch::Request#uuid` method to `ActionDispatch::Request#request_id`.
569
+ Due to implementation, `config.log_tags = [:request_id]` also works in substitute
570
+ for `config.log_tags = [:uuid]`.
444
571
 
445
- *Grey Baker*
572
+ *David Ilizarov*
446
573
 
447
- * Use `String#bytesize` instead of `String#size` when checking for cookie
448
- overflow.
574
+ * Change filter on /rails/info/routes to use an actual path regexp from rails
575
+ and not approximate javascript version. Oniguruma supports much more
576
+ extensive list of features than javascript regexp engine.
449
577
 
450
- *Agis Anastasopoulos*
578
+ Fixes #18402.
579
+
580
+ *Ravil Bayramgalin*
581
+
582
+ * Non-string authenticity tokens do not raise NoMethodError when decoding
583
+ the masked token.
451
584
 
452
- * `render nothing: true` or rendering a `nil` body no longer add a single
453
- space to the response body.
585
+ *Ville Lautanala*
454
586
 
455
- The old behavior was added as a workaround for a bug in an early version of
456
- Safari, where the HTTP headers are not returned correctly if the response
457
- body has a 0-length. This is been fixed since and the workaround is no
458
- longer necessary.
587
+ * Add `http_cache_forever` to Action Controller, so we can cache a response
588
+ that never gets expired.
459
589
 
460
- Use `render body: ' '` if the old behavior is desired.
590
+ *arthurnn*
461
591
 
462
- See #14883 for details.
592
+ * `ActionController#translate` supports symbols as shortcuts.
593
+ When a shortcut is given it also performs the lookup without the action
594
+ name.
463
595
 
464
- *Godfrey Chan*
596
+ *Max Melentiev*
465
597
 
466
- * Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671
467
- ("Rosetta Flash").
598
+ * Expand `ActionController::ConditionalGet#fresh_when` and `stale?` to also
599
+ accept a collection of records as the first argument, so that the
600
+ following code can be written in a shorter form.
468
601
 
469
- *Greg Campbell*
602
+ # Before
603
+ def index
604
+ @articles = Article.all
605
+ fresh_when(etag: @articles, last_modified: @articles.maximum(:updated_at))
606
+ end
470
607
 
471
- * Because URI paths may contain non US-ASCII characters we need to force
472
- the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
473
- This essentially replicates the functionality of the monkey patch to
474
- URI.parser.unescape in active_support/core_ext/uri.rb.
608
+ # After
609
+ def index
610
+ @articles = Article.all
611
+ fresh_when(@articles)
612
+ end
475
613
 
476
- Fixes #16104.
614
+ *claudiob*
477
615
 
478
- *Karl Entwistle*
616
+ * Explicitly ignored wildcard verbs when searching for HEAD routes before fallback
479
617
 
480
- * Generate shallow paths for all children of shallow resources.
618
+ Fixes an issue where a mounted rack app at root would intercept the HEAD
619
+ request causing an incorrect behavior during the fall back to GET requests.
481
620
 
482
- Fixes #15783.
621
+ Example:
483
622
 
484
- *Seb Jacobs*
623
+ draw do
624
+ get '/home' => 'test#index'
625
+ mount rack_app, at: '/'
626
+ end
627
+ head '/home'
628
+ assert_response :success
485
629
 
486
- * JSONP responses are now rendered with the `text/javascript` content type
487
- when rendering through a `respond_to` block.
630
+ In this case, a HEAD request runs through the routes the first time and fails
631
+ to match anything. Then, it runs through the list with the fallback and matches
632
+ `get '/home'`. The original behavior would match the rack app in the first pass.
488
633
 
489
- Fixes #15081.
634
+ *Terence Sun*
490
635
 
491
- *Lucas Mazza*
636
+ * Discarded flash messages get removed before storing into session.
492
637
 
493
- * Add `config.action_controller.always_permitted_parameters` to configure which
494
- parameters are permitted globally. The default value of this configuration is
495
- `['controller', 'action']`.
638
+ *Samuel Cochran*
496
639
 
497
- *Gary S. Weaver*, *Rafael Chacon*
640
+ * Migrating xhr methods to keyword arguments syntax
641
+ in `ActionController::TestCase` and `ActionDispatch::Integration`
498
642
 
499
- * Fix env['PATH_INFO'] missing leading slash when a rack app mounted at '/'.
643
+ Old syntax:
500
644
 
501
- Fixes #15511.
645
+ xhr :get, :create, params: { id: 1 }
502
646
 
503
- *Larry Lv*
647
+ New syntax example:
504
648
 
505
- * ActionController::Parameters#require now accepts `false` values.
649
+ get :create, params: { id: 1 }, xhr: true
506
650
 
507
- Fixes #15685.
651
+ *Kir Shatrov*
508
652
 
509
- *Sergio Romano*
653
+ * Migrating to keyword arguments syntax in `ActionController::TestCase` and
654
+ `ActionDispatch::Integration` HTTP request methods.
510
655
 
511
- * With authorization header `Authorization: Token token=`, `authenticate` now
512
- recognize token as nil, instead of "token".
656
+ Example:
513
657
 
514
- Fixes #14846.
658
+ post :create, params: { y: x }, session: { a: 'b' }
659
+ get :view, params: { id: 1 }
660
+ get :view, params: { id: 1 }, format: :json
515
661
 
516
- *Larry Lv*
662
+ *Kir Shatrov*
517
663
 
518
- * Ensure the controller is always notified as soon as the client disconnects
519
- during live streaming, even when the controller is blocked on a write.
664
+ * Preserve default url options when generating URLs.
520
665
 
521
- *Nicholas Jakobsen*, *Matthew Draper*
666
+ Fixes an issue that would cause `default_url_options` to be lost when
667
+ generating URLs with fewer positional arguments than parameters in the
668
+ route definition.
522
669
 
523
- * Routes specifying 'to:' must be a string that contains a "#" or a rack
524
- application. Use of a symbol should be replaced with `action: symbol`.
525
- Use of a string without a "#" should be replaced with `controller: string`.
670
+ *Tekin Suleyman*
526
671
 
527
- *Aaron Patterson*
672
+ * Deprecate `*_via_redirect` integration test methods.
528
673
 
529
- * Fix URL generation with `:trailing_slash` such that it does not add
530
- a trailing slash after `.:format`
674
+ Use `follow_redirect!` manually after the request call for the same behavior.
531
675
 
532
- *Dan Langevin*
676
+ *Aditya Kapoor*
533
677
 
534
- * Build full URI as string when processing path in integration tests for
535
- performance reasons. One consequence of this is that the leading slash
536
- is now required in integration test `process` helpers, whereas previously
537
- it could be omitted. The fact that this worked was a unintended consequence
538
- of the implementation and was never an intentional feature.
678
+ * Add `ActionController::Renderer` to render arbitrary templates
679
+ outside controller actions.
539
680
 
540
- *Guo Xiang Tan*
681
+ Its functionality is accessible through class methods `render` and
682
+ `renderer` of `ActionController::Base`.
541
683
 
542
- * Fix `'Stack level too deep'` when rendering `head :ok` in an action method
543
- called 'status' in a controller.
684
+ *Ravil Bayramgalin*
544
685
 
545
- Fixes #13905.
686
+ * Support `:assigns` option when rendering with controllers/mailers.
546
687
 
547
- *Christiaan Van den Poel*
688
+ *Ravil Bayramgalin*
548
689
 
549
- * Add MKCALENDAR HTTP method (RFC 4791).
690
+ * Default headers, removed in controller actions, are no longer reapplied on
691
+ the test response.
550
692
 
551
- *Sergey Karpesh*
693
+ *Jonas Baumann*
552
694
 
553
- * Instrument fragment cache metrics.
695
+ * Deprecate all `*_filter` callbacks in favor of `*_action` callbacks.
554
696
 
555
- Adds `:controller`: and `:action` keys to the instrumentation payload
556
- for the `*_fragment.action_controller` notifications. This allows tracking
557
- e.g. the fragment cache hit rates for each controller action.
697
+ *Rafael Mendonça França*
558
698
 
559
- *Daniel Schierbeck*
699
+ * Allow you to pass `prepend: false` to `protect_from_forgery` to have the
700
+ verification callback appended instead of prepended to the chain.
701
+ This allows you to let the verification step depend on prior callbacks.
560
702
 
561
- * Always use the provided port if the protocol is relative.
703
+ Example:
562
704
 
563
- Fixes #15043.
705
+ class ApplicationController < ActionController::Base
706
+ before_action :authenticate
707
+ protect_from_forgery prepend: false, unless: -> { @authenticated_by.oauth? }
564
708
 
565
- *Guilherme Cavalcanti*, *Andrew White*
709
+ private
710
+ def authenticate
711
+ if oauth_request?
712
+ # authenticate with oauth
713
+ @authenticated_by = 'oauth'.inquiry
714
+ else
715
+ # authenticate with cookies
716
+ @authenticated_by = 'cookie'.inquiry
717
+ end
718
+ end
719
+ end
566
720
 
567
- * Moved `params[request_forgery_protection_token]` into its own method
568
- and improved tests.
721
+ *Josef Šimánek*
569
722
 
570
- Fixes #11316.
723
+ * Remove `ActionController::HideActions`.
571
724
 
572
- *Tom Kadwill*
725
+ *Ravil Bayramgalin*
573
726
 
574
- * Added verification of route constraints given as a Proc or an object responding
575
- to `:matches?`. Previously, when given an non-complying object, it would just
576
- silently fail to enforce the constraint. It will now raise an `ArgumentError`
577
- when setting up the routes.
727
+ * Remove `respond_to`/`respond_with` placeholder methods, this functionality
728
+ has been extracted to the `responders` gem.
578
729
 
579
- *Xavier Defrang*
730
+ *Carlos Antonio da Silva*
580
731
 
581
- * Properly treat the entire IPv6 User Local Address space as private for
582
- purposes of remote IP detection. Also handle uppercase private IPv6
583
- addresses.
732
+ * Remove deprecated assertion files.
584
733
 
585
- Fixes #12638.
734
+ *Rafael Mendonça França*
586
735
 
587
- *Caleb Spare*
736
+ * Remove deprecated usage of string keys in URL helpers.
588
737
 
589
- * Fixed an issue with migrating legacy json cookies.
738
+ *Rafael Mendonça França*
590
739
 
591
- Previously, the `VerifyAndUpgradeLegacySignedMessage` assumes all incoming
592
- cookies are marshal-encoded. This is not the case when `secret_token` is
593
- used in conjunction with the `:json` or `:hybrid` serializer.
740
+ * Remove deprecated `only_path` option on `*_path` helpers.
594
741
 
595
- In those case, when upgrading to use `secret_key_base`, this would cause a
596
- `TypeError: incompatible marshal file format` and a 500 error for the user.
742
+ *Rafael Mendonça França*
597
743
 
598
- Fixes #14774.
744
+ * Remove deprecated `NamedRouteCollection#helpers`.
599
745
 
600
- *Godfrey Chan*
746
+ *Rafael Mendonça França*
601
747
 
602
- * Make URL escaping more consistent:
748
+ * Remove deprecated support to define routes with `:to` option that doesn't contain `#`.
603
749
 
604
- 1. Escape '%' characters in URLs - only unescaped data should be passed to URL helpers
605
- 2. Add an `escape_segment` helper to `Router::Utils` that escapes '/' characters
606
- 3. Use `escape_segment` rather than `escape_fragment` in optimized URL generation
607
- 4. Use `escape_segment` rather than `escape_path` in URL generation
750
+ *Rafael Mendonça França*
608
751
 
609
- For point 4 there are two exceptions. Firstly, when a route uses wildcard segments
610
- (e.g. `*foo`) then we use `escape_path` as the value may contain '/' characters. This
611
- means that wildcard routes can't be optimized. Secondly, if a `:controller` segment
612
- is used in the path then this uses `escape_path` as the controller may be namespaced.
752
+ * Remove deprecated `ActionDispatch::Response#to_ary`.
613
753
 
614
- Fixes #14629, #14636 and #14070.
754
+ *Rafael Mendonça França*
615
755
 
616
- *Andrew White*, *Edho Arief*
756
+ * Remove deprecated `ActionDispatch::Request#deep_munge`.
617
757
 
618
- * Add alias `ActionDispatch::Http::UploadedFile#to_io` to
619
- `ActionDispatch::Http::UploadedFile#tempfile`.
758
+ *Rafael Mendonça França*
620
759
 
621
- *Tim Linquist*
760
+ * Remove deprecated `ActionDispatch::Http::Parameters#symbolized_path_parameters`.
622
761
 
623
- * Returns null type format when format is not know and controller is using `any`
624
- format block.
762
+ *Rafael Mendonça França*
625
763
 
626
- Fixes #14462.
764
+ * Remove deprecated option `use_route` in controller tests.
627
765
 
628
766
  *Rafael Mendonça França*
629
767
 
630
- * Improve routing error page with fuzzy matching search.
768
+ * Ensure `append_info_to_payload` is called even if an exception is raised.
769
+
770
+ Fixes an issue where when an exception is raised in the request the additional
771
+ payload data is not available.
772
+
773
+ See #14903.
774
+
775
+ *Dieter Komendera*, *Margus Pärt*
776
+
777
+ * Correctly rely on the response's status code to handle calls to `head`.
778
+
779
+ *Robin Dupret*
780
+
781
+ * Using `head` method returns empty response_body instead
782
+ of returning a single space " ".
631
783
 
632
- *Winston*
784
+ The old behavior was added as a workaround for a bug in an early
785
+ version of Safari, where the HTTP headers are not returned correctly
786
+ if the response body has a 0-length. This is been fixed since and
787
+ the workaround is no longer necessary.
633
788
 
634
- * Only make deeply nested routes shallow when parent is shallow.
789
+ Fixes #18253.
635
790
 
636
- Fixes #14684.
791
+ *Prathamesh Sonpatki*
637
792
 
638
- *Andrew White*, *James Coglan*
793
+ * Fix how polymorphic routes works with objects that implement `to_model`.
639
794
 
640
- * Append link to bad code to backtrace when exception is `SyntaxError`.
795
+ *Travis Grathwell*
641
796
 
642
- *Boris Kuznetsov*
797
+ * Stop converting empty arrays in `params` to `nil`.
643
798
 
644
- * Swapped the parameters of assert_equal in `assert_select` so that the
645
- proper values were printed correctly.
799
+ This behavior was introduced in response to CVE-2012-2660, CVE-2012-2694
800
+ and CVE-2013-0155
646
801
 
647
- Fixes #14422.
802
+ ActiveRecord now issues a safe query when passing an empty array into
803
+ a where clause, so there is no longer a need to defend against this type
804
+ of input (any nils are still stripped from the array).
648
805
 
649
- *Vishal Lal*
806
+ *Chris Sinjakli*
650
807
 
651
- * The method `shallow?` returns false if the parent resource is a singleton so
652
- we need to check if we're not inside a nested scope before copying the :path
653
- and :as options to their shallow equivalents.
808
+ * Remove `ActionController::ModelNaming` module.
654
809
 
655
- Fixes #14388.
810
+ *claudiob*
656
811
 
657
- *Andrew White*
812
+ * Fixed usage of optional scopes in url helpers.
658
813
 
659
- * Make logging of CSRF failures optional (but on by default) with the
660
- `log_warning_on_csrf_failure` configuration setting in
661
- `ActionController::RequestForgeryProtection`.
814
+ *Alex Robbin*
662
815
 
663
- *John Barton*
816
+ * Fixed handling of positional url helper arguments when `format: false`.
664
817
 
665
- * Fix URL generation in controller tests with request-dependent
666
- `default_url_options` methods.
818
+ Fixes #17819.
667
819
 
668
- *Tony Wooster*
820
+ *Andrew White*, *Tatiana Soukiassian*
669
821
 
670
- Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionpack/CHANGELOG.md) for previous changes.
822
+ Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md) for previous changes.