Commit Graph

83639 Commits

Author SHA1 Message Date
Jean Boussier 4113ec933e
Merge pull request #45116 from ghiculescu/helper_method_backtrace 2022-05-17 20:20:27 -07:00
Alex Ghiculescu 203032dd76 Fix incorrect line number if a `helper_method` errors
Currently if you use `helper_method` to define a method, and inside that method you get an error, the backtrace is off by one line.

This PR fixes that so that the backtrace now points to the line where you called `helper_method`.
2022-05-17 15:41:28 -05:00
Jean Boussier 83c9bebf80
Merge pull request #45068 from intercom/ab/mem-cache-store-incr-decr-initial-option
Add initial value support to ActiveSupport::Cache #increment and #decrement calls
2022-05-17 13:06:43 -07:00
Andrej Blagojević f48bf3975f Add initial value support to MemCacheStore #increment and #decrement 2022-05-17 18:32:52 +00:00
Jeremy Daer fe8d41eda1
Merge pull request #42981 from ghiculescu/as-eager-more-methods-3
Active Storage eager loading: support more methods
2022-05-16 12:42:23 -07:00
Jeremy Daer 712ecf7749
Merge pull request #45072 from palkan/feat/ac-remote-disconnect-notice
Send disconnect message during remote disconnect
2022-05-16 12:41:39 -07:00
Jeremy Daer df88a42e5f Merge branch 'main' into feat/ac-remote-disconnect-notice
* main: (21 commits)
  feat: action cable connection callbacks
  fix: action cable stream_test errors
  Adds test coverage for #attach method behaviour in activestorage
  Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
  Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services
  Fixes development Action Mailbox new mail form
  Squash commits
  Include the unexpected class in InvalidParameterKey message
  Support unbounded time ranges for PostgreSQL
  Fix CHANGELOG alignment [ci-skip]
  Add ability to ignore tables by regexp for SQL schema dumps
  Improve `rails s` error message when no server could be found.
  Fix MySQL warning when creating Active Record's test databases
  Add `--js` and --skip-javascript` options to `rails new`
  Fix parsing operator classes for index columns in PostgreSQL
  Fix rails test command to handle leading dot slash
  Document that url_for can take classes
  Don't change the encoding of frozen parameters
  Update working_with_javascript_in_rails.md
  Avoid query from calculations on contradictory relation
  ...
2022-05-16 12:40:31 -07:00
Vladimir Dementyev 5d6c1f64ea feat: action cable connection callbacks 2022-05-16 12:24:38 -07:00
Vladimir Dementyev c5423e9a9c fix: action cable stream_test errors 2022-05-16 12:22:09 -07:00
Ghouse Mohamed 1a6e13d986 Adds test coverage for #attach method behaviour in activestorage 2022-05-16 12:21:19 -07:00
Jeremy Daer f24500b3ab Merge branch 'main' into as-eager-more-methods-3
* main: (746 commits)
  Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
  Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services
  Fixes development Action Mailbox new mail form
  Squash commits
  Include the unexpected class in InvalidParameterKey message
  Support unbounded time ranges for PostgreSQL
  Fix CHANGELOG alignment [ci-skip]
  Add ability to ignore tables by regexp for SQL schema dumps
  Improve `rails s` error message when no server could be found.
  Fix MySQL warning when creating Active Record's test databases
  Add `--js` and --skip-javascript` options to `rails new`
  Fix parsing operator classes for index columns in PostgreSQL
  Fix rails test command to handle leading dot slash
  Document that url_for can take classes
  Don't change the encoding of frozen parameters
  Update working_with_javascript_in_rails.md
  Avoid query from calculations on contradictory relation
  Fix MemoryStore#write(name, val, unless_exist: true) with expired entry
  Provide pattern matching for ActiveModel
  Stop autoclosing of PRs
  ...
2022-05-16 12:18:30 -07:00
Jean Boussier 8865834cbd
Merge pull request #45109 from yahonda/diag45108
Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
2022-05-16 09:48:32 -07:00
Jean Boussier af2447629a
Merge pull request #45102 from feliperaul/fix_activestorage_proxy_downloads_files_larger_5mb
Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storages
2022-05-16 09:47:40 -07:00
Yasuo Honda e4bb97db0a Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
This commit addresses this failure.

```ruby
$ cd activerecord
$ ARCONN=postgresql bin/test test/cases/adapters/postgresql/composite_test.rb test/cases/query_cache_test.rb  -n "/^(?:PostgresqlCompositeWithCustomOIDTest#(?:test_column)|QueryCacheTest#(?:test_query_cache_does_not_allow_sql_key_mutation))$/" --seed 50299
Using postgresql
Run options: -n "/^(?:PostgresqlCompositeWithCustomOIDTest#(?:test_column)|QueryCacheTest#(?:test_query_cache_does_not_allow_sql_key_mutation))$/" --seed 50299

.F

Failure:
QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation [/home/yahonda/src/github.com/rails/rails/activerecord/test/cases/query_cache_test.rb:395]:
0 instead of 1 queries were executed..
Expected: 1
  Actual: 0

bin/test test/cases/query_cache_test.rb:389

Finished in 0.096603s, 20.7033 runs/s, 72.4617 assertions/s.
2 runs, 7 assertions, 1 failures, 0 errors, 0 skips
$
```

