Commit Graph

833 Commits

Author SHA1 Message Date
Rafael Mendonça França
fda5afeb79
Remove deprecated code in ssl middleware 2016-10-10 01:35:59 -03:00
Rafael Mendonça França
2ca83c4a83
Remove deprecated code in ActionDispatch::Session::SessionRestoreError 2016-10-10 01:35:59 -03:00
Rafael Mendonça França
b3d41eae4b
Deprecated ActionDispatch::ParamsParser::ParamsParser
ActionDispatch::ParamsParser class was removed in favor of
ActionDispatch::Http::Parameters so it is better to move the error
constant to the new class.
2016-10-10 01:35:58 -03:00
Rafael Mendonça França
53d2b7335a
Remove deprecated ActionDispatch::ParamsParser 2016-10-10 01:35:58 -03:00
Rafael Mendonça França
1740610a08
Remove deprecated code in ActionDispatch::ParamsParser::ParseError 2016-10-10 01:35:58 -03:00
Rafael Mendonça França
2a3718f434
Remove deprecated access to mime types through constants 2016-10-10 01:35:58 -03:00
Rafael Mendonça França
98b8309569
Remove deprecated support to non-keyword arguments #process 2016-10-10 01:35:57 -03:00
Rafael Mendonça França
31639eab59
Remove deprecated xml_http_request and xhr methods 2016-10-10 00:17:08 -03:00
Rafael Mendonça França
7093ceb480
Remove deprecated methods in ActionController::Parameters 2016-10-10 00:16:16 -03:00
Rafael Mendonça França
c396a8c991
Remove deprecated comparing support with ActionController::Parameters 2016-10-10 00:02:52 -03:00
Rafael Mendonça França
79a5ea9ead
Remove deprecated support to :text in render 2016-10-10 00:02:52 -03:00
Rafael Mendonça França
57e1c99a28
Remove deprecated support to :nothing in render 2016-10-09 23:58:24 -03:00
Rafael Mendonça França
333bfd896e
Remove deprecated support to :back in redirect_to 2016-10-09 23:57:49 -03:00
Rafael Mendonça França
a2762d95c6
Remove deprecated support for status option in head 2016-10-09 23:57:13 -03:00
Rafael Mendonça França
6c24e47eda
Remove deprecation at ActionController::BadRequest 2016-10-09 23:56:14 -03:00
Rafael Mendonça França
d7be30e8ba
Remove deprecated methods related to controller filters
`skip_action_callback`, `skip_filter`, `before_filter`,
`prepend_before_filter`, `skip_before_filter`,
`append_before_filter`, `around_filter`
`prepend_around_filter`, `skip_around_filter`,
`append_around_filter`, `after_filter`,
`prepend_after_filter`, `skip_after_filter` and
`append_after_filter`.
2016-10-09 23:56:14 -03:00
Chris Carter
0b32e2dff3 Show an "unmatched constraints" error for mismatching and present params
Currently a misleading "missing required keys" error is thrown when a param
fails to match the constraints of a particular route. This commit ensures that
these params are recognised as unmatching rather than missing.

Note: this means that a different error message will be provided between
optimized and non-optimized path helpers, due to the fact that the former does
not check constraints when matching routes.

Fixes #26470.
2016-10-03 09:52:14 +01:00
Philip Nguyen
6d67c0ef96 Add #25546 and #25817 to changelog [ci skip] 2016-09-23 10:26:05 -07:00
yuuji.yaginuma
333f10e32c make fixture_file_upload work in integration tests
Currently, `fixture_file_upload` does not work in integration test.
Because, `TestProcess` module has been include in `Session` class, but
`fixture_path` can not get from `Session` class.

Modify to include `TestProcess` in `IntegrationTest` class in order to get
correct value of `fixture_path`.
2016-09-04 11:37:43 +09:00
Kasper Timm Hansen
21c929afe6 Add changelog entry for #26328.
I consider the missing deprecation warning a bug fix from
the point of view of the 5.0.x series and forward.
2016-08-31 21:39:15 +02:00
Ryo Hashimoto
2ea66fc6c5 Fix nested multiple roots
The PR #20940 enabled the use of multiple roots with different constraints
at the top level but unfortunately didn't work when those roots were inside
a namespace and also broke the use of root inside a namespace after a top
level root was defined because the check for the existence of the named route
used the global :root name and not the namespaced name.

This is fixed by using the name_for_action method to expand the :root name to
the full namespaced name. We can pass nil for the second argument as we're not
dealing with resource definitions so don't need to handle the cases for edit
and new routes.

