Commit Graph

84320 Commits

Author SHA1 Message Date
Jean Boussier
d0e26bf891
Merge pull request #45748 from Shopify/action-view-refactor-output-buffer-test-2
Refactor Action View tests to stop re-assigning @output_buffer
2022-08-03 15:18:13 +02:00
Petrik de Heus
df55109cbe
Merge pull request #45747 from Nittarab/main [ci-skip]
Add missing Versioning header in maintenance policy guide
2022-08-03 15:05:23 +02:00
Jean Boussier
4b67dffc8d Refactor Action View tests to stop re-assigning @output_buffer
Followup on https://github.com/rails/rails/pull/45745

`@rendered` is a much better variable for this kind of intermediate
result as that's what is used by DOM assertions.
2022-08-03 15:00:58 +02:00
Jean Boussier
206b2b8319
Merge pull request #45731 from Shopify/action-view-buffer-slice
Add OutputBuffer#raw and #capture to reduce the need to swap the buffer
2022-08-03 14:57:34 +02:00
Jean Boussier
a5862af315
Merge pull request #45744 from fatkodima/mysql-change-column-collation
Preserve collation when changing column in MySQL
2022-08-03 14:53:48 +02:00
Jean Boussier
9ac8e0c9ae
Merge pull request #45677 from Shopify/action-view-erb-freeze
Avoid explictly freezing literals strings when possible
2022-08-03 13:47:09 +02:00
Patrick Barattin
8821574186 Add missing Versioning header in maintenance policy guide 2022-08-03 13:32:59 +02:00
Jean Boussier
fc0db35fb1 Add OutputBuffer#raw and #capture to reduce the need to swap the buffer
Right now many helpers have to deal with two modes of operation to
capture view output.

The main one is to swap the `@output_buffer` variable with a new buffer.
But since some view implementations such as `builder` keep a reference
on the buffer they were initialized with, this doesn't always work.

So additionally, the various capturing helpers also record the buffer
length prior to executing the block, and then `slice!` the buffer back
to its original size.

This is wasteful and make the code rather unclear.

Now that `OutputBuffer` is a delegator, I'd like to refactor all this
so that:

  - @output_buffer is no longer re-assigned
  - A single OutputBuffer instance is used for the entire response rendering
  - Instead capturing is done through `OutputBuffer#capture`

Once the above is achieved, it should allow us to enabled Erubi's
`:chain_appends` option and get some reduced template size and some
performance.

Not re-assigning `@output_buffer` will also allow template to access
the local variable instead of an instance variable, which is cheaper.

But more importantly, that should make the code easier to understand
and easier to be compatible with `StreamingBuffer`.
2022-08-03 12:56:34 +02:00
Jean Boussier
ee754bac2a
Merge pull request #45745 from Shopify/refactor-form-helper-test
Refactor form_for tests to stop re-assigning @output_buffer
2022-08-03 12:56:05 +02:00
Jean Boussier
577bb114b5 Refactor form_for tests to stop re-assigning @output_buffer
It's really not what it's meant for. `@renderer` is a better use
for this as it's the variable used by the DOM testing helpers.

Ref: https://github.com/rails/rails/pull/45731
2022-08-03 12:33:08 +02:00
fatkodima
3a0d0f4bd8 Preserve collaction when changing column in MySQL 2022-08-03 13:09:25 +03:00
Jean Boussier
476aeda794 Avoid explictly freezing literals strings when possible
Ref: https://github.com/jeremyevans/erubi/pull/33

If the template is compiled with `frozen_string_literals: true`,
then explicitly freezing string is slightly wasteful as it will be
compiled as `opt_str_freeze` instead of a simple `putobject`.