Fix #45108

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2022-05-17 01:04:28 +09:00
Felipe e4eab9892f Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services 2022-05-16 08:09:12 -03:00
Jean Boussier a8f3f0df0a
Merge pull request #45099 from jonathanhefner/postgres-unbounded-time-ranges
Support unbounded time ranges for PostgreSQL
2022-05-15 17:08:29 -04:00
Jean Boussier 85cd509084
Merge pull request #45103 from dorianmariefr/issue-45088-error-when-submitting-action-mailbox-conductor-form
Fixes development Action Mailbox new mail form
2022-05-15 17:07:06 -04:00
Dorian Marié ebf916af2e Fixes development Action Mailbox new mail form
I wanted to add a test for sending an attachment that is an empty string
and a file but got this error:

NoMethodError: undefined method `original_filename' for "#<Rack::Test::UploadedFile:0x000000010840d388>":String

Related: #44702

Fixes #45088

-----

Started POST "/rails/conductor/action_mailbox/inbound_emails" for ::1 at 2022-05-14 07:34:19 +0200
Processing by Rails::Conductor::ActionMailbox::InboundEmailsController#create as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "mail"=>{"from"=>"", "to"=>"", "cc"=>"", "bcc"=>"", "x_original_to"=>"", "in_reply_to"=>"", "subject"=>"", "body"=>"", "attachments"=>[""]}, "commit"=>"Deliver inbound email"}
Completed 500 Internal Server Error in 7ms (ActiveRecord: 0.0ms | Allocations: 2600)

NoMethodError (undefined method `original_filename' for "":String

            mail.add_file(filename: attachment.original_filename, content: attachment.read)
                                              ^^^^^^^^^^^^^^^^^^):

actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:26:in `block (2 levels) in new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `each'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `block in new_mail'
<internal:kernel>:90:in `tap'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:23:in `new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:17:in `create'

Co-Authored-By: Patrício dos Santos <hello@psantos.dev>
2022-05-15 22:59:48 +02:00
Jean Boussier 06610c49fb
Merge pull request #42909 from joeyparis/main
Add `skip_nil:` support to `RedisCacheStore`
2022-05-15 09:09:11 -04:00
Joey Paris 98244c1d4b Squash commits 2022-05-15 11:45:22 +01:00
Jean Boussier e2dbb942d9 Include the unexpected class in InvalidParameterKey message
It is best practice to include the unexpected value in logs
and error message as it can often make it much easier to understand
where the error come from.
2022-05-14 17:03:49 -04:00
Jonathan Hefner 4479d81134 Support unbounded time ranges for PostgreSQL
Ruby raises an `ArgumentError` when mixing `Time` and `Float` values in
a `Range`, such as `Time.now..Float::INFINITY`.  Therefore, when
deserializing time ranges, we must use a beginless range to represent a
range with no lower bound, or an endless range to represent a range with
no upper bound.

Fixes #39833.
Closes #45082.

Co-authored-by: fatkodima <fatkodima123@gmail.com>
2022-05-14 15:52:50 -05:00
Petrik de Heus 203ddf688a
Merge pull request #45097 from p8/activerecord/fix-changelog-whitespace
Fix CHANGELOG alignment [ci-skip]
2022-05-14 19:43:50 +02:00
Petrik b4b4edd85e Fix CHANGELOG alignment [ci-skip] 2022-05-14 19:41:10 +02:00
Jean Boussier 445d400a65
Merge pull request #45089 from fatkodima/fix-opclass-parsing-postgres
Fix parsing operator classes for index columns in PostgreSQL
2022-05-14 11:28:46 -04:00
Jean Boussier 0977e9eccd
Merge pull request #45091 from fatkodima/sql-ignore_tables-regexp
Add ability to ignore tables by regexp for SQL schema dumps
2022-05-14 10:48:47 -04:00
fatkodima a3dc851159 Add ability to ignore tables by regexp for SQL schema dumps 2022-05-14 17:21:28 +03:00
Jean Boussier 7d3fd6edc6
Merge pull request #45095 from Shopify/missing-server
Improve `rails s` error message when no server could be found.
2022-05-14 09:50:55 -04:00
Jean Boussier 2a3a6e5efc Improve `rails s` error message when no server could be found.
Fix: https://github.com/rails/rails/issues/45092

Up until 3.0, `rails s` would always at least find webrick. But since it
was removed in Ruby 3.0, it's now possible to end up with no available server
at all.

In such case we should recommend adding puma to the Gemfile.
2022-05-14 09:43:34 -04:00
Jean Boussier 87c97b6d5e
Merge pull request #45078 from Shopify/master-default-params-encoding
Don't change the encoding of frozen parameters
2022-05-14 08:48:22 -04:00
Jean Boussier 265b3a1eff
Merge pull request #45094 from dorianmariefr/fix-mysql-warning
Fix MySQL warning when creating Active Record's test databases
2022-05-14 08:34:39 -04:00
Dorian Marié a0dcd25f5b Fix MySQL warning when creating Active Record's test databases
An empty password argument was passed by default and would produce
warnings when doing `rake db:create` in `activerecord/`

    mysql: [Warning] Using a password on the command line interface can be insecure.
    mysql: [Warning] Using a password on the command line interface can be insecure.

By default the password is empty so not passing the password argument
prevents the warning from appearing.

Tested on "mysql  Ver 8.0.29 for macos12.2 on arm64 (Homebrew)"
2022-05-14 08:59:25 +02:00
Jean Boussier a4fb045e0d
Merge pull request #43754 from dorianmariefr/js-alias
add `--js` alias to `--javascript` and `--skip-js` alias to `--skip-javscript`
2022-05-13 17:11:44 -04:00
Dorian Marié 7b244c99f6 Add `--js` and --skip-javascript` options to `rails new`
`--js` alias to `rails new --javascript ...`

