Commit Graph

89923 Commits

Author SHA1 Message Date
eileencodes a8e07924d6 Fix dependency on JSON gem
Don't use `json` 2.7.0 release that has a regression.

Ref: https://github.com/flori/json/pull/554
2023-12-02 09:41:55 +01:00
Eileen M. Uchitelle b3b230c08e
Merge pull request #50231 from rails/revert-50205-ac-validate-migration-timestamps
Revert "Add config for validating migration timestamps"
2023-12-01 12:46:02 -05:00
Adrianna Chang 5a09d32ee6
Add regression test for copying migrations at timestamp boundary
We'd like to add validation to migration timestamps (attempted in 2854e37),
but this is problematic for copied migrations, e.g. engine migrations:
migrations are copied by adding one to every migration timestamp number,
which may produce an invalid timestamp.

This commit adds a regression test for this case, ensuring that if / when
we revisit migration timestamp validation, we handle the case for copied
migrations.
2023-12-01 12:17:08 -05:00
Adrianna Chang 2854e378c8
Revert "Add config for validating migration timestamps" 2023-12-01 11:58:53 -05:00
Eileen M. Uchitelle d6197c5efc
Merge pull request #50159 from skipkayhil/hm-deprecate-void-content
Deprecate content for void elements in TagBuilder
2023-12-01 09:34:30 -05:00
Eileen M. Uchitelle 831810c342
Merge pull request #50158 from fatkodima/fix-alias_attribute-sti
Fix defining `alias_attribute` for STI classes with abstract class in the inheritance chain
2023-12-01 09:31:25 -05:00
Eileen M. Uchitelle c60d064fd5
Merge pull request #50205 from rails/ac-validate-migration-timestamps
Add config for validating migration timestamps
2023-11-30 16:20:49 -05:00
Adrianna Chang 06575d1d75
Add `active_record.config.validate_migration_timestamps` option.
When set, validates that the timestamp prefix for a migration is in the form YYYYMMDDHHMMSS.
This is designed to prevent migration timestamps from being modified by hand.

It is turned off by default.
2023-11-30 16:04:06 -05:00
Jean Boussier da2dbbb292
Merge pull request #50157 from Earlopain/update-erb-trim-mode-docs
Update docs for `erb_trim_mode`
2023-11-30 19:15:43 +01:00
Jean Boussier 9b9468566a
Merge pull request #50188 from skipkayhil/hm-fix-ci-env
Fix test infra depending on CI=true
2023-11-30 19:13:02 +01:00
Jonathan Hefner 52affa8357 Fix example output for truncate helper [ci-skip]
The previous output was incorrect for the default truncation length, and
it included unescaped quotes.
2023-11-30 11:19:37 -06:00
Jonathan Hefner c05d8ed9cd Link methods for Rails::Engine [ci-skip] 2023-11-30 11:04:38 -06:00
Jonathan Hefner 47b2f68f52
Merge pull request #50178 from akhilgkrishnan/improve-documentation-for-truncate
Improve documentation for truncate text helper [skip ci]
2023-11-30 11:04:26 -06:00
Jean Boussier 3f4261638a
Merge pull request #50214 from zzak/gha/rails-new-docker/read-permissions-only
Ensure all GH Actions set to read-only contents
2023-11-30 17:41:50 +01:00
Hartley McGuire 91dedc0436
Fix Railties tests
These tests have never run in CI due to CI using a root user. This
commit keeps that behavior without using the skip so that we can enable
raise on skips.
2023-11-30 11:11:23 -05:00
Hartley McGuire e67b8d0dcc
Fix Active Support test warnings
The namespace ivar needs a definition check to not warn on Ruby 2.7
2023-11-30 11:11:22 -05:00
Hartley McGuire d64acfdcac
Fix Active Job skips
Similarly to Action Mailbox, these tests didn't pass because the skip
patch was included before ActiveSupport::TestCase was defined. Moving
the patch to the bottom of the file fixes the issue.