The former has to check wether `String#freeze` was redefined every
time, which while fast is useless extra work.
2022-08-03 11:15:36 +02:00
Jonathan Hefner
887dc9af6c
Merge pull request #45716 from jonathanhefner/command-executable-helper
Consistently format commands in help messages
2022-08-02 15:42:38 -05:00
Jonathan Hefner
3661d0d8a4
Merge pull request #45675 from hirotaka/fix_date_select_with_locale
Fixes Date Helper with locale
2022-08-02 11:14:25 -05:00
Jean Boussier
408d061a80
Merge pull request #45720 from Shopify/find-or-create-or-find-by
find_or_create_by: handle race condition by finding again
2022-08-02 15:11:20 +02:00
Jean Boussier
562a038eae
Merge pull request #45732 from fatkodima/redis-cache-store-flaky-tests
Fix flaky tests for RedisCacheStore
2022-08-02 15:09:12 +02:00
fatkodima
813b58d8f9 Fix flaky tests for RedisCacheStore 2022-08-02 15:39:06 +03:00
Jean Boussier
090f78e6ed
Merge pull request #45729 from fatkodima/insert_all-empty-attributes
Accept empty list of attributes for `insert_all`, `insert_all!` and `upsert_all`
2022-08-02 13:02:56 +02:00
fatkodima
cd3508607d Accept empty list of attributes for insert_all, insert_all! and upsert_all 2022-08-02 13:21:31 +03:00
Hirotaka Mizutani
60ca482cf0 Fixes Date Helper with locale
The i18n gem (https://github.com/ruby-i18n/i18n) has been modified to `freeze`
locale setting values. This could cause the Date helper to not work correctly
under certain conditions. `dup` the configuration values fixes that problem.
2022-08-02 18:32:13 +09:00
Jean Boussier
023a3eb3c0 find_or_create_by: handle race condition by finding again
Using `create_or_find_by` in codepaths where most of the time
the record already exist is wasteful on several accounts.

`create_or_find_by` should be the method to use when most of the
time the record doesn't already exist, not a race condition safe
version of `find_or_create_by`.

To make `find_or_create_by` race-condition free, we can search
the record again if the creation failed because of an unicity
constraint.

Co-Authored-By: Alex Kitchens <alexcameron98@gmail.com>
2022-08-02 09:58:26 +02:00
Jean Boussier
195f20dca8
Merge pull request #45728 from fatkodima/null_store-repeated-reads
Fix `Cache::NullStore` with local caching for repeated reads
2022-08-02 09:37:13 +02:00
Jean Boussier
91b51e31cd
Merge pull request #45727 from joelhawksley/rename-strict-locals
Rename 'Explicit Locals` to `Strict Locals`
2022-08-02 08:35:24 +02:00
fatkodima
6dad6e7604 Fix Cache::NullStore with local caching for repeated reads 2022-08-02 03:18:35 +03:00
Joel Hawksley
b7908a62f9 Rename 'Explicit Locals to Strict Locals`
Per https://github.com/rails/rails/pull/45602#discussion_r934981516
2022-08-01 17:23:47 -06:00
Jean Boussier
f9f2644b61
Merge pull request #45602 from joelhawksley/strict-templates
Allow templates to define which locals they accept
2022-08-01 23:48:47 +02:00
Joel Hawksley
bbe7d19e11 Allow templates to define which locals they accept. 2022-08-01 15:42:02 -06:00
Jean Boussier
765caa44a7
Merge pull request #45714 from simi/proper-verbose-cleanup
Store previous verbose setting before it can fail in tests.
2022-08-01 19:29:17 +02:00
Jean Boussier
e7bc2cb16f
Merge pull request #45717 from stevecrozz/tagged_logging_formatter_method_persistence
TaggedLogging preserves formatter methods
2022-08-01 19:27:12 +02:00
Jean Boussier
c6cbf8fc56
Merge pull request #45722 from Shopify/encrypted-queries-options-mutation
Refactor ExtendedDeterministicQueries to not mutate the arguments
2022-08-01 16:50:16 +02:00
Jean Boussier
26aafc3c8c
Merge pull request #45711 from fatkodima/redis-cache-store-optimize-incr-decr
Optimize increment and decrement for `RedisCacheStore`
2022-08-01 16:35:38 +02:00
fatkodima
e35eb0f779 Optimize increment and decrement for RedisCacheStore 2022-08-01 17:23:53 +03:00
Jean Boussier
7de5053923 Refactor ExtendedDeterministicQueries to not mutate the arguments
Ref: https://github.com/rails/rails/pull/41659

Mutating the attributes hash requires to workaround the mutation
in `find_or_create_by` etc.

One extra Hash dup is not big deal.
2022-08-01 16:21:33 +02:00
Jean Boussier
80ec9e1610
Merge pull request #45721 from Shopify/cleanup-redis-store
RedisCacheStore: various cleanups
2022-08-01 14:46:20 +02:00
Jean Boussier
f9fce850da RedisCacheStore: get rid of the Redis::Distributed check
Instead we lazily check for pipelining support. `Redis::Distributed`
immediately raise when `pipelined` is called.

Also instead of using `mset` we use a pipelined. The performance
difference is extremly minimal, but it allows us to re-use `write_entry`
hence more shared code and we can speed up `write_multi` with an
expiry.
2022-08-01 14:33:29 +02:00
Jean Boussier
5aa9d16969 RedisCacheStore: avoid monkey patching redis
ConnectionPool#with is aliased as #then which is equivalent
to Object#then since Ruby 2.5. So if we use that we don't need
to monkey patch anything.
2022-08-01 12:19:14 +02:00
Jean Boussier
c617b8f8fd RedisCacheStore: remove unused mget_capable? flag
Ever since its introduction it was never set to false.
2022-08-01 12:00:12 +02:00
Jean Boussier
73d2cc86d8
Merge pull request #45664 from sambostock/teach-active-job-to-set-configs-on-itself
Teach `ActiveJob` to set configs on itself
2022-08-01 10:51:19 +02:00
Jonathan Hefner
6b042adb87
Merge pull request #45708 from jonathanhefner/encrypted-config-tmp-path-with-spaces
Support spaces in file path when invoking editor
2022-07-31 15:58:05 -05:00
Stephen Crosby
77209cc017
TaggedLogging preserves formatter methods
TaggedLogging preserves any methods that exist on the formatter's
singleton class.
2022-07-31 13:46:07 -07:00
Jonathan Hefner
7752be54cd Consistently format commands in help messages
This commit enhances the `Rails::Command::Base.executable` method to
integrate a new `bin` class attribute and optional `subcommand` arg.
So, for example, `CredentialsCommand.executable(:edit)` will now return
"bin/rails credentials:edit".

Additionally, this commit replaces occurrences of "bin/rails COMMAND",
"rails COMMAND", and "COMMAND" in help messages with calls to
`executable`, for improved consistency.
2022-07-31 15:06:31 -05:00
Yasuo Honda
0098f55846
Merge pull request #45715 from simi/postgresql-test-collation
Set collation for postgresql test DBs.
2022-08-01 00:05:23 +09:00
Josef Šimánek
4f4dd2ef02 Set collation for postgresql test DBs. 2022-07-31 16:23:00 +02:00
Josef Šimánek
bfdf158a15 Store previous verbose setting before it can fail in tests.
- thanks to hoisting it can be wrongly set to nil instead of previous value
2022-07-31 14:54:43 +02:00
Yasuo Honda
a01d6f8b08
Merge pull request #45707 from fatkodima/create_enum-schemas
Support explicit schemas in PostgreSQL's `create_enum`
2022-07-31 12:08:45 +09:00
fatkodima
438862b5d3 Support explicit schemas in PostgreSQL's create_enum 2022-07-31 00:12:07 +03:00
Stan Lo
fdc988bdd1
Remove resolved debugger caveat (#45704) 2022-07-31 02:27:28 +05:30
Jonathan Hefner
75d4e878ec Support spaces in file path when invoking editor
In #44910, the `credentials:edit` command was fixed to support spaces in
the temporary file path on Windows.  This commit applies the same fix to
the `encrypted:edit` command.
2022-07-30 15:47:54 -05:00
Jonathan Hefner
96236b5e52
Merge pull request #45700 from jonathanhefner/encrypted-config-aborted-edit-confirmation-message
Prevent "saved" message when edit command aborted
2022-07-30 15:44:11 -05:00
Sam Bostock
b4fffc3c68
Teach ActiveJob to set configs on itself
Previously configs of the form `config.active_job.X` were only forwarded to
`ActiveJob::Base`. This teaches Active Job to set them on `ActiveJob` directly
instead, if the setter exists.

For consistency, this more or less mirrors the way that Active Record does it.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Sam Bostock <sam.bostock@shopify.com>

---

Fix use_big_decimal_serializer Rails 7.1 default

This config should be enabled for new Rails 7.1 apps, or apps that have updated
their config to `load_defaults 7.1`, not disabled.

This also clarifies the config accessor comment.

---

Add contributor documentation comment to load_defaults

The process for introducing a change in behavior in Rails can be confusing to
new contributors, so a comment is added roughly explaining how to do so, and
what belongs in `load_defaults` and `new_framework_defaults`.

This comment is aimed at contributors, not consumers, so it is added within the
method, rather than above it.
2022-07-30 11:11:15 -04:00