Commit Graph

13221 Commits

Author SHA1 Message Date
Javan Makhmali
d12209cad2 Remove package:clean task
Introduced in d6f2000a67cc63aa67414c75ce77de671824ec52 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task.
2016-05-24 13:11:28 -04:00
Matthew Caruana Galizia
683b9627b3
Respect log_warning_on_csrf_failure setting for all CSRF failures
CSRF verification for non-XHR GET requests (cross-origin `<script>`
tags) didn't check this flag before logging failures.

Setting `config.action_controller.log_warning_on_csrf_failure = false`
now disables logging for these CSRF failures as well.

Closes #25086.

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
2016-05-23 10:21:30 -07:00
Rafael Mendonça França
e3b239cc1a
Revert "Make sure the cache is always populated"
This reverts commit 0ce7eae7418f1b9bb06b351c1f26d50c3674c0d0.

Tests were broken https://travis-ci.org/rails/rails/jobs/131850726#L520
2016-05-20 23:28:00 -03:00
Aaron Patterson
0ce7eae741
Make sure the cache is always populated
This way we don't have to make multiple calls on anonymous controllers
2016-05-20 18:30:34 -07:00
Jon Moss
f58bd6ed22
Add back in Oxford Comma
per [API documentation guidelines](http://edgeguides.rubyonrails.org/api_documentation_guidelines.html#oxford-comma)

[ci skip]
2016-05-19 15:41:59 -04:00
Arthur Nogueira Neves
d6e7334d19 Merge pull request #25070 from josedonizetti/fix_example_routes_doc
fix named route example [ci skip]
2016-05-19 13:32:39 -04:00
Jose Donizetti
e73f9bed62 fix named route example [ci skip] 2016-05-19 08:02:40 -04:00
Jeremy Daer
89e2f7e722
Support for unified Integer class in Ruby 2.4+
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005

* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
2016-05-18 21:58:51 -07:00
Jeremy Daer
e35b98e6f5
Action Mailer: Declarative exception handling with rescue_from.
Follows the same pattern as controllers and jobs. Exceptions raised in
delivery jobs (enqueued by `#deliver_later`) are also delegated to the
mailer's rescue_from handlers, so you can handle the DeserializationError
raised by delivery jobs:

```ruby
class MyMailer < ApplicationMailer
  rescue_from ActiveJob::DeserializationError do
    …
  end
```

ActiveSupport::Rescuable polish:
* Add the `rescue_with_handler` class method so exceptions may be
  handled at the class level without requiring an instance.
* Rationalize `exception.cause` handling. If no handler matches the
  exception, fall back to the handler that matches its cause.
* Handle exceptions raised elsewhere. Pass `object: …` to execute
  the `rescue_from` handler (e.g. a method call or a block to
  instance_exec) against a different object. Defaults to `self`.
2016-05-15 18:44:16 -07:00
Tom Kadwill
775703e1f9 Document and test ActionDispatch server_port 2016-05-12 18:46:16 +01:00
Kasper Timm Hansen
50ef6ed450 Merge pull request #24982 from tomkadwill/improve_clarity_of_raw_host_with_port
Improve documentation and tests for raw_host_with_port and host_with_…
2016-05-11 22:07:27 +02:00
Tom Kadwill
6b9bd2e3b0 Improve documentation and tests for raw_host_with_port and host_with_port 2016-05-11 20:38:13 +01:00
Santiago Pastorino
5f7d3363c5 Merge pull request #24912 from prathamesh-sonpatki/api-fix-response-format
API only apps: Preserve request format for HTML requests too
2016-05-11 11:13:35 -03:00
Prathamesh Sonpatki
c33bda875e
API only apps: Preserve request format for HTML requests too
- Earlier we were responding with JSON format for HTML requests in a API
  app.
- Now we will respond with HTML format for such requests in API apps.
- Also earlier we were not testing the API app's JSON requests
  properly. We were actually sending HTML requests. Now we send correct
  JSON requests. Also added more test coverage.
- Based on the discussion from this commit -
  05d89410bf.

[Prathamesh Sonpatki, Jorge Bejar]
2016-05-11 09:04:02 +05:30
Rafael Mendonça França
8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Connor Shea
86c860ff0c
Update rails-dom-testing gem to 2.0
Resolves #24924.
2016-05-09 20:23:42 -06:00
Jordan Owens
31bc9f27c8 use Rack::Utils.valid_path? to check path
This commit uses the new method in Rack to check if a path is valid.
2016-05-09 14:04:45 -04:00
Molchanov Andrey
95e2d35bb8 Replace loop to until 2016-05-07 20:52:56 +03:00
Matthew Draper
33f8dac38b Merge commit 'fbdcf5221ad7ea3d40ad09651962fc85d101dd67'
Preparing for 5.0.0.rc1 release
2016-05-07 11:50:04 -05:00
Jon Atack
0c3012991a Helpers doc grammar fix [skip ci] 2016-05-07 17:15:23 +02:00
Rafael Mendonça França
fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
Rafael Mendonça França
bf876aa0b6 Make flash messages cookie compatible with Rails 4
In #18721 we removed the discard key from the session hash used to flash
messages and that broke compatibility with Rails 4 applications because they
try to map in the discarded flash messages and it returns nil.

Fixes #24726.
2016-05-06 15:12:31 -05:00
Guillermo Iguaran
de8f3cb483 Merge pull request #24896 from prathamesh-sonpatki/api-cleanup
BoomerAPI is not used anywhere, so removed it!
2016-05-06 15:05:38 -05:00
Prathamesh Sonpatki
6e189a2e3b
BoomerAPI is not used anywhere, so removed it!
- It was originally added in 83b4e9073f0852afc065 and partially
  removed in 05d89410bf97d0778e7.
2016-05-06 14:33:31 -05:00
Sean Griffin
21a3b180f1 Merge pull request #24029 from rthbound/dont-call-each-when-calling-body-on-response
Dont call each when calling body on response to fix #23964

Fixes #23964
2016-05-06 14:22:05 -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
Rafael Mendonça França
cece50d3a6 Move protected instance variable to the right place
There were a lot of protected instance variables in
AbsctractController::Rendering that were related to Action Controller
and Action View.

Moving to ActionController::Base's protected instance list we make it
closer to where they are really defined.
2016-05-05 11:18:10 -05:00
Kasper Timm Hansen
3bed679670 Merge pull request #24820 from maclover7/fix-15843
Ensure compatibility between ActionDispatch::Request::Session and Rack
2016-05-04 22:36:54 +02:00
Jon Moss
09159d8530 Ensure compatibility between ActionDispatch::Request::Session and Rack
Adding the `each` method is required for ensuring compatibility between
Rails, and other Rack frameworks (like Sinatra, etc.), that are mounted
within Rails, and wish to use its session tooling. Prior to this, there
was an inconsistency between ActionDispatch::Request::Session and
Rack::Session::Cookie, due to the absence of the `each` method. This
should hopefully fix that error. :)

