Commit Graph

84356 Commits

Author SHA1 Message Date
Jonathan Hefner
a24879d0cd
Merge pull request #45765 from sampatbadhe/patch-1
[ci skip] Add basic create_enum and drop_enum in CommandRecorder documentations
2022-08-05 12:10:15 -05:00
Eileen M. Uchitelle
28f5ec63fd
Merge pull request #45773 from eileencodes/only-setup-shared-pools-if-we-have-a-connection
Only setup shared pools if we have a connection
2022-08-05 13:07:52 -04:00
eileencodes
70f2ae001e
Only setup shared pools if we have a connection
Previously `setup_shared_connection_pool` was called anytime
`setup_fixtures` saw a future connection established. Sometimes those
connections are `nil` but we were setting up the shared pools before
determining that.

This change moves the `setup_shared_connection_pool` into the check for
if we have a connection. The tests that were dealing with these settings
were originally set to not use transacitons. But without this we can't
test the change here so I've updated that as well.

This is an alternate fix to #45769. I realized after opening the PR it
wasn't quite right to skip if we don't have a writing pool config,
because the question is how were we ending up with that anyway? Well the
answer was that we were calling the shared setup in the wrong place.

Fixes #45767
2022-08-05 12:40:52 -04:00
Jean Boussier
cc329dcd4a
Merge pull request #45762 from fatkodima/redis-delete-multi-fail-safe
Improve failure safety for `RedisCacheStore#delete_multi`
2022-08-05 13:57:00 +02:00
sampatbadhe
76d2185c60 [ci skip] adding basic create_enum and drop_enum in CommandRecorder documentations 2022-08-05 12:41:35 +05:30
Gannon McGibbon
9414a8b79f
Merge pull request #45701 from gmcgibbon/unused_routes_script
Add `routes --unused` option to detect extraneous routes.
2022-08-04 21:57:09 -05:00
Eileen M. Uchitelle
914ac17156
Merge pull request #45539 from geongeorge/feature/updates-guide-generation-epub
Feature/updates guide generation - EPUB
2022-08-04 15:03:56 -04:00
eileencodes
1623892582
Fix rubocop warning re unused argument 2022-08-04 14:50:11 -04:00
Geon George
56e96d9344 Replaces mobi guide with epub for docs because of discontinued support
Removes kindlerb logic

Adds template for epub generator

Renames the kindle dir to /epub

Adds epub module to generator and replaces kindle

Fixes mimetype

Creates basic epub book

Deletes old kindle module

Adds zip package

Updates rubyzip gem name

Removes now unused gepub gem

Adds the required container file for epubs

Fixes media type

Adds new epub generation logic

Removes all buttons from output html

Refactors and generates valid epub files

Removes frontmatter logic used for kindlegen

Filters out epub files in zip

Updates link to kindle doc on sidebar

Fixes rubocop issues

Adds deprecation warning for the old kindle task

Refactors and cleans up epub module

Cleans up epub code

Cleans up private internal method code style

Removes unnecessary imagemagick check
2022-08-05 00:18:20 +05:30
John Hawthorn
668d866b4b
Merge pull request #45756 from jhawthorn/avoid_to_s_in_erb
Avoid calling to_s at end of ERB
2022-08-04 11:16:36 -07:00
eileencodes
8d0da3d568
Refactor changes in #44931 and add a test
The PR #44931 fell off my radar a few months ago so I decided to add a
test myself to ensure this behavior change is tested. While doing that I
decided to refactor the changes from that PR to make the code a little
cleaner and easier to read.
2022-08-04 12:58:39 -04:00
Matt Larraz
8af4165a18
Improve #configured_migrate_path logic (#44931)
* Improve #configured_migrate_path logic

This solves two issues:

* `migrations_paths` is an Array, which here gets coerced to a string.
  This is fine if it's a single path, but otherwise the generated path
  is a concatenation of all the paths. Instead, pick the first one.

* If the `--database` flag is not passed in, fall back to the primary
  database's `migrations_paths` entry if available before falling back
  to the global default migrate path.