Once the skip patch was fixed, all of the skips were due to differences
in adapters which aren't really test skips as much as tests that should
not ever run against those adapters.
2023-11-30 11:11:22 -05:00
Hartley McGuire ec3d392e20
Fix skips in Action Pack
We can't run this test on Ruby 2.7 due to minitest being locked in the
Gemfile to an older version, so we should use that as a condition
instead of skipping if minitest doesn't have metadata.
2023-11-30 11:11:22 -05:00
Hartley McGuire b8433879bc
Fix Action Mailbox tests
ActiveSupport::TestCase isn't defined until later in the file, so the
skip override can be added at the end to ensure it exists (similar to
what the Action Pack tests do)
2023-11-30 11:11:22 -05:00
Hartley McGuire 8f6ee6487f
Fix skips in Active Support
The change to serialization mirrors the test just below it that also
uses a conditional for the assertion instead of a skip. The conditional
is necessary because memcached entries are not strings.

The class_serial test should not run on Ruby 3.2+ because class_serial
was replaced with Object Shapes. The class_serial value in RubyVM.stat
was removed in ruby/ruby@13bd617ea6
2023-11-30 11:11:22 -05:00
Hartley McGuire 3d002c1947
Fix test infra depending on CI=true
The CI env var was recently [changed][1] to be specific for the
application being tested instead of the framework tests. Because of
this, these lines which should have been true before are now false.

[1]: 1f0262aa2b
2023-11-30 11:11:19 -05:00
Jean Boussier c4fbb0fe89
Merge pull request #50150 from kmcphillips/ar-warn-legacy-adapters
Add more specific exceptions to warn when an adapter is using legacy adapter format
2023-11-30 15:40:21 +01:00
Kevin McPhillips 79fb41ddd9 Add deprecation and specific exceptions to warn when an adapter is using the legacy registration format in 7.2 2023-11-30 07:00:38 -05:00
Akhil G Krishnan c5add29025 Improve documentation for truncate text helper
Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>

Update actionview/lib/action_view/helpers/text_helper.rb

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-11-30 10:51:11 +05:30
zzak 32fa741087
Ensure all GH Actions set to read-only contents
Since a GH token is required for the action-discord notify action to fetch the commit message, otherwise it would make unauthenticated requests leading to rate limiting. This shouldn't impact the result of a workflow, but it's annoying.

The permissions for this token can vary based on the repository's settings. So to ensure we don't accidentally get a token with write access or something, we should use restrictive permissions per workflow, like the other workflows in this project.

See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
2023-11-30 06:02:52 +09:00
Jean Boussier 9c22f35440
Merge pull request #50140 from kmcphillips/ar-protocol-adapter
Add a `ActiveRecord.protocol_adapters` configuration to map `DATABASE_URL` protocols to adapters at an application level
2023-11-29 17:41:51 +01:00
Jonathan Hefner d22c6576b5
Merge pull request #50206 from orhantoy/document-errors-delegated-methods
Document delegated methods in `ActiveModel::Errors` [ci skip]
2023-11-29 10:12:37 -06:00
Vipul A M 87c42b2c4f
Merge pull request #50210 from jbk2/patch-1
Update form_helpers.md typo [ci skip]
2023-11-29 19:55:56 +05:30
jbk2 aa688c1d31
Update form_helpers.md
Correcting book[title] value typo on line 265 in order that it correctly reflects it's object value stated in line 248.
2023-11-29 14:08:49 +01:00
Orhan Toy d86b098a8a Document delegated methods in ActiveModel::Errors
Fixes #50187
2023-11-29 06:38:14 +01:00
Kevin McPhillips 0ccf300add Add an `ActiveRecord.protocol_adapters` configuration which maps the protocol in a `DATABASE_URL` to a database adapter. 2023-11-28 20:23:58 -05:00
Jean Boussier f8212aab87
Merge pull request #50208 from kmcphillips/inheritable-options-to_s
Add #to_s and pretty print for `ActiveSupport::InheritableOptions`
2023-11-29 00:04:29 +01:00
Kevin McPhillips 3d60490a9d Add #to_s and pretty print for ActiveSupport::InheritableOptions 2023-11-28 17:49:15 -05:00
Jean Boussier 4467b26a3e
Merge pull request #50145 from fatkodima/include-db-errors-in-connection-errors
Include exception causes into log messages
2023-11-28 20:45:13 +01:00
Jean Boussier 4cbdffe459
Merge pull request #50196 from fatkodima/ensure-enable-trigger-all
Ensure triggers are enabled when operation fails in PostgreSQL
2023-11-28 20:37:48 +01:00
Jonathan Hefner ea46a00a9f
Merge pull request #50192 from sbfaulkner/memory-store-unless-exist
Fix MemoryStore#write with unless_exist and namespace
2023-11-28 12:25:29 -06:00
S. Brent Faulkner 701377c6af
Fix MemoryStore#write with unless_exist and namespace
Updates `MemoryStore#write_entry` to pass a `nil` `namespace` to
`exist?`, which expects a _name_ rather than a an already "normalized"
_key_. This fixes a bug where `unless_exist` would overwrite any
existing entry if a `namespace` was used.
2023-11-28 13:08:55 -05:00
Jean Boussier 6093281e07
Merge pull request #50151 from kmcphillips/inheritable-options-hash-behaviour
Improve `ActiveSupport::InheritableOptions` hash-like behaviour
2023-11-28 18:24:26 +01:00
Kevin McPhillips 9b03df5626 Add some behaviour to ActiveSupport::InheritableOptions to make it quack more like a hash 2023-11-28 12:01:10 -05:00
Jean Boussier ed2bc92b82
Merge pull request #50162 from misdoro/50160_allow_object_id_column_name
Allow `object_id` as a column name for ActiveRecord
2023-11-28 15:08:24 +01:00
Mikhail Doronin 622c58c287 Allow `object_id` as a column name for ActiveRecord
Fixes #50160