Fixes #26148.
2016-08-29 16:24:51 +01:00
David Heinemeier Hansson
debd774d63 Include the content of the flash in the auto-generated etag (#26250)
Include the content of the flash in the auto-generated etag
2016-08-22 13:34:35 -07:00
Chirag Singhal
64f9802e90 Return 307 status instead of 301 when rerouting POST requests to SSL
When `config.force_ssl` is set to `true`, any POST/PUT/DELETE requests coming in to non-secure url are being redirected with a 301 status.
However, when that happens, the request is converted to a GET request and ends up hitting a different action on the controller.

Since we can not do non-GET redirects, we can instead redirect with a 307 status code instead to indicate to the caller that a fresh request should be tried preserving the original request method.

`rack-ssl` gem which was used to achieve this before we had this middleware directly baked into Rails also used to do the same, ref: https://github.com/josh/rack-ssl/blob/master/lib/rack/ssl.rb#L54

This would be specially important for any apps switching from older version of Rails or apps which expose an API through Rails.
2016-08-22 10:53:41 +05:30
Rafael Mendonça França
544d44fb53
Copy edits in the documentation [ci skip] 2016-08-19 01:48:56 -03:00
Everest Munro-Zeisberger
3db57bde1e Set the request type if as: is specified
Documentation & testing
2016-08-18 18:09:23 -04:00
Vipul A M
8b984161d6
Pass over changelogs [ci skip] 2016-08-10 09:33:13 +05:30
Kasper Timm Hansen
801c6f9e04 Add changelog entry to Action Pack as well.
The entry was a result of a combination of changes in Action View
and Action Controller.
2016-08-07 19:15:11 +02:00
David Chen
23ce9e9b99 Fix Accept header overridden when "xhr: true" in integration test
In integration test when specify the "Accept" header with "xhr: true"
option, the Accept header is overridden with a default xhr Accept
header. The issue only affects HTTP header "Accept" but not CGI variable
"HTTP_ACCEPT".

For example:

    get '/page', headers: { 'Accept' => 'application/json' }, xhr: true

    # This is WRONG! And the response.content_type is also affected.
    # It should be "application/json"
    assert_equal "text/javascript, text/html, ...", request.accept
    assert_equal 'text/html', response.content_type

The issue is in `ActionDispatch::Integration::RequestHelpers`. When
setting "xhr: true" the helper sets a default HTTP_ACCEPT if blank.
But the code doesn't consider supporting both HTTP header style and
CGI variable style.

For detail see this GitHub issue:
https://github.com/rails/rails/issues/25859
2016-08-07 23:44:31 +08:00
Rafael Mendonça França
c1dc565f1e
Merge pull request #25913 from chrisarcand/fix-keyed-defaults-with-root
Fix keyed defaults with root
2016-07-27 20:28:54 -03:00
Chris Arcand
2a946da9bb
Update changelog 2016-07-26 11:05:32 -05:00
Prathamesh Sonpatki
91251fdcbd
CHANGELOG for https://github.com/rails/rails/pull/25257 [ci skip]
- Also minor weekly CHANGELOG cleanup.
2016-07-17 11:27:06 +05:30
Grey Baker
9f38a3fb0c Check request.path_parameters encoding at the point they're set
Check for any non-UTF8 characters in path parameters at the point they're
set in `env`. Previously they were checked for when used to get a controller
class, but this meant routes that went directly to a Rack app, or skipped
controller instantiation for some other reason, had to defend against
non-UTF8 characters themselves.
2016-07-14 16:50:49 +01:00
Grey Baker
25c1461766 Don't raise ActionController::UnknownHttpMethod from ActionDispatch::Static
The `ActionDispatch::Static` middleware is used low down in the stack to serve
static assets before doing much processing. Since it's called from so low in
the stack, we don't have access to the request ID at this point, and generally
won't have any exception handling defined (by default `ShowExceptions` is added
to the stack quite a bit higher and relies on logging and request ID).

Before 8f27d6036a
this middleware would ignore unknown HTTP methods, and an exception about these
would be raised higher in the stack. After that commit, however, that exception
will be raised here.

If we want to keep `ActionDispatch::Static` so low in the stack (I think we do)
we should suppress the `ActionController::UnknownHttpMethod` exception here,
and instead let it be raised higher up the stack, once we've had a chance to
define exception handling behaviour.

This PR updates `ActionDispatch::Static` so it passes `Rack::Request` objects to
`ActionDispatch::FileHandler`, which won't raise an
`ActionController::UnknownHttpMethod` error. If an unknown method is
passed, it should exception higher in the stack instead, once we've had a
chance to define exception handling behaviour.`
2016-07-13 17:52:36 +01:00
Grey Baker
fe859a5421 Handle Rack::QueryParser errors in ActionDispatch::ExceptionWrapper
Rack [recently](7e7a389044)
moved the namespace of its `ParameterTypeError` and `InvalidParameterError`
errors. Whilst an alias for the old name was added, the logic in
`ActionDispatch::ExceptionWrapper` was still broken by this change, since it
relies on the class name.

This PR updates `ActionDispatch::ExceptionWrapper` to handle the Rack 2.0
namespaced errors correctly. We no longer need to worry about the old names,
since Rails specifies Rack ~> 2.0.
2016-07-12 16:41:09 +01:00
Rafael Mendonça França
8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França
fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
Prathamesh Sonpatki
bf79bc0395
Release notes: Add PR #24866 to release notes 2016-05-05 23:04:30 -05:00
Rafael Mendonça França
541a51ecf8 Implement helpers proxy in controller instance level
It is a common pattern in the Rails community that when people want to
:xa
use any kind of helper that is defined inside app/helpers they includes
the helper module inside the controller like:

    module UserHelper
      def my_user_helper
        # ...
      end
    end

    class UsersController < ApplicationController
      include UserHelper

      def index
        render inline: my_user_helper
      end
    end

This has problem because the helper can't access anything that is
defined in the view level context class.

Also all public methods of the helper become available in the controller
what can lead to undesirable methods being routed and behaving as
actions.

Also if you helper depends on other helpers or even Action View helpers
you need to include each one of these dependencies in your controller
otherwise your helper is not going to work.

We already have a helpers proxy at controller class level but that proxy
doesn't have access to the instance variables defined in the
controller.

With this new instance level helper proxy users can reuse helpers in the
controller without having to include the modules and with access to
instance variables defined in the controller.

    class UsersController < ApplicationController
      def index
        render inline: helpers.my_user_helper
      end
    end
2016-05-05 16:17:17 -05:00
eileencodes
f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Jeremy Daer
643cac08a3
Merge pull request #23103 from rails/refactor-handling-of-action-default
Refactor handling of :action default in routing
2016-04-24 15:27:46 -07:00
yui-knk
b50e88ebdf Make assert_recognizes to traverse mounted engines
Before this commit paths of mounted engines are not traversed
when `assert_recognizes` is called, causing strange test results.
This commit enable to traverse mounted paths.
2016-04-23 11:40:50 +09:00
Prathamesh Sonpatki
64b115b451
[ci skip] Remove extra so from the Action Pack CHANGELOG 2016-04-14 09:19:34 +05:30
Rafael Mendonça França
0c21fb361c Merge pull request #24318 from bogdanvlviv/patch-1
extension synonyms yml and yaml
2016-04-12 23:26:45 -03:00
Ryan McCuaig
58c12900b7 it's => its typo 2016-04-04 19:13:57 -07:00
Ryan T. Hosford
f99106805d Fixes #24239
- skip calling helper_method if it's not there: if we don't have helpers, we needn't define one.
  - tests that an api controller can include and use ActionController::Cookies
2016-04-04 08:51:29 -05:00
Jeremy Daer
c1c9c69040 Strong ETag validators
* Introduce `Response#strong_etag=` and `#weak_etag=` and analogous options
  for `fresh_when` and `stale?`. `Response#etag=` sets a weak ETag.

  Strong ETags are desirable when you're serving byte-for-byte identical
  responses that support Range requests, like PDFs or videos (typically
  done by reproxying the response from a backend storage service).
  Also desirable when fronted by some CDNs that support strong ETags
  only, like Akamai.

