Commit Graph

71894 Commits

Author SHA1 Message Date
Yuki Nishijima
ef40fb6fd8 Fixed a bug where the debug view does not show the error page properly
There are two cases where the debug view does not show the error details
properly:

 * When the cause is mapped to an HTTP status code the last exception is
   unexpectedly uwrapped
 * When the last error is thrown from a view template the debug view is
   not using the `rescues/template_error.html.erb` to generate the view

Both the cases could be fixed by not unwrapping the exception. The only
case where the exception should be unwrapped is when the last error is
an `ActionView::Template::Error` object. In this case the HTTP status
code is determined based on the cause.

There are actually more wrapper exceptions that are intentionally
thrown. However, there is a consistent pattern of setting the original
message and original backtrace to the wrapper exception implemented, so
the debug view will not lose the information about what went wrong
eariler.
2019-01-24 20:30:20 -05:00
Kasper Timm Hansen
5f7d5995a6
Merge pull request #34789 from christos/fix-editing-new-environment-credentials
Don't load app environment when editing credentials
2019-01-25 00:07:33 +01:00
Rafael França
1b7f0283b9
Merge pull request #34994 from schuetzm/host-authorization-only-in-development
Recommend adding the requested domain to hosts whitelist only in deve…
2019-01-24 18:00:04 -05:00
Kasper Timm Hansen
36c840057f
Merge pull request #35021 from palkan/refactor/broadcasting-for-testing
Action Cable: move channel_name to Channel.broadcasting_for
2019-01-24 23:40:33 +01:00
Rafael França
87626a6042
Merge pull request #35047 from yuki24/prefer-strings-over-regex
Prefer strings over regex expressions
2019-01-24 17:35:56 -05:00
Rafael França
d2085f2bc4
Merge pull request #35045 from paracycle/uk-fix-partial-renderer
Fix partial renderer assuming `locals` responds to `symbolize_keys`
2019-01-24 17:19:01 -05:00
Rafael França
267136d87d
Merge pull request #35046 from kddeisz/make-and-and-case-node-expressions
Make `And` and `Case` into expression nodes
2019-01-24 16:00:46 -05:00
Yuki Nishijima
6922ba6cb6 Prefer strings over regex expressions
In this case statement, there are two patterns that start with the same
line:

  when %r{/not_found}
    ...
  when %r{/not_found_original_exception}
    ...

Because the string "/not_found_original_exception" does match the first
one, it is never routed to what it is supposed to be routed, causing one
of the tests for DebugExceptions to happen to be passing.

After changing the regex expressions back to strings, I noticed that the
test setup is not complete (the template object needs to be a proper
template object). Once I fixed it all the tests started padding.
2019-01-24 15:49:05 -05:00
Ufuk Kayserilioglu
44c07fd0be Add test for Hash-like object being passed to partial locals
The test passes an instance of `ActionController::Parameters` that acts
like a Hash but does not respond to some Hash methods like
`symbolize_keys`.

Moreover, if someone were to call `to_h` on the value it would fail since
the parameter is not permitted. So this is a great way to ensure that the
partial rendering pipeline does not mess with `locals`.
2019-01-24 22:41:19 +02:00
Ufuk Kayserilioglu
d5fcb5b9ad Revert "Allow usage of strings as locals for partial renderer" 2019-01-24 22:15:46 +02:00
Kevin Deisz
5cf36e2ea2
Make And and Case into expression nodes
Allows aliasing, predications, ordering, and various other functions on `And` and `Case` nodes. This brings them in line with other nodes like `Binary` and `Unary`.
2019-01-24 14:35:52 -05:00
Rafael França
1e25dfde03
Merge pull request #35033 from gmcgibbon/multilevel_command_root_namespace
Fix deeply nested namespace command printing
2019-01-24 13:13:10 -05:00
Gannon McGibbon
a670654882 Fix deeply nested namespace command printing 2019-01-24 12:28:43 -05:00
Simo Leone
c5b71c9bae
include the content type when uploading to S3 2019-01-24 17:05:49 +00:00
George Claghorn
c1e949e9e6 Prefer ImageProcessing's resize_to_limit macro over resize_to_fit
Don't upsize images smaller than the specified dimensions.
2019-01-24 11:46:42 -05:00
Ryuta Kamizono
1fecebae31 Allow column_exists? to be passed type argument as a string
Currently `conn.column_exists?("testings", "created_at", "datetime")`
returns false even if the table has the `created_at` column.