The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`.
In that case two columns are created: `object_id` and `object_type`.

Update tests and comments to reference `__id__` instead of `object_id` for consistency.
2023-11-28 14:59:55 +01:00
Jean Boussier 6f394ffa91
Merge pull request #50197 from Shopify/testing-isolation-crash
ActiveSupport::Testing::Isolation: gracefully handle the subprocess dying
2023-11-28 14:52:03 +01:00
Jean Boussier b07362cffa ActiveSupport::Testing::Isolation: gracefully handle the subprocess dying
Right now if the subprocess exit uncleanly, it straight out bring the
parent down with it because it will fail to parse the (likely empty)
Marshal payload:

```
<internal:marshal>:34:in `load': marshal data too short (ArgumentError)
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:23:in `run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:1094:in `run_one_method'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:179:in `block in run'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:168:in `with_timestamps'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:178:in `run'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:229:in `block in run_from_queue'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/ci/queue/redis/worker.rb:55:in `poll'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:228:in `run_from_queue'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:213:in `__run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:162:in `run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:86:in `block in autorun'
 - XXXX::XXXXTest#test_xxxxx - /tmp/bundle/ruby/3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:52:in `write': closed stream (IOError)
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:52:in `puts'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:52:in `block (2 levels) in run_in_isolation'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:32:in `fork'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:32:in `block in run_in_isolation'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:28:in `pipe'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:28:in `run_in_isolation'
	from 3.3.0+0/bundler/gems/rails-488a7ce18880/activesupport/lib/active_support/testing/isolation.rb:19:in `run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:1094:in `run_one_method'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:179:in `block in run'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:168:in `with_timestamps'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:178:in `run'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:229:in `block in run_from_queue'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/ci/queue/redis/worker.rb:55:in `poll'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:228:in `run_from_queue'
	from 3.3.0+0/gems/ci-queue-0.38.0/lib/minitest/queue.rb:213:in `__run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:162:in `run'
	from 3.3.0+0/gems/minitest-5.20.0/lib/minitest.rb:86:in `block in autorun'
```

This breaks the Minitest contract that `run_one_method` shouldn't raise
ever, and return a `Minitest::Result`.