* No longer strips quotes (`"`) from ETag values before comparing them.
  Quotes are significant, part of the ETag. A quoted ETag and an unquoted
  one are not the same entity.

* Support `If-None-Match: *`. Rarely useful for GET requests; meant
  to provide some optimistic concurrency control for PUT requests.
2016-03-31 18:15:32 -07:00
Rafael Mendonça França
5ed3801481 Deprecate ActionDispatch::ParamsParser instance.
Related with 38d2bf5fd1f3e014f2397898d371c339baa627b1.

cc @tenderlove
2016-03-30 01:17:05 -03:00
Bogdan
3a37c4e371 extension synonyms yml and yaml 2016-03-27 17:20:28 +03:00
Prathamesh Sonpatki
ca9e1e2101 Fix typo in Action Pack changelog [ci skip] 2016-03-25 14:33:00 +05:30
Yves Senn
c94045dc1c guides, sync railties and AP changelogs with 5.0 release notes.
[ci skip]

This updates the 5.0 release notes guide to reflect changes that
happened after beta1 has been released.

I'll sync the other changelogs later today but I'll push this batch to
prevent against cumbersome merge conflicts.
2016-03-22 12:12:39 +01:00
Sean Griffin
3bfda09fa0 Merge pull request #22854 from jcoyne/missing_template
Default rendering behavior if respond_to collector doesn't have a block.
2016-03-11 10:29:10 -07:00
Sean Griffin
5cd2beb013 Add ActionController::Parameters#dig
This method will only be added when used with Ruby 2.3.0 or greater.
This method has the same behavior as `Hash#dig`, except it will convert
hashes to `ActionController::Parameters`, similar to `#[]` and `#fetch`.
2016-03-09 09:49:23 -07:00
Rafael Mendonça França
fe8239e35a Add changelog entry for #24115 [ci skip] 2016-03-09 12:48:56 -03:00
Yves Senn
ab7ad20125 Merge pull request #24086 from yui-knk/do_not_ad_integration_test_class
Prevent not-intended loading of `ActionDispatch::IntegrationTest`
2016-03-07 09:12:18 +01:00
yui-knk
9a642931fb Prevent not-intended loading of ActionDispatch::IntegrationTest
After 9d378747326d26cf1afdac4433ead22967af0984 `ActionDispatch::IntegrationTest`
class is loaded and defined in all Rails environments, not only test but also
production. This is not-intended loading of a class which is only used in
test environment.
To prevent not-intended loading, add `ActiveSupport.run_load_hooks` to
`ActionDispatch::IntegrationTest` with `action_dispatch_integration_test` name
and use it in `ActionMailer`.
2016-03-07 16:48:18 +09:00
Matthew Draper
ee5b621e2f Revert "Merge pull request #20851 from tomprats/indifferent-sessions"
This reverts commit 22db455dbe9c26fe6d723cac0758705d9943ea4b, reversing
changes made to 40be61dfda1e04c3f306022a40370862e3a2ce39.