That reason is that `column.type` is a symbol but passed `type` is not
normalized to symbol unlike `column_name`, it is surprising behavior to
me.

I've improved that to normalize a value before comparison.
2019-01-24 19:02:44 +09:00
Yuji Yaginuma
4a40128a3f
Merge pull request #35040 from colorbox/fix_formatting_in_action_text_docs
Fix document formatting on Action Text docs [ci skip]
2019-01-24 18:03:50 +09:00
colorbox
91fc859016 Fix document formatting on Action Text docs [ci skip]
Use `+` instead of backquote.
2019-01-24 17:44:35 +09:00
Aaron Patterson
c91c71fa15
Merge pull request #35031 from rails/view-ivar
Pass the view around instead of using an ivar
2019-01-23 13:40:24 -08:00
Xavier Noria
0065011660 Tell the user what to use instead of update_attributes/! 2019-01-23 22:26:22 +01:00
Ryuta Kamizono
060fe16447
Merge pull request #35029 from dylanahsmith/fix-strictly-cast-attribute-types
activerecord: Fix statement cache for strictly cast attributes
2019-01-24 05:36:13 +09:00
Aaron Patterson
1853b0d0ab
Pass the view around instead of using an ivar
If we pass the view instance around it's easier to understand the flow
control.
2019-01-23 12:17:30 -08:00
Dylan Thacker-Smith
5b58cc4f44 activerecord: Fix statement cache for strictly cast attributes 2019-01-23 14:49:42 -05:00
Rafael França
d1456e3ad5
Merge pull request #34993 from schuetzm/allow-subdomains-of-localhost
Subdomains of localhost are safe against DNS rebinding
2019-01-23 13:15:15 -05:00
Kasper Timm Hansen
3aa094c527
Merge pull request #35027 from sponomarev/chore/fix-ac-test-typo
Fix attribute typo in ActionCable connection test request
2019-01-23 18:59:19 +01:00
Sergey Ponomarev
c125990c7c
Fix attribute typo in ActionCable connection test request 2019-01-23 09:35:48 -05:00
Marc Schütz
4dfb1a3961 Subdomains of localhost are safe against DNS rebinding 2019-01-23 13:30:35 +01:00
Marc Schütz
ee0d0b1220 Recommend adding the requested domain to hosts whitelist only in development 2019-01-23 13:11:35 +01:00
George Claghorn
8642e3dce5
Merge pull request #35024 from calasyr/patch-1
Corrected spelling of ActionCable::Connection::TestCase [ci skip]
2019-01-22 20:25:46 -05:00
Alan Brown
6d6be1f194
Corrected spelling of ActionCable::Connection::TestCase 2019-01-22 16:19:09 -08:00
Vladimir Dementyev
cfe65cb478
fix fixture syntax in cable docs and guides 2019-01-22 16:53:01 -05:00
Rafael França
afbab2822a
Merge pull request #35018 from gmcgibbon/revert_redirect_to_allow_other_host
Revert ensure external redirects are explicitly allowed
2019-01-22 15:35:57 -05:00
Rafael França
ea6a488f51
Merge pull request #35010 from Edouard-chin/ec-numericality-validator-fix
Fix NumericalityValidator on object responding to `to_f`:
2019-01-22 15:33:54 -05:00
Vladimir Dementyev
513dd2cfdb
Add note about broadcast_to/broadcasting_for to change log 2019-01-22 15:29:12 -05:00
Vladimir Dementyev
35bef64718
Add Channel#broadcast_to 2019-01-22 15:14:35 -05:00
Vladimir Dementyev
dc80459a9e
Move channel_name to Channel.broadcasting_for
That would allow us to test broadcasting made with channel, e.g.:

```ruby
class ChatRelayJob < ApplicationJob
  def perform_later(room, msg)
    ChatChannel.broadcast_to room, message: msg
  end
end
```

To test this functionality we need to know the underlying stream name
(to use `assert_broadcasts`), which relies on `channel_name`.

We had to use the following code:

```ruby
assert_broadcasts(ChatChannel.broadcasting_for([ChatChannel.channel_name, room]), 1) do
  ChatRelayJob.perform_now
end
```

The problem with this approach is that we use _internal_ API (we shouldn't care about `channel_name` prefix
in our code).

With this commit we could re-write the test as following:

```ruby
 assert_broadcasts(ChatChannel.broadcasting_for(room), 1) do
   ChatRelayJob.perform_now
 end
```
2019-01-22 15:14:20 -05:00
Ryuta Kamizono
0815474d2f
Merge pull request #35017 from yahonda/mysql8014
MySQL 8.0.14 adds `ER_FK_INCOMPATIBLE_COLUMNS`
2019-01-23 04:52:44 +09:00
Edouard CHIN
f01e38509c Fix NumericalityValidator on object responding to to_f:
- If you had a PORO that acted like a Numeric, the validator would
  work correctly because it was previously using `Kernel.Float`
  which is implicitely calling `to_f` on the passed argument.

  Since rails/rails@d126c0d , we are now using `BigDecimal` which does
  not implicitely call `to_f` on the argument, making the validator
  fail with an underlying `TypeError` exception.

  This patch replate the `is_decimal?` check with `Kernel.Float`.
  Using `Kernel.Float` as argument for the BigDecimal call has two
  advantages:

  1. It calls `to_f` implicetely for us.
  2. It's also smart enough to detect that `Kernel.Float("a")` isn't a
     Numeric and will raise an error.
     We don't need the `is_decimal?` check thanks to that.

  Passing `Float::DIG` as second argument to `BigDecimal` is mandatory
  because the precision can't be omitted when passing a Float.
  `Float::DIG` is what is used internally by ruby when calling
  `123.to_d`

  https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L47

- Another small issue introduced in https://github.com/rails/rails/pull/34693
  would now raise a TypeError because `Regexp#===` will just return
  false if the passed argument isn't a string or symbol, whereas
  `Regexp#match?` will.
2019-01-22 20:46:16 +01:00
Rafael França
1d359d4bf6
Merge pull request #35020 from alkesh26/ationpack-typo-fixes
Actionpack typo fixes.
2019-01-22 14:02:42 -05:00
Aaron Patterson
db4b77aca1
Merge pull request #34952 from rails/template-stuff
Template Handler Refactoring
2019-01-22 09:28:08 -08:00
alkesh26
78cf58b765 1. Replaced unused variables by _.
2. Typo fixes.
2019-01-22 22:27:01 +05:30
Gannon McGibbon
2e0ca9284a Revert ensure external redirects are explicitly allowed 2019-01-22 11:40:13 -05:00
Eileen M. Uchitelle
e26f0658da
Merge pull request #34997 from alkesh26/typo-fix-webserver
Replaced webserver with web server
2019-01-22 11:13:37 -05:00
alkesh26
97909ddcf2 Changed webserver to web server. 2019-01-22 21:11:03 +05:30
Yasuo Honda
3ea3cccc93 MySQL 8.0.14 adds ER_FK_INCOMPATIBLE_COLUMNS
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-14.html
> Error messages relating to creating and dropping foreign keys
> were improved to be more specific and informative. (Bug #28526309, Bug #92087)

https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html

> Error number: 3780; Symbol: ER_FK_INCOMPATIBLE_COLUMNS; SQLSTATE: HY000
> Message: Referencing column '%s' and referenced column '%s' in foreign key constraint '%s' are incompatible.
> ER_FK_INCOMPATIBLE_COLUMNS was added in 8.0.14.
2019-01-22 15:15:52 +00:00
Ryuta Kamizono
3f0c7c5580
Merge pull request #35006 from kddeisz/alias-case-nodes
Alias case nodes
2019-01-22 06:54:41 +09:00
Andrew White
4f62e757ca
Merge pull request #34990 from rails/fix-time-multiparameter-casting
Fix year value when casting a multiparameter time hash
2019-01-21 20:26:45 +00:00
Kevin Deisz
65cec345b4
Alias case nodes
When `Arel` was merged into `ActiveRecord` we lost the ability to alias case nodes. This adds it back.
2019-01-21 10:28:39 -05:00
Ryuta Kamizono
feb97dfabd
Merge pull request #35005 from bogdanvlviv/add-chanel-tests-to-rails-stats
Add Channel tests to `rails stats`
2019-01-21 20:36:29 +09:00
Ryuta Kamizono
98ebebde86
Merge pull request #35004 from bogdanvlviv/add-missing-entries-to-guides-changelog-file
Add missing entries to guides' changelog file [ci skip]
2019-01-21 20:36:09 +09:00