By properly checking the sub process status, we can turn this crash into
a test failure, allowing the original test process to go on.
2023-11-28 14:03:59 +01:00
fatkodima e28a609811 Ensure triggers are enabled when operation fails in PostgreSQL 2023-11-28 12:07:59 +02:00
fatkodima 139c5678aa
Merge pull request #50182 from apoorv1316/improve-getting-started-guide
Add missing preposition in sentence [ci skip]
2023-11-27 23:27:00 +02:00
Jonathan Hefner 3e7771ceb0
Merge pull request #50185 from jonathanhefner/app_generator-quiet-bundle-install
Use `--quiet` for `bundle install`
2023-11-27 14:22:52 -06:00
Jonathan Hefner 0c5edcc89e
Merge pull request #50184 from knodi/dirty_typo
Fix small string typo in docs for ActiveRecord Dirty [ci-skip]
2023-11-27 13:18:37 -06:00
Jonathan Hefner 11f418f17e Use `--quiet` for `bundle install`
When generating a new app, `bundle install` may be run multiple times
due to various application templates.  This can create a lot of noise
in the output log, particularly with Bundler <= 2.4.16, which displays
the full list of gems each time `bundle install` is run.

To reduce noise, this commit adds the `--quiet` flag to `bundle install`
commands.

__Before__

  ```console
  $ rails new my_cool_app --dev
        create
        create  Gemfile
           run  bundle install
  Resolving dependencies...
  Fetching gem metadata from https://rubygems.org/..........
  Bundle complete! 1 Gemfile dependency, 58 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
           run  rails new my_cool_app --dev
         exist
        remove  Gemfile
        remove  Gemfile.lock
        create  README.md
  ...
           run  bundle install
  Fetching gem metadata from https://rubygems.org/..........
  Resolving dependencies...
  Bundle complete! 12 Gemfile dependencies, 78 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
  ...
         rails  importmap:install
         apply  importmap-rails-1.2.3/lib/install/install.rb
  ...
           run  bundle install
  Bundle complete! 12 Gemfile dependencies, 78 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.

         rails  turbo:install stimulus:install
         apply  turbo-rails-1.5.0/lib/install/turbo_with_importmap.rb
  ...
           run  bundle install
  Bundle complete! 12 Gemfile dependencies, 78 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
         apply  turbo-rails-1.5.0/lib/install/turbo_needs_redis.rb
    Enable redis in bundle
          gsub    Gemfile
           run    bundle install
  Fetching gem metadata from https://rubygems.org/..........
  Resolving dependencies...
  Bundle complete! 13 Gemfile dependencies, 80 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
    Switch development cable to use redis
          gsub    config/cable.yml
           run  bundle install
  Bundle complete! 13 Gemfile dependencies, 80 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
         apply  stimulus-rails-1.3.0/lib/install/stimulus_with_importmap.rb
  ...
           run  bundle install
  Bundle complete! 13 Gemfile dependencies, 80 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
  ```

__After__

  ```console
  $ rails new my_cool_app --dev
        create
        create  Gemfile
           run  bundle install --quiet
           run  rails new my_cool_app --dev
         exist
        remove  Gemfile
        remove  Gemfile.lock
        create  README.md
  ...
           run  bundle install --quiet
  ...
         rails  importmap:install
         apply  importmap-rails-1.2.3/lib/install/install.rb
  ...
           run  bundle install --quiet
         rails  turbo:install stimulus:install
         apply  turbo-rails-1.5.0/lib/install/turbo_with_importmap.rb
  ...
           run  bundle install --quiet
         apply  turbo-rails-1.5.0/lib/install/turbo_needs_redis.rb
    Enable redis in bundle
          gsub    Gemfile
           run    bundle install --quiet
    Switch development cable to use redis
          gsub    config/cable.yml
           run  bundle install --quiet
         apply  stimulus-rails-1.3.0/lib/install/stimulus_with_importmap.rb
  ...
           run  bundle install --quiet
  ```

Note that `bundle install` still displays any errors when using the
`--quiet` flag:

  ```console
  $ bundle install
  Could not find gem 'rails (= 9001.0)' in rubygems repository https://rubygems.org/ or installed locally.

  The source contains the following gems matching 'rails':
    * rails-0.8.0
    ...
    * rails-7.1.2
  ```
2023-11-27 13:13:02 -06:00
Colin Knox 55ab5d51fb [ci skip] Fix small string typo in docs for ActiveRecord::AttributeMethods::Dirty 2023-11-27 12:53:26 -06:00
Jonathan Hefner e85e574cd6
Merge pull request #50183 from jonathanhefner/app_generator-separate-lock-from-install
Separate `bundle lock` from `bundle install`
2023-11-27 12:32:03 -06:00