Same as `-j`, e.g. `rails new --js esbuild ...`

`--skip-js` alias to `rails new --skip-javascript ...`

Same as `-J`, e.g. `rails new --skip-js ...`
2022-05-13 22:36:36 +02:00
fatkodima a8e292be47 Fix parsing operator classes for index columns in PostgreSQL 2022-05-13 20:16:16 +03:00
Jean Boussier b5630e232b
Merge pull request #45085 from shouichi/test-with-leading-dot-slash
Fix rails test command to handle leading dot slash
2022-05-13 07:02:44 -04:00
Shouichi Kamiya 44b56fba20 Fix rails test command to handle leading dot slash
Co-authored-by: oljfte <oljfte@gmail.com>
2022-05-13 19:59:10 +09:00
Jonathan Hefner 25b1267071
Merge pull request #45083 from shouichi/doc-url-for-can-take-classes
Document that url_for can take classes [ci-skip]
2022-05-12 20:29:00 -05:00
Shouichi Kamiya aaa9bcc62e Document that url_for can take classes
Co-authored-by: oljfte <oljfte@gmail.com>
2022-05-13 10:09:17 +09:00
Jean Boussier ee2ab9866a Don't change the encoding of frozen parameters
Fix: https://github.com/rails/rails/issues/44923

The fix may seem very ad hoc, but this methods assumes all params
come from Rack, hence are mutable. So checking for frozen is a decent
proxy for ignoring the router defaults.
2022-05-12 09:21:08 -04:00
Petrik de Heus d966095055
Merge pull request #45075 from Cremesis/patch-1
Update working_with_javascript_in_rails.md - missing "turbo-" form attribute
2022-05-12 12:40:18 +02:00
Cremesis 0a7749818e
Update working_with_javascript_in_rails.md 2022-05-12 10:12:22 +02:00
Jean Boussier 8ec7455385
Merge pull request #45073 from asavageiv/alan/memory-store-write-expired-test
Fix MemoryStore#write(name, val, unless_exist: true) with expired entry
2022-05-11 20:25:08 -04:00
John Hawthorn 3ab2cd6fa1
Merge pull request #45030 from luanzeba/calculate_on_contradiction
Avoid query from calculations on contradictory relation
2022-05-11 15:38:01 -07:00
Luan Vieira a1f76dd712 Avoid query from calculations on contradictory relation
Previously calculations would make a query even when passed a
contradiction, like `User.where(id: []).count`. This commit optimzes
that to avoid an unnecessary query to the database.

Co-authored-by: John Hawthorn <jhawthorn@github.com>
Co-authored-by: Daniel Colson <composerinteralia@github.com>
2022-05-11 15:27:01 -07:00
Alan Savage ad7b40c4f7 Fix MemoryStore#write(name, val, unless_exist: true) with expired entry 2022-05-11 11:54:03 -07:00
Vladimir Dementyev 2d0f9c5844 Send disconnect message during remote disconnect
Send {type: :disconnect} message to a client before closing the connection when initiated by server.remote_connections.where(...).disconnect
2022-05-11 13:59:23 -04:00
Petrik de Heus 4b5410a6aa
Merge pull request #44897 from claasz/patch-1
Clarified requirements for keys in nested structures
2022-05-11 19:49:03 +02:00
Gannon McGibbon 0cca979fa6
Merge pull request #45035 from kddnewton/pattern-matching
Provide pattern matching for ActiveModel
2022-05-11 12:50:21 -04:00
Kevin Newton 7e499b25ac
Provide pattern matching for ActiveModel
It would be nice to be able to pattern match against ActiveModel (and
transitively ActiveRecord). If you want to check multiple attributes
with conditions, it's nice to be able use the pattern matching syntax.

For example:

```ruby
case Current.user
in { superuser: true }
  "Thanks for logging in. You are a superuser."
in { admin: true, name: }
  "Thanks for logging in, admin #{name}!"
in { name: }
  "Welcome, #{name}!"
end
```
2022-05-11 12:47:59 -04:00