For a full integration test with Sinatra and a standalone Rack
application, you can check out the gist for that here: https://gist.github.com/maclover7/08cd95b0bfe259465314311941326470.

Solves #15843.
2016-05-04 15:49:25 -04:00
Joe Rafaniello
d2660c8cad Fix some typos in comments.
[ci skip]
2016-05-04 12:22:23 -04:00
Rafael França
3de5078fa6 Merge pull request #24845 from tomkadwill/action_controller_typos
Fix actionpack typos [ci skip]
2016-05-04 01:07:24 -05:00
Tom Kadwill
6cb854f707 Fix actionpack typos [ci skip] 2016-05-04 07:00:47 +01:00
Vipul A M
e7de870ec7 Merge pull request #24777 from tomkadwill/action_pack_typos_3
Fix actionpack typos [ci skip]
2016-04-30 22:17:12 +05:30
Tom Kadwill
41b7b8216c Fix actionpack typos [ci skip] 2016-04-30 17:41:50 +01:00
Jon Moss
e0b5a773cc Remove last uses of @env[] and @env[]=
Last August (2015), @tenderlove worked to remove all `@env[]` and `@env[]=`, in
favor of using `set_header`, `get_header`, etc. (Here's an [example
commit](f16a33b68e)).

This PR should remove the last uses of these methods, and fully convert
them to the newly standardized API.
2016-04-28 20:26:58 -04:00
eileencodes
f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Derek Prior
cacded5a0e Add more info to insecure URL generation error
I always appreciate having a bit more information as to why something is
now an error. We can use this error to tell people why what they were
previously doing is insecure and give them hints on how to fix it.

Signed-off-by: Kasper Timm Hansen <kaspth@gmail.com>
2016-04-26 22:14:03 +02:00
Jeremy Daer
9364d50654
Merge pull request #24641 from rafaelfranca/fix-per-form-token-with-full-url
Discart the schema and host information when building the per-form token
2016-04-25 21:03:33 -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
Guillermo Iguaran
65d743904c Merge pull request #24701 from prathamesh-sonpatki/deprecate-request_via_redirect
Deprecate `request_via_redirect` method.
2016-04-24 00:04:26 -05:00
Prathamesh Sonpatki
3da0a2b065
Deprecate request_via_redirect method.
- Followup of https://github.com/rails/rails/issues/18693.
- I think we missed deprecating `request_via_redirect` in that pull
  request.
- Originally requested by DHH here
  https://github.com/rails/rails/issues/18333.
2016-04-24 07:18:11 +05:30
Vipul A M
1ffa1a852e Merge pull request #24697 from tomkadwill/action_pack_typos_2
Actionpack documentation typos [ci skip]
2016-04-23 19:03:28 +05:30
Tom Kadwill
51a2f7bb67 Actionpack documentation typos [ci skip] 2016-04-23 14:24:10 +01:00
Vipul A M
f0a2edc7fc Merge pull request #24669 from tomkadwill/action_pack_typos
Actioncable and Actionpack documentation typos [ci skip]
2016-04-22 02:07:29 +05:30
Tom Kadwill
5646895b7f Actioncable and Actionpack documentation typos [ci skip] 2016-04-21 21:32:06 +01:00
Jon Moss
7bd2f91773 Fix ApplicationController.renderer.defaults.merge!
Previously, users were trying to modify a frozen Hash. Includes a
regression test :)

Fixes #22975
2016-04-20 19:47:16 -04:00
Rafael Mendonça França
60c6b53817 Discart the schema and host information when building the per-form token
When the token is generated by the form we were using the schema and
host information while only using the path to compare if the action was
the same. This was causing the token to be invalid.

To fix this we use the same information to generate the token and check
it.

Fix #24257
2016-04-20 00:48:32 -03:00
Jeremy Daer
ee25e1992c
Merge pull request #24031 from samphilipd/sam/do_not_clobber_options_in_route_definitions
Do not destructively mutate passed options hash in route definitions
2016-04-19 15:01:28 -07:00
Anton Rieder
46d31a1453 Update send_data documentation [ci skip]
Add missing period after sentence.
2016-04-19 17:02:46 +02:00