This finishes off what I meant to do in 6216a092ccfe6422f113db906a52fe8ffdafdbe6.
2016-02-26 04:47:30 +10:30
Justin Coyne
48f140cf74 Render default template if block doesn't render
When a `respond_to` collector doesn't have a response, then a
`:no_content` response should be rendered. This brings the default
rendering behavior introduced by
https://github.com/rails/rails/issues/19036 to controller methods
employing `respond_to`
2016-02-25 07:14:49 -06:00
Godfrey Chan
73b1efc58f Lock down new ImplicitRender behavior for 5.0 RC
1. Conceptually revert #20276

   The feature was implemented for the `responders` gem. In the end,
   they did not need that feature, and have found a better fix (see
   plataformatec/responders#131).

   `ImplicitRender` is the place where Rails specifies our default
   policies for the case where the user did not explicitly tell us
   what to render, essentially describing a set of heuristics. If
   the gem (or the user) knows exactly what they want, they could
   just perform the correct `render` to avoid falling through to
   here, as `responders` did (the user called `respond_with`).

   Reverting the patch allows us to avoid exploding the complexity
   and defining “the fallback for a fallback” policies.

2. `respond_to` and templates are considered exhaustive enumerations

   If the user specified a list of formats/variants in a `respond_to`
   block, anything that is not explicitly included should result
   in an `UnknownFormat` error (which is then caught upstream to
   mean “406 Not Acceptable” by default). This is already how it
   works before this commit.

   Same goes for templates – if the user defined a set of templates
   (usually in the file system), that set is now considered exhaustive,
   which means that “missing” templates are considered `UnknownFormat`
   errors (406).

3. To keep API endpoints simple, the implicit render behavior for
   actions with no templates defined at all (regardless of formats,
   locales, variants, etc) are defaulted to “204 No Content”. This
   is a strictly narrower version of the feature landed in #19036 and
   #19377.

4. To avoid confusion when interacting in the browser, these actions
   will raise an `UnknownFormat` error for “interactive” requests
   instead. (The precise definition of “interactive” requests might
   change – the spirit here is to give helpful messages and avoid
   confusions.)

Closes #20666, #23062, #23077, #23564

[Godfrey Chan, Jon Moss, Kasper Timm Hansen, Mike Clark, Matthew Draper]
2016-02-25 01:19:49 -08:00
eileencodes
dbfa8fdfc2 Preparing for 5.0.0.beta3 release
Adds changelog headers for beta3 release
2016-02-24 11:14:40 -05:00
Rafael Mendonça França
53c19c5024 No need CHANGELOG entry for #23849.
It is not a released feature so we don't need to add changelogs to
changes on it.

[ci skip]
2016-02-24 10:29:14 -03:00
Prathamesh Sonpatki
5f59c10471 Show permitted flag in the output of AC::Parameters#inspect
- Fixes #23822.
2016-02-24 13:55:37 +05:30
Rafael Mendonça França
22db455dbe Merge pull request #20851 from tomprats/indifferent-sessions
Give Sessions Indifferent Access
2016-02-24 00:22:04 -03:00
Andrew White
8ca8a2d773 Refactor handling of :action default in routing
The longstanding convention in Rails is that if the :action parameter
is missing or nil then it defaults to 'index'. Up until Rails 5.0.0.beta1
this was handled slightly differently than other routing defaults by
deleting it from the route options and adding it to the recall parameters.

With the recent focus of removing unnecessary duplications this has
exposed a problem in this strategy - we are now mutating the request's
path parameters and causing problems for later url generation. This will
typically affect url_for rather a named url helper since the latter
explicitly pass :controller, :action, etc.

The fix is to add a default for :action in the route class if the path
contains an :action segment and no default is passed. This change also
revealed an issue with the parameterized part expiry in that it doesn't
follow a right to left order - as soon as a dynamic segment is required
then all other segments become required.

Fixes #23019.
2016-02-16 09:52:26 +00:00
Mehmet Emin İNAÇ
ff8bdafec4 application/gzip added as default mime type into mime type list 2016-02-13 19:25:28 +02:00
Kasper Timm Hansen
da1fbb9a00 Add fixes accidentally removed.
Yesterday, when improving how `parsed_body` extracted a parser I wrote
77bbf1e. Then I thought that was too many changes in one commit
and broke it up locally... or so I thought.

When pushed the extra commits removed the changes! Wups!

In shame, lob those changes together here:

  * 3b94c38 which meant to fix the CHANGELOG syntax error.
  * 5007df5 which meant to mention `parsed_body` in the docs.
  * 036a7a0 which meant to memoize the `parsed_body`.
2016-02-12 20:13:48 +01:00
Kasper Timm Hansen
354fb73ff2 Flesh out request encoding + response parsing changelog entry.
Add more info about the APIs added and how they work.

Use string keys when comparing the parsed response, like how JSON would
be parsed.
2016-02-12 20:13:48 +01:00
Gaurav Sharma
33e202d3ae use rails instead of rake
since starting with Rails 5.x(beta) we prefer to use rails as the replacement of rake commands, may be change log will be the same
2016-02-12 23:12:56 +05:30
Vipul A M
ef2a8c2391 - Fixed and removed long arguments to rake routes
- Fixed related documentation and usage all around

Fixes #23561
2016-02-12 14:35:57 +05:30
Kasper Timm Hansen
c85b17773e Add request encoding and response parsing to changelog.
Forgot to add this in the original pull request. No biggie, just show
some examples.
2016-02-10 22:05:08 +01:00
David Heinemeier Hansson
7e35cb2987 Add SVG as a default mime type 2016-02-07 15:34:13 +01:00
Kang-Kyu Lee
c4ac23bfa6 Update CHANGELOG.md
fix indentation to show it as code
2016-02-01 14:21:34 -08:00
Rafael Mendonça França
60b040e362 Add some Action Cable CHANGELOG entries
And improve changelongs.

[ci skip]
2016-02-01 19:57:50 -02:00
Sean Griffin
49f6ce63f3 Preparing for Rails 5.0.0.beta2 2016-02-01 14:37:52 -07:00
Vipul A M
8a436fdd98 Add options for rake routes task
Add two options: `-c` and `-g`.
`-g` option returns the urls name, verb and path fields that match the pattern.
`-c` option returns the urls for specific controller.

Fixes #18902, and Fixes #20420

[Anton Davydov & Vipul A M]
2016-02-02 00:27:30 +05:30
Tom Prats
82dc8266dd Update session to have indifferent access 2016-01-29 17:22:05 -05:00
Vipul A M
48c03c59c3 rm changelog for unreleased changes fixes
Based on https://github.com/rails/rails/pull/23167/files#r50507317

[ci skip]
2016-01-22 12:43:03 +05:30
Jon Moss
627f736cc0 Fix ActionController::Parameters#== bug
See bug #21032.
2016-01-21 17:28:18 -05:00
abhishek
e362c31b34 Response etags to always be weak: Prefixed W/ to value returned by ActionDispatch::Http::Cache::Response#etag= such that etags set in fresh_when and stale? are weak. For #17556. 2016-01-20 07:57:30 +05:30
Vipul A M
ee14fbe4ee Pass through AP CHANGELOG [ci skip] 2016-01-18 12:05:23 +05:30
Yves Senn
f5ab4055b9 docs, formatting pass over changelogs. [ci skip] 2016-01-13 10:19:55 +01:00
Sean Collins
a4032ca072 Add both HTTP Response Code and Type to assertion messages
Also, refactor logic to convert between symbol and response code,
via the AssertionResponse class
2016-01-12 13:09:00 -07:00
Prathamesh Sonpatki
4824971f36 Fix typo in ActionPack CHANGELOG [ci skip] 2016-01-08 08:31:08 +05:30
Ben Toews
77d01e36aa add greg 2016-01-07 12:35:46 -07:00
Edouard CHIN
ce13f79105 Better error message when running rake routes with CONTROLLER arg:
- `CONTROLLER` argument can now be supplied in different ways (Rails::WelcomeController, Rails::Welcome, rails/welcome)
- If `CONTROLLER` argument was supplied but it does not exist, will warn the user that this controller does not exist
- If `CONTROLLER` argument was supplied and no routes could be found matching this filter, will warn the user that no routes were found matching the supplied filter
- If no routes were defined in the config/routes.rb file, will warn the user with the original message
2016-01-07 06:35:40 -05:00
Prathamesh Sonpatki
a31078556a Allow AC::Parameters as an argument to url_helpers
- Earlier only Hash was allowed as params argument to url_helpers.
- Now ActionController::Parameters instances will also be allowed.
- If the params are not secured then it will raise an ArgumentError to
  indicate that constructing URLs with non-secure params is not recommended.
- Fixes #22832.
2016-01-07 12:12:34 +05:30
Ben Toews
3e98819e20 add option for per-form CSRF tokens 2016-01-04 12:26:38 -07:00
Benjamin Fleischer
1c361ea356 Test ActionController::Renderers::use_renderers 2015-12-31 13:07:58 -06:00
Prathamesh Sonpatki
28f648dbc7 Fix AC::Parameters#to_unsafe_h to return all unfiltered values
- AC::Parameters#convert_parameters_to_hashes should return filtered or
  unfiltered values based on whether it is called from `to_h` or `to_unsafe_h`
  instead of always defaulting to `to_h`.
- Fixes #22841
2015-12-31 12:32:29 +05:30
Justin Coyne
ff8a62d1d0 Add AC::Parameters#include?
Fixes #22818
2015-12-29 10:11:26 -06:00
Yves Senn
099082690d release notes, extract notable changes from Action Pack CHANGELOG.
[ci skip]
2015-12-22 12:19:37 +01:00
Genadi Samokovarov
c5b6ec7b0f No more no changes entries in the CHANGELOGs
During the `5.0.0.beta1` release, the CHANGELOGs got an entry like the
following:

```
* No changes.
```

It is kinda confusing as there are indeed changes after it. Not a
biggie, just a small pass over the CHANGELOGs.

[ci skip]
2015-12-21 11:46:38 +02:00
eileencodes
099ddfdefd Add CHANGELOG headers for Rails 5.0.0.beta1 2015-12-18 15:58:25 -05:00
Derek Prior
dc4429ca3b
Deprecate redirect_to :back
Applications that use `redirect_to :back` can be forced to 500 by
clients that do not send the HTTP `Referer` (sic) header.
`redirect_back` requires the user to consider this possibility up front
and avoids this trivially-caused application error.
2015-12-16 11:42:25 -05:00
Derek Prior
13fd5586ce
Add redirect_back for safer referrer redirects
`redirect_to :back` is a somewhat common pattern in Rails apps, but it
is not completely safe. There are a number of circumstances where HTTP
referrer information is not available on the request. This happens often
with bot traffic and occasionally to user traffic depending on browser
security settings.

When there is no referrer available on the request, `redirect_to :back`
will raise `ActionController::RedirectBackError`, usually resulting in
an application error.

`redirect_back` takes a required `fallback_location` keyword argument
that specifies the redirect when the referrer information is not
available.  This prevents 500 errors caused by
`ActionController::RedirectBackError`.
2015-12-16 11:42:05 -05:00
eileencodes
cd355a8eeb Fix spacing on CHANGELOG name
So that it appears correctly in the CHANGELOG on github.
2015-12-12 14:44:59 -05:00
eileencodes
4414c5d179 Remove ActionController::TestCase from documentation
In Rails 5.1 `ActionController::TestCase` will be moved out of Rails
into it's own gem.

Please use `ActionDispatch::IntegrationTest` going foward.

Because this will be moved to a gem I used `# :stopdoc:` instead of
deleting the documentation. This will remove it from the Rails
documentation but still leave the method documented for when we move it
to a gem.

Guides have been updated to use the routing structure used in Integration
and all test examples have been updated to inherit from
`ActionDispatch::IntegrationTest` instead of `ActionController::TestCase.

Fixes #22496
2015-12-12 14:44:50 -05:00
Jorge Bejar
290a536d28 Update Changelog with the added response_format option in AD::DebugExceptions 2015-12-09 10:53:46 -03:00
eileencodes
3979403781 Change the protect_from_forgery prepend default to false
Per this comment
https://github.com/rails/rails/pull/18334#issuecomment-69234050 we want
`protect_from_forgery` to default to `prepend: false`.

`protect_from_forgery` will now be insterted into the callback chain at the
point it is called in your application. This is useful for cases where you
want to `protect_from_forgery` after you perform required authentication
callbacks or other callbacks that are required to run after forgery protection.

If you want `protect_from_forgery` callbacks to always run first, regardless of
position they are called in your application, then you can add `prepend: true`
to your `protect_from_forgery` call.

Example:

```ruby
protect_from_forgery prepend: true
```
2015-12-07 10:38:26 -05:00
yui-knk
f9e8d2c9a2 [ci skip] Add author's name to CHANGELOG 2015-11-28 17:39:38 +09:00
Arthur Nogueira Neves
9afb0b9c43 Merge pull request #21241 from pdg137/master
In url_for, never append ? when the query string is empty anyway.
2015-11-26 16:10:46 -05:00
Kasper Timm Hansen
a3e05f7c81 Move static_cache_contorl deprecation changelog entry to Railties.
The configuration for `config.static_cache_control`, and its replacement
`config.public_file_server.headers` are implemented in Railties.

People would configure this in environment files, which is Railties domain too.
2015-11-04 22:07:45 +01:00
Paul Grayson
e6e056c2c1 In url_for, never append ? when the query string is empty anyway.
It used to behave like this:

    url_for(controller: 'x', action: 'y', q: {})
    # -> "/x/y?"

We previously avoided empty query strings in most cases by removing
nil values, then checking whether params was empty.  But as you can
see above, even non-empty params can yield an empty query string.  So
I changed the code to just directly check whether the query string
ended up empty.

(To make everything more consistent, the "removing nil values"
functionality should probably move to ActionPack's Hash#to_query, the
place where empty hashes and arrays get removed.  However, this would
change a lot more behavior.)
2015-10-29 17:02:13 -07:00
Aaron Patterson
8941831733 Revert "ActionController::Base#process() now only takes an action name"
This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
2015-10-29 16:18:27 -07:00
Aaron Patterson
9f93a5efbb ActionController::Base#process() now only takes an action name
rather than an action name and *args.  The *args were not being used in regular
applications outside tests.  This causes a backwards compatibility
issue, but reduces array allocations for most users.
2015-10-29 15:40:18 -07:00
Grey Baker
59ab2d1ee5 Catch invalid UTF-8 querystring values and respond with BadRequest 2015-10-23 14:56:47 +01:00
Sean Griffin
ea9bc06c9a Merge pull request #20715 from simsalabim/feature/parse-rss-atom-as-xml
parse RSS/ATOM responses as XML, not HTML
2015-10-20 16:11:36 -06:00
Agis Anastasopoulos
3f81b3753f Show helpful messages on invalid param. encodings
Prior to this change, given a route:

    # config/routes.rb
    get ':a' => "foo#bar"

If one pointed to http://example.com/%BE (param `a` has invalid encoding),
a `BadRequest` would be raised with the following non-informative message:

    ActionController::BadRequest

From now on the message displayed is:

    Invalid parameter encoding: hi => "\xBE"

Fixes #21923.
2015-10-19 17:36:22 +03:00
Jeremy Daer
9d05430c95 Merge pull request #19135 from yuki24/access-control-support
Add basic support for access control headers to ActionDispatch::Static
2015-10-13 11:16:50 -07:00
Rafael Sales
4db921a8e7 Allow multiple root routes in same scope level
When an application has multiple root entries with different
constraints, the current solution is to use `get '/'`. Example:

**Currently I have to do:**
```ruby
get '/', to: 'portfolio#show', constraints: ->(req) { Hostname.portfolio_site?(req.host) }
get '/', to: 'blog#show',      constraints: ->(req) { Hostname.blog_site?(req.host) }
root 'landing#show'
```

**But I would like to do:**
```ruby
root 'portfolio#show', constraints: ->(req) { Hostname.portfolio_site?(req.host) }
root 'blog#show',      constraints: ->(req) { Hostname.blog_site?(req.host) }
root 'landing#show'
```

Other URL matchers such as `get`, `post`, etc, already allows this, so I
think it's fair that `root` also allow it since it's just a shortcut for
a `get` internally.
2015-10-10 08:22:31 -03:00
Matthew Erhard
bcfbd8ba21 Fix mounted engine named routes regression
When generating the url for a mounted engine through its proxy, the path should be the sum of three parts:

1. Any `SCRIPT_NAME` request header or the value of `ActionDispatch::Routing::RouteSet#relative_url_root`.
2. A prefix (the engine's mounted path).
3. The path of the named route inside the engine.

Since commit 44ff0313c1, this has been broken. Step 2 has been changed to:

2. A prefix (the value of `ActionDispatch::Routing::RouteSet#relative_url_root` + the engine's mounted path).

The value of `ActionDispatch::Routing::RouteSet#relative_url_root` is taken into account in step 1 of the route generation and should be ignored when generating the mounted engine's prefix in step 2.

This commit fixes the regression by having `ActionDispatch::Routing::RouteSet#url_for` check `options[:relative_url_root]` before falling back to `ActionDispatch::Routing::RouteSet#relative_url_root`. The prefix generating code then sets `options[:relative_url_root]` to an empty string. This empty string is used instead of `ActionDispatch::Routing::RouteSet#relative_url_root` and avoids the duplicate `relative_url_root` value in the final result.

This resolves #20920 and resolves #21459
2015-10-07 12:45:01 -04:00
Jeremy Daer
565094a8b5 Use Mime[:foo] instead of Mime::Type[:FOO] for back compat
Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries
that support multiple Rails versions would've had to feature-detect
whether to use `Mime::Type[:FOO]` or `Mime::FOO`.

`Mime[:foo]` has been around for ages to look up registered MIME types
by symbol / extension, though, so libraries and plugins can safely
switch to that without breaking backward- or forward-compatibility.

Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup
by type or extension, so it's not available as `Mime[:all]`. We use it
internally as a wildcard for `respond_to` negotiation. If you use this
internal constant, continue to reference it with `Mime::ALL`.

Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
2015-10-06 11:29:30 -07:00
Aaron Patterson
e16afe61ab stop applying default headers in ActionDispatch::Response
I'm making this change so that I can construct response objects that
*don't* have the default headers applied.  For example, I would like to
construct a response object from the return value of a controller.

If you need to construct a response object with the default headers,
then please use the alternate constructor:
`ActionDispatch::Response.create`
2015-09-23 15:48:01 -07:00
Juanito Fatas
2510784e78 Fix a typo: Mime::Types should be Mime::Type [ci skip] 2015-09-22 10:04:27 +08:00
Aaron Patterson
8325d4c473 update changelog for mime changes 2015-09-21 12:13:13 -07:00
Rafael Mendonça França
f883867dd6 Merge pull request #21502 from bernerdschaefer/bs-polymorphic-url_for-dups-arguments
`url_for` does not modify polymorphic options
2015-09-08 13:49:22 -03:00
Jeremy Daer
f674922462 Make config.force_ssl less dangerous to try and easier to disable
SSL redirect:
* Move `:host` and `:port` options within `redirect: { … }`. Deprecate.
* Introduce `:status` and `:body` to customize the redirect response.
  The 301 permanent default makes it difficult to test the redirect and
  back out of it since browsers remember the 301. Test with a 302 or 307
  instead, then switch to 301 once you're confident that all is well.

HTTP Strict Transport Security (HSTS):
* Shorter max-age. Shorten the default max-age from 1 year to 180 days,
  the low end for https://www.ssllabs.com/ssltest/ grading and greater
  than the 18-week minimum to qualify for browser preload lists.
* Disabling HSTS. Setting `hsts: false` now sets `hsts: { expires: 0 }`
  instead of omitting the header. Omitting does nothing to disable HSTS
  since browsers hang on to your previous settings until they expire.
  Sending `{ hsts: { expires: 0 }}` flushes out old browser settings and
  actually disables HSTS:
    http://tools.ietf.org/html/rfc6797#section-6.1.1
* HSTS Preload. Introduce `preload: true` to set the `preload` flag,
  indicating that your site may be included in browser preload lists,
  including Chrome, Firefox, Safari, IE11, and Edge. Submit your site:
    https://hstspreload.appspot.com
2015-09-07 17:57:20 -07:00
Bernerd Schaefer
ee63532d40 url_for does not modify polymorphic options
The `url_for` methods in `actionpack` and `actionview`
now make a copy of the provided options
before generating polymorphic paths or URLs.

The bug in the previous behavior
is most noticeable in a case like:

    url_options = [:new, :post, param: 'value']

    if current_page?(url_options)
      css_class = "active"
    end

    link_to "New Post", url_options, class: css_class
2015-09-04 13:42:32 -07:00
Yves Senn
a62a164850 minor copy edit. [ci skip]
Follow up to #21384.
2015-08-27 14:20:09 +02:00
Jeremy Friesen
0258ef33a5 Updating TestSession to access with indifference
The following Rails code failed (with a `KeyError` exception) under
test:

```ruby
class ApplicationController < ActionController::Base
  def user_strategy
    # At this point:
    # ```ruby
    # session == {
    #   "user_strategy"=>"email",
    #   "user_identifying_value"=>"hello@world.com"
    # }
    # ```
    if session.key?(:user_strategy)
      session.fetch(:user_strategy)
    end
  end
end
```

When I checked the session's keys (`session.keys`), I got an array of
strings. If I accessed `session[:user_strategy]` I got the expected
`'email'` value. However if I used `session.fetch(:user_strategy)` I
got a `KeyError` exception.

This appears to be a Rails 4.2.4 regression (as the code works under
Rails 4.2.3).

Closes #21383
2015-08-26 09:08:18 -04:00
Aaron Patterson
83b767cef9 Using strings or symbols for middleware class names is deprecated.
Convert things like this:

  middleware.use "Foo::Bar"

to this:

  middleware.use Foo::Bar
2015-08-07 15:37:31 -07:00
Matthew Gerrior
3004cc8177 Adds missing argument handling for ActionController::TestSession to
allow testing controllers that use session#fetch with a default value.
2015-08-06 15:29:45 -04:00
Roque Pinel
780af27bf9 Fix exception overwritten for parameters fetch method
When executing an `ActionController::Parameters#fetch` with a block
that raises a `KeyError` the raised `KeyError` will be rescued and
converted to an `ActionController::ParameterMissing` exception,
covering up the original exception.

[Jonas Schubert Erlandsson & Roque Pinel]
2015-07-18 18:48:41 -04:00
Jon Atack
ea747f7d2e [skip ci] Lookup can be a noun but it is not a verb
Various grammar corrections and wrap to 80 characters.
2015-07-17 20:18:57 +02:00
Prem Sichanugrist
84b861f1aa Update documentation on AC::Parameters 2015-07-15 13:02:53 -04:00
Prem Sichanugrist
14a3bd520d Make AC::Parameters not inherited from Hash
This is another take at #14384 as we decided to wait until `master` is
targeting Rails 5.0. This commit is implementation-complete, as it
guarantees that all the public methods on the hash-inherited Parameters
are still working (based on test case). We can decide to follow-up later
if we want to remove some methods out from Parameters.
2015-07-15 11:11:36 -04:00
Jerry D'Antonio
284a9ba8ec Replaced ActiveSupport::Concurrency::Latch with concurrent-ruby.
The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
2015-07-13 15:44:21 -04:00
Guillaume Malette
33b93174f0 Allow filtering params based on parent keys
Add the possibility to only filter parameters based on
their full path instead of relying on the immediate key.

    config.filter_parameters += ['credit_card.code']

    { 'credit_card' => { 'code' => '[FILTERED]' },
      'source' => { 'code' => '<%= puts 5 %>' } }
2015-06-22 10:04:11 -04:00
Arthur Neves
ffba8f79a2
Revert "Merge pull request #20584 from arthurnn/fix_url"
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.

As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
2015-06-17 20:17:44 +02:00
Arthur Neves
e23b314945
Catch InvalidURIError on bad paths on redirect.
Handle URI::InvalidURIError errors on the redirect route method, so it
wont raise a 500 if a bad path is given.
2015-06-16 23:27:49 +02:00
Mehmet Emin İNAÇ
cf81a3bae0 Deprecate passing hash as first parameter into ActionController::Head 2015-06-15 23:53:45 +03:00
Yves Senn
863fcfa79a quick pass over changelogs. [ci skip] 2015-06-15 09:33:27 +02:00
Yuki Nishijima
5226058163 Add the ability of returning arbitrary headers to ActionDispatch::Static
Now ActionDispatch::Static can accept HTTP headers so that developers
will have control of returning arbitrary headers like
'Access-Control-Allow-Origin' when a response is delivered. They can
be configured through `#config.public_file_server.headers`:

  config.public_file_server.headers = {
    "Cache-Control"               => "public, max-age=60",
    "Access-Control-Allow-Origin" => "http://rubyonrails.org"
  }

Also deprecate `config.static_cache_control` in favor of
`config.public_file_server.headers`.
2015-06-13 09:30:23 -07:00
Grey Baker
0a9b86b0c0 Handle param-parsing errors from Rack in ExceptionWrapper 2015-06-12 23:44:20 +01:00
Santiago Pastorino
f3df21649a Add CHANGELOG entries for API apps functionality 2015-06-11 16:54:15 -03:00
Rafael Mendonça França
cf484e3ee3 Merge pull request #19094 from phoet/have_bearer_be_valid_as_well
Have Bearer be valid as well
2015-06-01 12:41:18 -03:00
phoet
4d4440c5a8 add changelog entry 2015-06-01 17:39:06 +02:00
Guo Xiang Tan
ca83436d1b Remove assigns and assert_template. 2015-05-30 14:13:57 +08:00
Rafael Mendonça França
73aab036ee Merge pull request #20017 from eliotsykes/configurable-static-index-filename
config.static_index configures directory Index "index.html" filename
2015-05-28 18:53:00 -03:00
Mehmet Emin İNAÇ
44781b6e97 Deprecate :nothing option for render method
`head` method works similar to `render` method with `:nothing` option
2015-05-28 15:13:32 +03:00
Eliot Sykes
3ff39494cd config.static_index configures directory index "index.html" filename
Set `config.static_index` to serve a static directory index file not
named `index`. For example, to serve `main.html` instead of `index.html`
for directory requests, set `config.static_index` to `"main"`.
2015-05-28 09:41:00 +01:00
karanarora
0750330941 Spelling/typo/grammatical fixes [ci skip]
spelling fix [ci skip]

example to be consistent [ci skip]

grammatical fix

typo fixes [ci skip]
2015-05-23 03:01:33 +05:30
Prathamesh Sonpatki
daba090dec Pass over CHANGELOGS [ci skip] 2015-05-16 11:00:17 +05:30
Anton Davydov
8a40bf2081 [skip ci] Fix typos in actionpack changelog and security guide 2015-05-07 14:49:34 +03:00
Arthur Neves
6d9ad0dd92
Add changelog for rake routes default fix
[see #18392]
2015-04-27 09:18:43 -04:00
Yves Senn
cdbf685994 pass over CHANGELOGs. [ci skip] 2015-04-22 14:44:30 +02:00
Kevin McPhillips
2b8acdcd21 Override default form builder for a controller 2015-04-13 23:43:34 -04:00
Stephen Bussey
0de4a23d1c head no_content when there is no template or action performed 2015-04-05 15:46:50 -04:00
Rafael Mendonça França
5cb8e0046c Merge pull request #18939 from georgeclaghorn/variant-inquiry
Provide friendlier access to request variants
2015-03-27 16:20:52 -03:00
Arthur Neves
b6b088429c Add changelog entry for #19271 2015-03-24 15:12:47 -04:00
George Claghorn
9d9cc4777b Provide friendlier access to request variants
Closes #18933.
2015-03-24 12:49:27 -05:00