Commit Graph

14697 Commits

Author SHA1 Message Date
Carlos Antonio da Silva fd1dac6c27
Merge pull request #37139 from Shopify/define-url-helper-patch
Optimize UrlHelper.optimize_helper?
2019-09-05 14:55:26 -03:00
Jean Boussier ae390b3795 Optimize UrlHelper.optimize_helper? 2019-09-05 16:49:31 +02:00
Akira Matsuda ea791e53f9 No need to synchronize for just reading an ivar, at least in MRI
thanks to GVL.
2019-09-04 12:45:27 +09:00
Ryuta Kamizono 0770c025bd Do not enforce no braces for hash argument
Non-kwargs parameters should be to be braced for https://github.com/ruby/ruby/pull/2395.
See https://bugs.ruby-lang.org/issues/14183 for details.

`Style/BracesAroundHashParameters` cop conflicts with that.

This removes `Style/BracesAroundHashParameters` cop and auto-correct to
following changes.

d94263f...5665fb5
2019-09-04 08:49:36 +09:00
Cliff Pruitt 89c62a7bdb Do not set response "Vary" header if it has already been set
If an app sets the `"Vary"` header in an action to a value other than `"Accept"`, the `_set_vary_header` method will reset it's value to `"Accept"`.

This commit checks the header to be sure that it does not already have a value before setting the header to `"Accept"`.
2019-09-03 11:54:40 -04:00
Akira Matsuda 5665fb5f6e send with **options only when options is not empty
or this causes "ArgumentError: wrong number of arguments (given 1, expected 0)" in some methods
2019-09-03 20:59:14 +09:00
Akira Matsuda b7e591a55f These RequestHelpers' methods take keyword arguments 2019-09-03 18:55:50 +09:00
Akira Matsuda 614b552a0a RequestEncoder.register_encoder takes keyworded arguments 2019-09-03 18:14:39 +09:00
Akira Matsuda 08ee9d1490 Passing in a Hash instance as non-kwargs parameters has to be braced in Ruby 3.0 syntax 2019-09-03 18:12:23 +09:00
Akira Matsuda b5704f3b38 Passing in a Hash instance as kwargs parameters requires the "double splat" prefix 2019-09-03 18:10:18 +09:00
Woody Peterson b44740d48d Fix route from "(:a)(foo/:b)" when only given :b
Previously, when generating a root path from a route having nested
optional scopes where second-level or greater scopes had a static part,
and when providing only a second-level option, it would result in an
invalid path leading with "//". Ex. a path generated from the route
"(:a)(foo/:b)", given `b: 'bar'`, would return "//foo/bar".

Commit 7670d60977 introduced this bug while fixing the edge case of
empty strings returned when no options are passed to such routes.

A previous commit fixed this for simpler hierarchical cases like
"(:a)(:b)(:c)", and this fixes it for "(:a)(foo/:b)(bar/:c)".
2019-08-28 21:58:06 -07:00
Woody Peterson c218233472 Fix route from "(:a)(:b)" when given only :a or :b
Previously, when generating a root path from a route having nested
optional scopes, and when providing an option, would result in an
invalid path leading with "//". For example, the route
"(:locale)(:region)", given `locale: 'es'`, would output "//es".

Commit 7670d60977 introduced this bug while fixing the edge case of
empty strings returned when no options are passed to such routes.

This commit fixes both cases.
2019-08-28 21:57:05 -07:00
Daniel Vandersluis b99c21a015 Remove locale key for to_sentence
For example, HasManyThroughSourceAssociationNotFoundError uses
to_sentence to create its message, but was hardcoded to use the `en`
locale. In cases where this locale did not exist, this caused the
exception to be suppressed in favour of an I18n::InvalidLocale
exception.

This change removes the hardcoded locale, which allows I18n to use its
default locale.
2019-08-27 14:53:17 -04:00
Ryuta Kamizono b65bb377fe Fix `content_type=` to not discard extra part
In #36996, the behavior of `content_type=` has been changed to treat a
`content_type` itself as a mime type if a `content_type` doesn't contain
`charset=...` part.

i.e.

```ruby
response.content_type = "text/html; fragment"
response.media_type # => "text/html; fragment"

response.content_type = "text/html; fragment; charset=utf-16"
response.media_type # => "text/html"
```

That is tricky and strange.

I think that we cannot distinguish whether extra part is a part of mime
type or not for now. So at least in Rails 6.0, we should not discard
extra part conservatively as before.
2019-08-23 05:22:53 +09:00
Ryuta Kamizono 85c0f96618 Revert "Partly revert unnecessary change in #36996"
This reverts commit 35737465ff.
2019-08-23 05:16:51 +09:00
Aaron Patterson 3ae59fe14a
Merge pull request #37015 from cpruitt/action-dispatch-default-test-headers-ascii-8bit
Encode ActionDispatch::TestRequest::DEFAULT_ENV headers as ASCII-8BIT
2019-08-22 14:02:40 -04:00
Cliff Pruitt da0bcfb44a Encode ActionDispatch::TestRequest::DEFAULT_ENV headers as ASCII-8BIT
Request headers provided by servers are ASCII-8BIT encoded. This commit sets up the `ActionDispatch::TestRequest::DEFAULT_ENV` headers so that they are likewise encoded as ASCII-8BIT.
2019-08-22 12:58:57 -04:00
Ryuta Kamizono 35737465ff Partly revert unnecessary change in #36996
Actually the change is not required, and is not tested.

https://github.com/rails/rails/pull/36996#discussion_r316222037
2019-08-23 00:39:52 +09:00
Ryuta Kamizono 4dbb7aa58b Revert "Merge pull request #37001 from abhaynikam/36996-remove-unused-null-content-type-header"
This reverts commit 3ec1daddc8, reversing
changes made to 2a3f759eef.
2019-08-23 00:39:52 +09:00
Abhay Nikam 42dae0ab05 Removed unused NullContentTypeHeader after changes in #36996
Rebuild CI
2019-08-21 17:24:08 +05:30
Aaron Patterson 10b18163de
Support extra stuff in the Content-Type header via Mime registration
I'm not sure a better way to describe this, but we need to set extra
stuff in the Content-Type header and we're doing it via Mime
registration so that we can have the "html_fragment" method on the
respond_to type.  This worked in Rails 5.2, but it's broken in 6.0