* migrations_paths can be a String, Array, or nil
2022-08-04 12:58:20 -04:00
Jonathan Hefner
246eed4d1b
Merge pull request #45737 from jonathanhefner/generalize-command-editor-helper-module
Remove remnants from `Editor` command helper module
2022-08-04 11:45:22 -05:00
Jonathan Hefner
239d6fa67d Use tap in conditionally-required password example [ci-skip] 2022-08-04 11:39:29 -05:00
fatkodima
b0061a30a0 Improve failure safety for RedisCacheStore#delete_multi
For redis cache store, running `Rails.cache.delete_multi(["foo", "bar"])`
will lead to an error when redis is down. Other existing cache store methods
already implement failure safety.
2022-08-04 18:53:10 +03:00
Eileen M. Uchitelle
0c9e4069f7
Merge pull request #45751 from adrianna-chang-shopify/ac-build-change-column-default-definition
Define #build_change_column_definition for MySQL and PG
2022-08-04 08:37:11 -04:00
Yasuo Honda
a0c1d33d2f
Merge pull request #45735 from ghiculescu/drop-enum
Add `drop_enum` command for Postgres
2022-08-04 09:26:46 +09:00
Alex Ghiculescu
bd0fdc8094 Add drop_enum command for Postgres 2022-08-03 18:50:43 -05:00
Yasuo Honda
c558d98b9d
Merge pull request #45674 from skipkayhil/add-changelog-linter
Add linter for CHANGELOG formatting [ci skip]
2022-08-04 08:45:28 +09:00
John Hawthorn
ee68644c28 Avoid calling to_s at end of ERB
With the recent changes to OutputBuffer, calling `to_s` is extremely
expensive if the buffer later is concatenated to (if the buffer never
changes it should be relatively inexpensive, as Ruby will share memory).
2022-08-03 16:24:12 -07:00
Jonathan Hefner
3f814695d7
Merge pull request #45754 from jonathanhefner/has_secure_password-conditional-password-example
Add example of conditionally requiring a password [ci-skip]
2022-08-03 16:17:45 -05:00
Jonathan Hefner
f53e3ad938 Add example of conditionally requiring a password [ci-skip]
This example addresses the use case brought up by #45487, which has been
reverted by #45753.
2022-08-03 16:14:08 -05:00
Jonathan Hefner
396776644d
Merge pull request #45753 from jonathanhefner/revert-45487
Revert "Allow passing hash on secure password validations"
2022-08-03 16:13:46 -05:00
Eileen M. Uchitelle
cf0873010a
Merge pull request #45743 from deepakmahakale/fix-test-case
Fix test case to check has_many_attached
2022-08-03 16:33:02 -04:00
Adrianna Chang
7455336638 Define #build_change_column_definition for MySQL and PG
Define APIs on the MySQL and PostgreSQL connection adapters for building
ChangeColumnDefaultDefinition objects. These provide information on what a
column default change would look like, when called with the same arguments as
would be passed to #change_column_default.
2022-08-03 16:27:25 -04:00
eileencodes
58e6f11878
Fix indentation
I messed up copying and pasting this. Rubocop failures caught
this in https://github.com/rails/rails/runs/7658743379?check_suite_focus=true
2022-08-03 14:46:11 -04:00
eileencodes
25f97a66bd
Add support for if_exists option when removing a check constraint
The `remove_check_constraint` method now accepts an `if_exists` option. If set
to true an error won't be raised if the check constraint doesn't exist.

This commit is a combination of PR #45726 and #45718 with some
additional changes to improve wording, testing, and implementation.

Usage:

```ruby
remove_check_constraint :products, name: "price_check", if_exists: true
```

Fixes #45634

Co-authored-by: Margaret Parsa <mparsa@actbluetech.com>
Co-authored-by: Aditya Bhutani <adi_bhutani16@yahoo.in>
2022-08-03 14:39:54 -04:00
Jean Boussier
1288289ed0
Merge pull request #45697 from adrianna-chang-shopify/ac-change-column-default-mysql
Use SET DEFAULT when changing a column default in MySQL
2022-08-03 20:23:08 +02:00
Jean Boussier
e1f566a6f4
Merge pull request #45734 from fatkodima/fix-columnless-enums
Raise when defining an enum not backed by a database column
2022-08-03 20:20:39 +02:00
Jonathan Hefner
6020f5331d Revert "Allow passing hash on secure password validations"
This reverts #45487 (8804128ad4cfea228ce97005072b029d0379d80f) until a
better API can be decided upon.
2022-08-03 11:52:30 -05:00
Adrianna Chang
b9b8852adc Use SET DEFAULT when changing a column default in MySQL
Aligns the SQL produced for changing a column default between MySQL and PostgreSQL.
MySQL is currently producing an <ALTER TABLE x CHANGE COLUMN y> query just to
change the default for a column, which is less efficient than using the SET DEFAULT syntax.

Additionally, extracts ChangeColumnDefaultDefinition and moves the SQL generation to the visitor class.
2022-08-03 11:16:06 -04:00
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
Deepak Mahakale
380cd17ae4 Fix attachment to has_many_attached 2022-08-03 15:09:49 +05:30
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
fatkodima
6c5fab0668 Raise when defining an enum not backed by a database column 2022-08-03 11:14:45 +03:00
Gannon McGibbon
5613b1240a Add routes --unused option to detect extraneous routes.
Routes take a long time to draw. Over time, a Rails app can become slow
to boot simply because of how many routes it has. This script can be
used to detect routes that are drawn, but aren't actually valid.
Removing routes this script detects can help speed up your app and
remove dead code.

Example:

```
> bin/rails routes --unused

Found 2 unused routes:

Prefix Verb URI Pattern    Controller#Action
   one GET  /one(.:format) action#one
   two GET  /two(.:format) action#two
```
2022-08-02 20:07:45 -05:00
Jonathan Hefner
943fca0de8 Remove remnants from Editor command helper module
The `Editor` command helper module was originally extracted from
`CredentialsCommand`, and still includes a help message mentioning
"credentials" and a `rescue` that is specific to encrypted files.

This commit removes those remnants, fully generalizing the `Editor`
module.  Additionally, this commit changes `SecretsCommand` to make use
of the `Editor` module.
2022-08-02 15:47:28 -05: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