In the future, I think we should probably give `register` a block that
takes the response object so we can do more interesting and complex
stuff without doing weird string manipulation.  But this patch fixes the
issue we have today.
2019-08-20 10:26:37 -07:00
Akira Matsuda 8ebd6e5ccc No need to dup options hash where it's not modified 2019-08-19 00:09:08 +09:00
Akira Matsuda c45eaffa27 Reduce String allocations while handling HTTP headers 2019-08-19 00:03:25 +09:00
Akira Matsuda c487a82773 `additions` here never will be empty
it at least includes something appended 3.lines.above
2019-08-18 23:58:13 +09:00
Akira Matsuda 09ad1ec0bf Reduce String creations in HelperMethodBuilder.get() 2019-08-18 23:58:13 +09:00
Akira Matsuda bbb35d94e1 respond_to? usually receives the method with a Symbol 2019-08-18 23:58:13 +09:00
John Hawthorn 79953c476c Allow tests to run without a TTY
We had two tests which assigned IO.console.winsize (to ensure output was
consistent), however it's possible for IO.console to be nil.

This commit makes these tests stub IO.console_size directly (the method
we actually call, we shouldn't have been relying on that calling
IO.console.winsize anyways) or passes the width when initializing the
class.

This allows tests to run without a TTY. This can be tested with ex.

    ssh localhost "cd src/rails/actionpack && bundle exec rake"

or

    (setsid bundle exec rake) </dev/null |& cat
2019-08-14 10:52:21 -07:00
Kasper Timm Hansen 12001611d6
Require and support rails-html-sanitzer 1.2.0
Rails now requires 1.2.0 because it relies on the safe_list_sanitizer
API exclusively.

Also raise `sanitizer_vendor` API from the dead for
rails-deprecated_sanitizer.

Fixes https://github.com/rails/rails-deprecated_sanitizer/pull/6
2019-08-09 00:07:45 +02:00
Rafael Mendonça França fb5f8d4f86
Remove invalid autoload of ActionDispatch::Http::Upload
This constant doesn't exists.
2019-08-08 15:08:45 -04:00
Kasper Timm Hansen 4f235e9a86
Merge pull request #36537 from quadule/fix-cookie-rotation-hash-pollution
Fix cookie modification during rotation
2019-08-05 03:57:08 +02:00
Eugene Kenny 7cf445d3bd Use media_type instead of content_type internally
These calls to `content_type` were triggering the deprecation from
c631e8d011 in upgraded applications.

We can use `media_type` in all of these cases to avoid the deprecation.
2019-08-04 00:35:49 +01:00
Rafael Mendonça França 847ad98e07
ConditionalGet needs time core_ext 2019-08-02 01:12:36 -04:00
Rafael Mendonça França 967beb7229
Revert "MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now"
This reverts commit 98d0f7ebd3.
2019-08-02 00:24:21 -04:00
Rafael Mendonça França 6384933994
Revert "You give jruby_skip & rubinius_skip a good name"
This reverts commit 8d2866bb80.
2019-08-02 00:24:11 -04:00
Akira Matsuda 8d2866bb80 You give jruby_skip & rubinius_skip a good name
This hack prevails everywhere in the codebase by being copy & pasted, and it's actually not a negative thing but a necessary thing for framework implementors,
so it should better have a name and be a thing.

And with this commit, activesupport/test/abstract_unit.rb now doesn't silently autoload AS::TestCase,
so we're ready to establish clearner environment for running AS tests (probably in later commits)
2019-08-02 05:36:38 +09:00
Akira Matsuda 98d0f7ebd3 MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now
It's used everywhere, clean and mature enough
2019-08-02 05:36:15 +09:00
Akira Matsuda 530f7805ed It may be better to explicitly require 'object/try' where we call `try`
In most cases it works now without explicit require because it's accidentally required through
active_support/core_ext/date_and_time/calculations.rb where we still call `try`,
but that would stop working if we changed the Calculations implementation and remove the require call there.
2019-08-01 18:51:51 +09:00
Akira Matsuda af2129b4c7 Use `try` only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
st0012 56d1977596 Respect Content-Type header passed in head method
This closes #28850
2019-08-01 14:57:20 +08:00
Akira Matsuda 511d1abc8a Reduce method invocations and object allocations in head() 2019-07-31 17:41:34 +09:00
Akira Matsuda 34a7e68bb9 Reduce Array allocations 2019-07-31 17:41:34 +09:00
Akira Matsuda c46172171b Reduce block execution 2019-07-31 17:41:34 +09:00
Akira Matsuda f0fdeaa175 Reduce method calls 2019-07-31 17:41:34 +09:00
Akira Matsuda 5ae814d016 Reduce Array assignment by not giving a name for unused `*args` 2019-07-31 17:41:34 +09:00
Akira Matsuda acf7642ece Reduce some more Hash#fetch + default object allocations 2019-07-31 17:40:05 +09:00
Akira Matsuda a1d7d4c6dc Reduce Hash object creation when normalizing request env 2019-07-31 11:51:59 +09:00
Akira Matsuda b8d29f35f0 Reduce object allocations in Middleware::Static 2019-07-31 11:51:59 +09:00
Akira Matsuda f915341628 Reduce unnecessary String creation by not `to_s`ing until nothing matches 2019-07-31 11:51:19 +09:00
Akira Matsuda 303f388d93 Reduce String allocation when finding controller class 2019-07-31 11:51:19 +09:00
Akira Matsuda 23009e3e33 No need to dup the payload for an instrumentation 2019-07-31 11:51:19 +09:00
Akira Matsuda 0196551e60 Use match? where we don't need MatchData 2019-07-29 14:23:10 +09:00
Akira Matsuda 26edd1d112 Revert "Use assert_match / assert_no_match for asserting match"
This reverts commit e9651deea4.

Now we're having both `=~` and `match?` for these objects, and it's nicer to have explicit tests for both of them
2019-07-29 14:17:36 +09:00
Akira Matsuda d55dea5ef1 Add Mime::Type#match? that doesn't create MatchData 2019-07-29 14:17:36 +09:00
Ryuta Kamizono 36b32bb32e Revert "Merge pull request #36785 from shes50103/fix_typo_actionpack_changelog"
This reverts commit ac6f3c9299, reversing
changes made to 5b0ea95a1a.
2019-07-28 15:55:38 +09:00
shes50103 c3d5c9447a fix typo in actionpack CHANGELOG.md 2019-07-28 11:17:19 +08:00
Rafael Mendonça França 5b0ea95a1a
Merge pull request #36545 from tomfakes/screenshot-updates
HTML page save during screenshot and multiple shots per test
2019-07-27 22:48:24 -04:00
Akira Matsuda d1ffe59ab5 Use match? where we don't need MatchData
We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
2019-07-27 13:06:49 +09:00
Akira Matsuda e9651deea4 Use assert_match / assert_no_match for asserting match 2019-07-27 13:06:49 +09:00
yuuji.yaginuma e69a7ee42d Fix "warning: ambiguous first argument; put parentheses or a space even after `/' operator" 2019-07-27 10:41:37 +09:00
Simone Carletti 6ea09841f2 Fix error 500 caused by ActionController::RoutingError (via fail-safe) when POST parameters are invalid (#29985)
* Reproduce error caused by malformed parameters

    Error:
    RequestFormat#test_format_does_not_throw_exceptions_when_invalid_POST_parameters:
    ActionDispatch::Http::Parameters::ParseError: 765: unexpected token at '{record:{content:24.12.1.146}}'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/parameters.rb:113:in `rescue in parse_formatted_parameters'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/parameters.rb:107:in `parse_formatted_parameters'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/request.rb:360:in `block in POST'
        /Users/weppos/.rvm/gems/ruby-2.3.3/gems/rack-2.0.3/lib/rack/request.rb:57:in `fetch'
        /Users/weppos/.rvm/gems/ruby-2.3.3/gems/rack-2.0.3/lib/rack/request.rb:57:in `fetch_header'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/request.rb:359:in `POST'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/parameters.rb:53:in `parameters'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/mime_negotiation.rb:62:in `block in formats'
        /Users/weppos/.rvm/gems/ruby-2.3.3/gems/rack-2.0.3/lib/rack/request.rb:57:in `fetch'
        /Users/weppos/.rvm/gems/ruby-2.3.3/gems/rack-2.0.3/lib/rack/request.rb:57:in `fetch_header'
        /Users/weppos/Mirrors/rails/actionpack/lib/action_dispatch/http/mime_negotiation.rb:60:in `formats'
        /Users/weppos/Mirrors/rails/actionpack/test/dispatch/request_test.rb:891:in `block in <class:RequestFormat>'

See GH-29983

* Capture parameter parsing error output and test it

This change prevents the log to be displayed in the tests.
Moreover, the assertion against the debug ensures that
the test effectively triggers the parsing error as expected.

* Use a generic value in the test

* Switch to assert_match

[Simone Carletti + Rafael Mendonça França]
2019-07-26 15:27:32 -04:00
Rafael França 7f16fedad3
Merge pull request #36254 from sharang-d/remove-named-helpers
Use a single term instead of all terms used to describe path and URL helpers together
2019-07-26 14:39:59 -04:00
Sharang Dashputre 18504eb78f Use a single term instead of all terms used to describe path and URL helpers together 2019-07-26 23:54:39 +05:30
Rafael França 0643dc44d5
Merge pull request #36779 from Shopify/optimize-url-helper-creation
Optimize Journey::Route#glob?
2019-07-26 14:16:45 -04:00
Jean Boussier 04beaa78c5 Optimize Journey::Route#glob? 2019-07-26 13:56:25 -04:00
st0012 5745a3c092 Add `Vary: Accept` header when rendering
Problem description (quoted from @rafaelfranca's excellent explanation in https://github.com/rails/jquery-ujs/issues/318#issuecomment-88129005):

> Let say that we requested /tasks/1 using Ajax, and the previous page has the same url. When we click the back button the browser tries to get the response from its cache and it gets the javascript response. With vary we "fix" this behavior because we are telling the browser that the url is the same but it is not from the same type what will skip the cache.

And there's a Rails issue discussing about this problem as well https://github.com/rails/rails/issues/25842

Also, according to [RFC 7231 7.1.4](https://tools.ietf.org/html/rfc7231#section-7.1.4)

>  An origin server SHOULD send a Vary header field when its algorithm
>  for selecting a representation varies based on aspects of the request
>  message other than the method and request target

we should add `Vary: Accept` header when determining content based on the `Accept` header.

Although adding such header by default could cause unnecessary cache invalidation. But this PR only adds the header if:
- The format param is not provided
- The request is a `xhr` request
- The request has accept headers and the headers are valid

So if the user
- sends request with explicit format, like `/users/1.json`
- or sends a normal request (non xhr)
- or doesn't specify accept headers

then the header won't be added.

See the discussion in https://github.com/rails/rails/issues/25842 and
https://github.com/rails/rails/pull/36213 for more details.
2019-07-26 13:52:06 +08:00
Rafael França 41bc4c6207
Merge pull request #36300 from okuramasafumi/make-handle-options-private
Make `handle_options` method private
2019-07-26 00:07:48 -04:00
Fumiaki MATSUSHIMA 6c69ff436a Fix flaky test ActionControllerBaseRenderTest#test_direct_render_to_string 2019-07-26 12:29:58 +09:00
Rafael Mendonça França c9b7b9ff8a
Merge pull request #36412 from robotdana/compact_blank
Add compact_blank shortcut for reject(&:blank?)
2019-07-25 16:18:18 -04:00
Edouard CHIN 1969f40a3a fix `follow_redirect!` not using the same HTTP verb on 307 redirection:
- According to the HTTP 1.1 spec, the 307 redirection guarantees that
  the method and the body will not be changed during redirection.

  This PR fixes that since follow_redirect! would always follow the
  redirection my making a GET request.

  Ref https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/307
2019-07-25 18:57:07 +02:00
George Claghorn d415eb4f6d
Stop setting a default Capybara app host
It's intended not to be set if Capybara starts the app server itself. Base Rails-generated URLs off of Capybara.current_session.server_url instead.
2019-07-24 22:19:21 -04:00
Edouard CHIN e6cf57df8a Define the `url_options` needed for SytemTest inside the route proxy:
- I made a change in https://github.com/rails/rails/pull/36691 to
  delegate route helper to a proxy class.
  This didn't take into account that the `url_options` we redefine
  in SystemTest would be ignored.

  This PR fixes that by definin the url_options inside the proxy
2019-07-24 01:18:00 +02:00
Yuya Tanaka 438af5507c
[ActionController] Fix send_file example for 404 2019-07-19 14:39:48 +09:00
yuuji.yaginuma efae4c268b Add support for script-src-attr / elem and style-src-attr / elem directives
These directives can be used in Chrome 75.
Ref: https://www.chromestatus.com/feature/5141352765456384
2019-07-18 10:00:54 +09:00
Rafael França 8d967534de
Merge pull request #36691 from Edouard-chin/ec-system-test-route
Don't include routes helpers inside System test class:
2019-07-17 15:11:53 -04:00
Edouard CHIN 2dbb904c5e Don't include routes helpers inside System test class:
- https://github.com/rails/rails/pull/36283 made a change to
  make SystemTest inherits from ActiveSupport::TestCase instead
  of ActionDispatch::IntegrationTest.

  With this change, the route helpers are now directly included inside
  the SystemTest class. This causes an edge case in case you have a
  routes whos name starts with `test_`, minitest will consider it as a
  test and will try to run it ab39d35fb4/lib/minitest/test.rb (L66)

  This PR uses a proxy and deleted missing method to a dummy class
  that has all the route helpers.
2019-07-16 22:18:32 +02:00
Rafael Mendonça França 650c070150
Reuse the exception class name in all places in the wrapper 2019-07-16 14:33:47 +01:00
Rafael Mendonça França 238d36715e
Make the selent exceptions configurable on the exception wrapper 2019-07-16 14:28:59 +01:00
Rafael Mendonça França a115a4cc79
Merge pull request #31634 from afcapel/reduce-routing-error-log-noise
Reduce log noise handling ActionController::RoutingErrors
2019-07-16 14:16:28 +01:00
Rafael França 71b0ca2aba
Merge pull request #36672 from jbaranov/strong-params-hash
Add hash method to ActionController::Parameters
2019-07-16 03:33:15 +01:00
Jacob Bednarz 6c5acd5bc1
Use reserved domain for example configuration
Updates the generator output to use a reserved domain[1] instead of a
potentially real world domain.

[1]: https://tools.ietf.org/html/rfc2606#section-3
2019-07-15 08:16:51 +10:00
Eugene Baranov 80aaa11188 Add hash method to ActionController::Parameters 2019-07-14 00:06:45 +03:00
Akira Matsuda 3676544141 active_support/rails has to be required via abstract_controller.rb 2019-07-12 18:33:31 +09:00
Akira Matsuda 00c3f3fca2 No Woman, No try 2019-07-12 18:32:45 +09:00
Akira Matsuda 71a20b0e6d try (Just a Little Bit Harder) 2019-07-12 18:30:58 +09:00
Akira Matsuda 0126f60d16 Make sure to require active_support.rb before requiring active_support/rails.rb 2019-07-12 18:30:58 +09:00
Jacob Bednarz bf19b8774e Adds support for configuring HTTP Feature Policy (#33439)
A HTTP feature policy is Yet Another HTTP header for instructing the
browser about which features the application intends to make use of and
to lock down access to others. This is a new security mechanism that
ensures that should an application become compromised or a third party
attempts an unexpected action, the browser will override it and maintain
the intended UX.

WICG specification: https://wicg.github.io/feature-policy/

The end result is a HTTP header that looks like the following:

```
Feature-Policy: geolocation 'none'; autoplay https://example.com
```

This will prevent the browser from using geolocation and only allow
autoplay on `https://example.com`. Full feature list can be found over
in the WICG repository[1].

As of today Chrome and Safari have public support[2] for this
functionality with Firefox working on support[3] and Edge still pending
acceptance of the suggestion[4].

#### Examples

Using an initializer

```rb
# config/initializers/feature_policy.rb
Rails.application.config.feature_policy do |f|
  f.geolocation :none
  f.camera      :none
  f.payment     "https://secure.example.com"
  f.fullscreen  :self
end
```

In a controller

```rb
class SampleController < ApplicationController
  def index
    feature_policy do |f|
      f.geolocation "https://example.com"
    end
  end
end
```

Some of you might realise that the HTTP feature policy looks pretty
close to that of a Content Security Policy; and you're right. So much so
that I used the Content Security Policy DSL from #31162 as the starting
point for this change.

This change *doesn't* introduce support for defining a feature policy on
an iframe and this has been intentionally done to split the HTTP header
and the HTML element (`iframe`) support. If this is successful, I'll
look to add that on it's own.

Full documentation on HTTP feature policies can be found at
https://wicg.github.io/feature-policy/. Google have also published[5] a
great in-depth write up of this functionality.

[1]: https://github.com/WICG/feature-policy/blob/master/features.md
[2]: https://www.chromestatus.com/feature/5694225681219584
[3]: https://bugzilla.mozilla.org/show_bug.cgi?id=1390801
[4]: https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/33507907-support-feature-policy
[5]: https://developers.google.com/web/updates/2018/06/feature-policy
2019-07-10 15:33:15 -07:00
John Hawthorn cd4541a1aa Fix Browser#preload for older Selenium
Older versions of selenium had driver_path on
::Selenium::WebDriver::Chrome directly, not on Service. This avoids
errors on those old versions and will preload properly if webdrivers is
installed.
2019-07-04 15:00:07 -07:00
John Hawthorn b21ef26661 Preload browser driver_path for system testing
The webdrivers gem configures Selenium::WebDriver::Service.driver_path
as a proc which updates the web drivers and returns their path.

This commit introduces SystemTesting::Browser#preload, which runs this
proc early. This ensures that webdrivers update is run before forking
for parallel testing, but doesn't explicitly tie us to that gem (and I
think anything configured as driver_path probably makes sense to
eager-load).
2019-07-03 13:56:50 -07:00
Tom Fakes c699a877ca Add code to save the HTML of the page being screenshotted during the `take_screenshot` method
that is enabled by a new environment variable - RAILS_SYSTEM_TESTING_SCREENSHOT_HTML=1

Add the ability to call `take_screenshot` more than once in a single test by prefixing the name of
the image file with a counter that is incremented on every `take_screenshot` call.  This allows a
developer to see their pages in sequence when trying to debug test errors.  This does not affect
the failure case where the prefix remains 'failures'
2019-06-25 21:04:30 -07:00
Milo Winningham 27db230bd1 Prevent serialized hash from being used as options 2019-06-22 12:43:11 -07:00
Milo Winningham 36b25aa1c4 Add test for cookie being modified by rotation 2019-06-22 12:43:11 -07:00
yuuji.yaginuma 09d55b3022 Add the ability to set the CSP nonce only to the specified directives
I changed to set CSP nonce to `style-src` directive in #32932.
But this causes an issue when `unsafe-inline` is specified to `style-src`
(If a nonce is present, a nonce takes precedence over `unsafe-inline`).

So, I fixed to nonce directives configurable. By configure this, users
can make CSP as before.

Fixes #35137.
2019-06-22 12:44:37 +09:00
yuuji.yaginuma ddb6d788d6 Make `ActionDispatch::Response#content_type` behavior configurable
I changed return value of `ActionDispatch::Response#content_type` in #36034.
But this change seems to an obstacle to upgrading. https://github.com/rails/rails/pull/36034#issuecomment-498795893

Therefore, I restored the behavior of `ActionDispatch::Response#content_type`
to 5.2 and deprecated old behavior. Also, made it possible to control the
behavior with the config.
2019-06-21 07:17:14 +09:00
Ryuta Kamizono c81af6ae72 Enable `Layout/EmptyLinesAroundAccessModifier` cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Ryuta Kamizono 648144649a
Merge pull request #36426 from abhaynikam/bump-codeclimate-rubocop-version
Bump rubocop to 0.71
2019-06-06 20:40:20 +09:00
Abhay Nikam 00b3b68602 Bump rubocop to 0.71 2019-06-06 15:34:50 +05:30
yuuji.yaginuma fef8d97a2c Fix broken driver test
Since `selenium-webdrive` v3.1.30, use `goog:chromeOptions'` key for
sending chrome options.
Ref: 0ba8188b1a
2019-06-06 13:47:17 +09:00
John Hawthorn 08e97650d6
Merge pull request #36399 from jhawthorn/named_controller_helper_module
Name helper_method module and improve source location
2019-06-05 08:20:50 -07:00
Dana Sherson c8847c17a7 Add compact_blank shortcut for reject(&:blank?)
I frequently find myself having to .compact but for blank. which means
on an array reject(&:blank?) (this is fine), or,
on a hash `.reject { |_k, v| v.blank? }` which is slightly more
frustrating and i usually write it as .reject(&:blank?) first and am
confused when it's trying to check if the keys are blank.

I've added the analagous .compact_blank! where there's a reject! to
build on (there's also a reject! in Set, but there's no other core_ext
touching Set so i've left that alone)
2019-06-05 18:18:17 +10:00
Ryuta Kamizono cc27e9988f Unify to use 4 spaces indentation in CHANGELOGs [ci skip]
Especially, somehow `CHANGELOG.md` in actiontext and activestorage in
master branch had used 3 spaces indentation.
2019-06-05 05:53:49 +09:00
John Hawthorn 4ab00cfac0 Use file/line from call to helper_module 2019-06-03 20:06:57 -07:00
John Hawthorn 17424a7de1 Give HelperMethods module a name 2019-06-03 18:59:51 -07:00
Abhay Nikam a04a0330a5 Remove unnecessary require pathname from actionpack controller specs 2019-06-02 20:23:10 +05:30
yuuji.yaginuma 22274d320e Simplify `ActionDispatch::Response#content_type` 2019-06-02 07:26:42 +09:00
yuuji.yaginuma ea5f509643 Change `ActionDispatch::Response#content_type` returning Content-Type header as it is
Since #35709, `Response#conten_type` returns only MIME type correctly.
It is a documented behavior that this method only returns MIME type, so
this change seems appropriate.
39de7fac05/actionpack/lib/action_dispatch/http/response.rb (L245-L249)

But unfortunately, some users expect this method to return all
Content-Type that does not contain charset. This seems to be breaking
changes.

We can change this behavior with the deprecate cycle.
But, in that case, a method needs that include Content-Type with
additional parameters. And that method name is probably the
`content_type` seems to properly.

So I changed the new behavior to more appropriate `media_type` method.
And `Response#content_type` changed (as the method name) to return Content-Type
header as it is.

Fixes #35709.

[Rafael Mendonça França & Yuuji Yaginuma ]
2019-06-01 09:20:13 +09:00
Alberto Fernández Capel c8f4c53d55 Reduce log noise handling ActionController::RoutingErrors
Each time a missing route is hit 32 lines of internal rails traces
are written to the log. This is overly verbose and doesn't offer
any actionable information to the user.

With this change we'll still write an error message showing the
route error but the trace will be omitted.
2019-05-28 20:39:10 +01:00
yaojie 430d931738 remove unused requires from debug_exceptions 2019-05-28 12:28:19 +08:00
Alberto Almagro 20104ba13d Remove Route#build as it wasn't used
After @kamipo CR feedback we realized `Route#build` wasn't used. As it
is also private API being able to create Routes both with `#new` and
`#build` was redundant.
2019-05-22 23:59:18 +02:00
Alberto Almagro 963b3ed9b6 Use keyword arguments for ActionDispatch::Routing::Mapper::Mapping constructor
This commit changes from constructor's argument list to keyword
arguments in order to remove the dependency of remember parameters'
positions.

It also unifies all parameters extracted from the `scope` into
`scope_params`, which also takes care of providing the default values
for them.
2019-05-22 23:03:56 +02:00
Alberto Almagro 29506d0f03 Use keyword arguments for ActionDispatch::Journey:Route constructor
This commit changes from constructor's argument list to keyword
arguments in order to remove the dependency of remember parameters'
positions.

The constructor already provided a default value for `internal`, this
commits takes the chance to also add default values for `precedence` and
`scope_options`.
2019-05-22 23:03:56 +02:00
Alberto Almagro fb9117e190 Keep part when scope option has value
When a route was defined within an optional scope, if that route didn't
take parameters the scope was lost when using path helpers. This patch
ensures scope is kept both when the route takes parameters or when it
doesn't.

Fixes #33219
2019-05-22 23:03:54 +02:00
Rafael França ff34f78248
Merge pull request #36329 from XrXr/no-doc-template-assertions
Remove compatibility module from docs [ci skip]
2019-05-22 12:08:26 -04:00
Alan Wu 1db8438d10 Remove compatibility module from docs [ci skip]
This module exists to warn old users. I think we should remove
it from the docs so we don't advertise it.
2019-05-22 11:58:14 -04:00
Gustavo Gutierrez bc7e94503a
Implemented deep_transform_keys/! for ActionController::Parameters 2019-05-22 16:04:31 +02:00
Kasper Timm Hansen bbd065204e
Merge pull request #36306 from cseelus/responsive-rescues-layout
Make rescues layout responsive
2019-05-20 08:33:03 -05:00
Ryuta Kamizono 38a945d615 Merge pull request #36302 from eugeneius/parameters_transform_keys_enumerator
Return parameters enumerator from transform_keys/!
2019-05-20 18:12:18 +09:00
Chris Seelus 75a16b3790 Make rescues layout responsive 2019-05-20 05:46:25 +02:00
Eugene Kenny 46e84d5b10 Return parameters enumerator from transform_keys/!
Previously calling `ActionController::Parameters#transform_keys/!`
without passing a block would return an enumerator for the underlying
hash, which was inconsistent with the behaviour when a block was passed:

    ActionController::Parameters.new(foo: "bar").transform_keys { |k| k }
    => <ActionController::Parameters {"foo"=>"bar"} permitted: false>
    ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k }
    => {"foo"=>"bar"}

An enumerator for the parameters is now returned instead, ensuring that
evaluating it produces another parameters object instead of a hash:

    ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k }
    => <ActionController::Parameters {"foo"=>"bar"} permitted: false>
2019-05-18 22:49:32 +01:00
Gannon McGibbon 88b12b2f60
Merge pull request #36122 from cseelus/respect-operating-system-color-scheme-for-errors
Regard operating system color scheme for rescues
2019-05-18 16:00:40 -04:00
Chris Seelus d8f4cfa76f Implement dark color scheme for rescues layout 2019-05-18 12:32:53 +02:00
OKURA Masafumi 7a59b9f1a0 Make `handle_options` method private
`handle_options` method in `CookieJar` is used internal only,
so it should be private.
2019-05-18 19:11:56 +09:00
shioimm f5e2d9838a Rename `hash` to `jar` in CookieJar.build
In CookieJar.build, the name `hash` is used as block parameter name
for tap method.
However, it is actually not hash but a CookieJar's instance.
The name `hash` was confusing, so replace with `jar`.
2019-05-18 17:41:58 +09:00
George Claghorn c8396e030f
Permit running jobs in system tests
Inherit from ActiveSupport::TestCase instead of ActionDispatch::IntegrationTest. Active Job automatically mixes its test helper into the latter, forcibly setting the test queue adapter before Capybara starts its app server.

As a bonus, we no longer need to remove the parts of the ActionDispatch::IntegrationTest API we don’t want to expose.
2019-05-16 09:02:36 -04:00
L.Fexon 858c63a0a4 fixed usage of Parameters when a non-numeric key exists
test for non-numeric key in nested attributes

test: extra blank line between tests removed

test for non-numeric key fixed (by Daniel)

Update according to feedback
2019-05-13 15:03:27 +08:00
Sam Bostock affe3e2e15
Bubble up IntegrationTest assertions count
`IntegrationTest#open_session` uses `dup` to create the new session,
which meant it had its own copy of `@assertions`. This prevented the
assertions from being correctly counted and reported.

Child sessions now have their `attr_accessor` overriden to delegate to
the root session.
2019-05-08 20:06:10 -04:00
John Hawthorn 6f549ce53f Only build middleware proxy when instrumentating
The instrumentation proxy adds three stack frames per-middleware, even
when nothing is listening.

This commit, when the middleware stack is built, only adds
instrumentation when the `process_middleware.action_dispatch` event has
already been subscribed to.

The advantage to this is that we don't have any extra stack frames in
apps which don't need middleware instrumentation.

The disadvantage is that the subscriptions need to be in place when the
middleware stack is built (during app boot). I think this is likely okay
because temporary AS::Notifications subscriptions are strongly
discouraged.
2019-05-08 13:30:41 -07:00
Ryuta Kamizono 28aca474d4 Auto-correct `Style/RedundantBegin` offence
This offenced code is introduced from forward ported #36196, since looks
like 6-0-stable branch isn't checked by CodeClimate.
2019-05-08 19:34:31 +09:00
Ryuta Kamizono 8024179d60 Remove forward ported CHANGELOG [ci skip] 2019-05-08 19:19:08 +09:00
Eileen M. Uchitelle d155f61b64 Merge pull request #36196 from st0012/fix-29947
Hide malformed parameters from error page

Accidentally merged this to 6-0-stable so forward porting it to master
here instead.
2019-05-07 15:14:14 -04:00
Rafael Mendonça França 9834be6565
Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
st0012 fb524896c4 Remove redundant test setups in log_subscriber_test
Because controllers' `perform_caching` config is `true` by default, it
means we actually enable the caching in all those tests implicitly (and
it works). Which also means we can avoid repeatedly declaring that and
just specify it once in the setup method (just for declaration).
2019-04-24 02:02:09 +08:00
Rafael França b62b038d9a
Revert "Include Caching module for ActionController::API" 2019-04-22 17:20:48 -04:00
Guillermo Iguaran 216ef01d14
Merge pull request #36038 from st0012/fix-35602
Include Caching module for ActionController::API
2019-04-22 16:05:51 -05:00
Richard Macklin ef12ccfd8b Make system tests take failed screenshots in `before_teardown` hook
Previously we were calling the `take_failed_screenshot` method in an
`after_teardown` hook. However, this means that other teardown hooks
have to be executed before we take the screenshot. Since there can be
dynamic updates to the page after the assertion fails and before we
take a screenshot, it seems desirable to minimize that gap as much as
possible. Taking the screenshot in a `before_teardown` rather than an
`after_teardown` helps with that, and has a side benefit of allowing
us to remove the nested `ensure` commented on here:
https://github.com/rails/rails/pull/34411#discussion_r232819478
2019-04-20 19:32:30 -07:00
Abhay Nikam 37b2c83dbc Change the deprecation message for dynamic routes segment to 6.1 2019-04-20 01:50:52 +05:30
Eileen M. Uchitelle 612af1926c
Merge pull request #36000 from JosiMcClellan/fix-screenshot-filenames
handle long or duplicated screenshot filenames
2019-04-19 10:30:59 -04:00
st0012 7814d1c0ae Make sure api controllers can perform caching as well
Currently ActionController::API doesn't include Caching module, so it
can't perform caching. And even if users include it later manually, it
won't inherit application's default cache store for action_controllers.
So the only way to solve this issue is to include Caching module in
ActionController::API, too.

This closes #35602
2019-04-19 22:50:42 +09:00
Genadi Samokovarov feaaa7576a Refactor after the most recent code review 2019-04-19 14:15:41 +09:00
Genadi Samokovarov 769f73cc18 Dispatch actions only if config.consider_all_requests_local is set 2019-04-19 14:15:41 +09:00
Genadi Samokovarov a3110fe20b Drop the ambiguous `ActiveSupport::ActionableError#===` check 2019-04-19 14:15:22 +09:00
Genadi Samokovarov 54df392bc5 Manage ActionDispatch::ActionableExceptions from the default middleware stack 2019-04-19 14:15:22 +09:00
Genadi Samokovarov 45f1c7a3e1 Introduce Actionable Errors
Actionable errors let's you dispatch actions from Rails' error pages. This
can help you save time if you have a clear action for the resolution of
common development errors.

The de-facto example are pending migrations. Every time pending migrations
are found, a middleware raises an error. With actionable errors, you can
run the migrations right from the error page. Other examples include Rails
plugins that need to run a rake task to setup themselves. They can now
raise actionable errors to run the setup straight from the error pages.

Here is how to define an actionable error:

```ruby
class PendingMigrationError < MigrationError #:nodoc:
  include ActiveSupport::ActionableError

  action "Run pending migrations" do
    ActiveRecord::Tasks::DatabaseTasks.migrate
  end
end
```

To make an error actionable, include the `ActiveSupport::ActionableError`
module and invoke the `action` class macro to define the action. An action
needs a name and a procedure to execute. The name is shown as the name of a
button on the error pages. Once clicked, it will invoke the given
procedure.
2019-04-19 14:14:06 +09:00
Josi McClellan 51cb5d4a20 truncate screenshot filenames to avoid error 2019-04-18 15:20:22 -05:00
Rafael França 60afbfffdc
Merge pull request #35975 from xithan/master
mounted routes with non-word characters
2019-04-15 18:12:57 -04:00
xithan 64ed91f5aa mounted routes with non-word characters 2019-04-15 15:11:13 +02:00
Patrik Bóna 93e0f975e9 Remove unused modules from StrongParameters
Unless I'm missing some undocumented use case, these modules aren't
needed in `StrongParameters` anymore since 8e221127ab. Also, all
actionpack tests are passing without them.
2019-04-15 10:14:51 +02:00
Matthew Draper 3bd5342871
Merge pull request #32541 from sergiogomez/remove-lock-from-params-wrapper
Remove lock from method model
2019-04-12 18:22:12 +09:30
Rafael França 98e10c2dea
Merge pull request #35919 from Shopify/simplify-define_url_helper
Simplify and fasten NamedRouteCollection#define_url_helper
2019-04-11 18:43:58 -04:00
Jean Boussier fdfd9e399f Simplify and fasten NamedRouteCollection#define_url_helper 2019-04-10 13:42:08 +02:00
Brandon Weaver 79c15566da Adds named_captures to MatchData to emulate Regex
This change adds a `named_captures` method to
`ActionDispatch::Journey::Path::MatchData` in order to emulate a similar
method present on `Regex`'s `MatchData` present in Ruby core.

This method can be useful for introspection of routes without the need
to use `zip` while testing or developing in Rails core.
2019-04-09 12:40:26 -07:00
Ryuta Kamizono 069f2e250a `ast` is no longer to be `nil` since #33118 2019-04-05 10:52:17 +09:00
Fumiaki MATSUSHIMA 61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
Rafael França 9d02b1bd58
Merge pull request #35842 from Shopify/deduplicate-routing-strings
Deduplicate strings held by the router
2019-04-03 16:53:51 -04:00
Jean Boussier ed7234860b Deduplicate strings held by the router 2019-04-03 22:26:52 +02:00
Eileen M. Uchitelle d39b2b684e
Merge pull request #35825 from jhawthorn/always_filter_view_paths
Make Resolver#find_all_anywhere equivalent to #find_all
2019-04-03 13:21:51 -04:00
John Hawthorn eb52904eb5 Always reject files external to app
Previously, when using `render file:`, it was possible to render files
not only at an absolute path or relative to the current directory, but
relative to ANY view paths. This was probably done for absolutely
maximum compatibility when addressing CVE-2016-0752, but I think is
unlikely to be used in practice.

Tihs commit removes the ability to `render file:` with a path relative
to a non-fallback view path.

Make FallbackResolver.new private

To ensure nobody is making FallbackResolvers other than "/" and "".

Make reject_files_external_... no-op for fallbacks

Because there are only two values used for path: "" and "/", and
File.join("", "") == File.join("/", "") == "/", this method was only
testing that the absolute paths started at "/" (which of course all do).

This commit doesn't change any behaviour, but it makes it explicit that
the FallbackFileSystemResolver works this way.

Remove outside_app_allowed argument

Deprecate find_all_anywhere

This is now equivalent to find_all

Remove outside_app argument

Deprecate find_file for find

Both LookupContext#find_file and PathSet#find_file are now equivalent to
their respective #find methods.
2019-04-03 09:02:28 -07:00
Abhay Nikam e0c697e46c [ci skip] Doc for shallow: false options should use <tt> for better readability. PR after #24405 2019-04-03 11:40:01 +05:30
Ryuta Kamizono b2209ca59d Auto-correct rubocop offences 2019-04-03 08:40:15 +09:00
Rafael França 798f175c65
Merge pull request #24405 from waits/shallow-false
Honor shallow: false on nested resources
2019-04-02 19:32:13 -04:00
Sharang Dashputre 249622e748 url -> URL where apt inside actionpack/ 2019-04-01 22:58:02 +05:30
Emil Shakirov 43866b2ca3 Fix typo in the value of ENCRYPTED_SIGNED_COOKIE_SALT constant (#35619)
* Fix typo in the value of ENCRYPTED_SIGNED_COOKIE_SALT constant

* Fix value of cookie in with authenticated encryption flag off in tests

[Emil Shakirov + Ryuta Kamizono]
2019-04-01 10:03:29 +09:00
Ryuta Kamizono 51ab5cb043 Follow up tweaks b89a3e7e63 [ci skip]
* use backticks instead of `+`
* and more (e.g. missed replacing `Array#excluding` and
`Enumerable#excluding` in b89a3e7e63)
2019-03-31 09:52:02 +09:00
Aaron Patterson 2bf5517981
Merge pull request #35688 from jhawthorn/render_file_rfc
RFC: Introduce Template::File
2019-03-30 13:33:52 -07:00
Prathamesh Sonpatki 12701d5a46
Fix annotated typo 2019-03-29 20:42:35 +05:30
John Hawthorn 06c703570a Remove :all symbol from Mime::ALL
.all isn't a valid file extension, so it shouldn't used as a symbol.
This also makes Mime::ALL better match how */* is parsed from an Accept
header.
2019-03-27 16:47:48 -07:00
John Hawthorn c7820d8124 Introduce Template::File as new render file:
The previous behaviour of render file: was essentially the same as
render template:, except that templates can be specified as an absolute
path on the filesystem.

This makes sense for historic reasons, but now render file: is almost
exclusively used to render raw files (not .erb) like public/404.html. In
addition to complicating the code in template/resolver.rb, I think the
current behaviour is surprising to developers.

This commit deprecates the existing "lookup a template from anywhere"
behaviour and replaces it with "render this file exactly as it is on
disk". Handlers will no longer be used (it will render the same as if
the :raw handler was used), but formats (.html, .xml, etc) will still be
detected (and will default to :plain).

The existing render file: behaviour was the path through which Rails
apps were vulnerable in the recent CVE-2019-5418. Although the
vulnerability has been patched in a fully backwards-compatible way, I
think it's a strong hint that we should drop the existing
previously-vulnerable behaviour if it isn't a benefit to developers.
2019-03-27 15:51:25 -07:00
Rafael França 93dbbe3a81
Merge pull request #35236 from renuo/fix-30467
Prohibit sneaky custom params from being drawn (Fix #30467)
2019-03-27 16:31:16 -04:00
Josua Schmid 25f2e0c39d
Raise if resource custom params contain colons
After this change it's not possible anymore to configure routes
like this:

    routes.draw do
      resources :users, param: "name/:sneaky"
    end

Fixes #30467.
2019-03-26 13:53:41 +01:00
Edouard CHIN 378b4fedb1 Add the `Mime::Type::InvalidMimeType` error in the default rescue_response:
- https://github.com/rails/rails/pull/35604 introduced a vulnerability fix
  to raise an error in case the `HTTP_ACCEPT` headers contains malformated
  mime type.

  This will cause applications to throw a 500 if a User Agent sends an
  invalid header.

  This PR adds the `InvalidMimeType` in the default `rescue_responses` from
  the ExceptionWrapper and will return a 406. I looked up the HTTP/1.1
  RFC and it doesn't stand what should be returned when the UA
  sends malformated mime type. Decided to get 406 as it seemed to be the
  status the better suited for this.
2019-03-26 02:03:47 +01:00
Ryuta Kamizono d2f9b8e800 Address rubocop offences 2019-03-21 11:19:47 +09:00
Rafael França 7c6343078a
Merge pull request #35649 from andrehjr/fix-override-of-cookies-controller-specs
Don't override @set_cookies on CookieJar#update_cookies_from_jar'
2019-03-19 21:19:45 -04:00
Rafael Mendonça França a207b94227
Fix test broken by 04ae0b0b5e
This test was trying to set the exception_app in the wrapper proxy
instead in the middleware itself.
2019-03-19 18:42:37 -04:00
Aaron Patterson 12a1a6658c
Merge pull request #35669 from cpruitt/update-mime-type-regexp
Update regular expression for checking valid MIME type
2019-03-19 09:13:49 -07:00
Daniel Schierbeck 04ae0b0b5e Instrument middleware processing
Adds ActiveSupport::Notifications instrumentation of the processing of
each middleware in the stack.
2019-03-19 08:35:09 -07:00
Cliff Pruitt ab38aa4549 Update regular expression for checking valid MIME type
MIME Type validation regular expression does not allow for MIME types initialized with strings that contain parameters after the MIME type name.
2019-03-19 11:20:40 -04:00
Eileen M. Uchitelle 299573adc6
Merge pull request #35358 from tjwallace/patch-1
Add documentation for the resource(s) :param option
2019-03-19 09:29:00 -04:00
Eileen M. Uchitelle 7fe3c69331
Merge pull request #35604 from jhawthorn/validate_mime_types
Raise exception when building invalid mime type
2019-03-19 09:22:16 -04:00
Sharang Dashputre e4401c6436 Fix a ContentNegotiation test description 2019-03-19 16:57:32 +05:30
Tom Richards f80871fe60
Suggest 'strict-origin' Referrer-Policy header 2019-03-17 15:22:36 -04:00
André Luis Leal Cardoso Junior ca937c59cd Don't override @set_cookies on CookieJar#update_cookies_from_jar'
When building the cookie_jar for the current test request.
It was possible for this method to override keys currently being set on the test itself.
In situations such as when making two requests mixing creating the cookie on the test and the controller.
2019-03-17 01:26:51 -03:00
John Hawthorn b5e8942c95 Raise exception when building invalid mime type
This allows mime types in the form text/html, text/*, or */*

This required a few minor test/code changes where previously nil was
used as a mime string.
2019-03-14 11:33:48 -07:00
eileencodes a2bd669ed2 v6.0.0.beta3 release
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEEvJkGf0BARV+D0L2ulxXUSC76N8FAlyJN4cACgkQulxXUSC7
 6N9ZXAf/Wx7edIct8kZzcC6irlROx4DzpNbrrH792sO1OAcnoFDE7DPkokllTEP/
 4kzC42lca/XG27MCl7E0dtVD8hIyAl89nxid6cwKFVZVTPIRVc1wjXkoiWy/cvd7
 6+9IjxhlgrzxGnw3aWZJG7H3iqz69yr55aoSDU/TbMqq5kQrqNF95vr2nc8LEUco
 SLQj0pO/tfJdHquSeX0JiXn3VSEHT+5TdLGQ3J/w0wFU6mkecH4MJMJvMwLFx/v4
 llnvF6HyfSLASWbrpdD3h6MQHpImDoee5vILXAHzPdSaEVcVa1cDFtMcPMYiu8Dw
 AGdCAaHQhZFFGoYK472+o6pur0dxEA==
 =5dET
 -----END PGP SIGNATURE-----

Merge tag 'v6.0.0.beta3'

v6.0.0.beta3 release
2019-03-13 13:11:10 -04:00
Kurt Mueller 20613519c2 Update small typo in documentation. 2019-03-12 11:52:09 -04:00
Prathamesh Sonpatki c18166a39b
Show friendly message to install action mailbox if the related table does not exist
- This is similar to the work done in https://github.com/rails/rails/pull/31534
2019-03-12 17:01:36 +05:30
eileencodes 7c87fd5635 Prep release
* Update RAILS_VERSION
* Bundle
* rake update_versions
* rake changelog:header
2019-03-11 11:58:15 -04:00
Aaron Patterson 4c743587ad Fix possible dev mode RCE
If the secret_key_base is nil in dev or test generate a key from random
bytes and store it in a tmp file. This prevents the app developers from
having to share / checkin the secret key for dev / test but also
maintains a key between app restarts in dev/test.

[CVE-2019-5420]

Co-Authored-By: eileencodes <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2019-03-10 21:30:03 -07:00
John Hawthorn f4c70c2222
Only accept formats from registered mime types
[CVE-2019-5418]
[CVE-2019-5419]
2019-03-10 20:38:22 -07:00
Kasper Timm Hansen c87f6841b7
Merge pull request #35121 from utilum/warning_tried_to_create_proc_without_block
Ruby 2.7 warning: creating a Proc without a block
2019-03-10 16:31:15 +01:00
Ryuta Kamizono 08a93efab6
Merge pull request #35549 from r7kamura/feature/response-charset
Support other optional parameters and quoted-strings on Content-Type parser
2019-03-10 17:30:35 +09:00
r7kamura 29b42f5e5c Support other optional parameters and quoted-strings on Content-Type parser 2019-03-10 16:48:10 +09:00
Kasper Timm Hansen 0fc1397784
Merge pull request #35559 from ashishprajapati/ashishprajapati/important_textual_improvements
Added missing guide links in documentation and minor wording fix
2019-03-09 22:54:21 +01:00
ashishprajapati e3ef12b310 Added missing guide links in README documentation and minor wording fix [ci skip] 2019-03-10 03:17:01 +05:30
Abhay Nikam 476abd403b Updated links from http to https in guides, docs, etc 2019-03-09 16:43:47 +05:30
Shailesh Kalamkar de5d84bfbb [ci skip] Fix typos 2019-03-07 10:06:30 +05:30
Rafael França 3ee0dabb84
Merge pull request #35422 from ricardotk002/fix-indentation-ad-routing
Fix code examples' indentation in ActionDispatch::Routing
2019-02-26 14:44:33 -05:00
Ricardo Díaz f06e146965 Fix code examples' indentation in ActionDispatch::Routing [ci skip] 2019-02-26 14:04:08 -05:00
Aaron Patterson d4015a7f06
Pass locals in to the template object on construction
This commit ensures that locals are passed in to the template objects
when they are constructed, then removes the `locals=` mutator on the
template object.  This means we don't need to mutate Template objects
with locals in the `decorate` method.
2019-02-25 15:14:53 -08:00
Rafael Mendonça França 5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Aaron Patterson 790a3e69ac
Merge pull request #35400 from aglushkov/stream_manual_cache_control
Allow custom cache-control header in AC::Live
2019-02-25 13:33:22 -08:00
Aaron Patterson 2f128a82e6
Always pass a format to the ActionView::Template constructor
This means we can eliminate nil checks and remove some mutations from
the `decorate` method.
2019-02-25 12:26:25 -08:00