Commit Graph

89885 Commits

Author SHA1 Message Date
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
Jonathan Hefner
5cfff97ee7 Separate bundle lock from bundle install
When running `bundle install` for the `bin/rails app:template` command,
it is unnecessary and possibly even incorrect to also run
`bundle lock --add-platform=...` (because it could add a platform that
the user has intentionally removed).  Likewise, when running
`bundle install` to support a prerelease version of Rails, it is
unnecessary to run `bundle lock --add-platform=...`.

This commit extracts `bundle lock --add-platform=...` from `run_bundle`
into its own `add_bundler_platforms` generator task.
2023-11-27 11:52:08 -06:00
“Apoorv
d7b212626b add missing preposition in sentence 2023-11-27 22:01:07 +05:30
Eileen M. Uchitelle
1b67822fe4
Merge pull request #50170 from y-yagi/fix-db_system_change-to-trilogy
Don't add `default-mysql-client` when running `db:system:change` to Trilogy
2023-11-27 09:52:28 -05:00
Jonathan Hefner
f4b08457a4
Merge pull request #50177 from skipkayhil/hm-av-path-followup
Remove unused DeprecatedConstantAccessor include
2023-11-26 11:52:35 -06:00
Hartley McGuire
c1f3d6851e
Remove unused DeprecatedConstantAccessor include
deprecate_constant removed in 23344d4b8cc36bb8ae3db209e0365b70469118d2
2023-11-26 12:38:21 -05:00
yuuji.yaginuma
1e3e013fe8 Don't add default-mysql-client when running db:system:change to Trilogy
Trilogy doesn't depend on the libmariadb / libmysqlclient library
Ref: https://github.blog/2022-08-25-introducing-trilogy-a-new-database-adapter-for-ruby-on-rails/#should-you-use-trilogy
2023-11-26 13:34:28 +09:00
Jonathan Hefner
9f18c04697
Merge pull request #50169 from jonathanhefner/app_generator_test-fix-arm64
Fix generator tests on `arm64` platforms
2023-11-25 17:02:14 -06:00
Jonathan Hefner
0b02dce15f Fix generator tests on arm64 platforms
Follow-up to #47516 / #47492.

When running generator tests on `arm64` platforms, there is an extra
`lock --add-platform` command in `@bundle_commands` which causes
`assert_match %r"^exec rails ...", @bundle_commands[2]` to fail.

However, `run_generator_using_prerelease` isn't really concerned with
`lock --add-platform` commands; it is only concerned with the `install`
and `exec rails` commands, and the contents of the `Gemfile` when those
commands were executed.

Therefore, this commit removes `lock --add-platform` command-related
assertions from `run_generator_using_prerelease` and puts them into a
dedicated `test_generation_runs_bundle_lock_for_linux` test.  This
approach makes `run_generator_using_prerelease` less brittle.  This
change also fixes a technically incorrect assertion wherein the contents
of the `Gemfile` during the `lock --add-platform` command was checked
instead of the contents during the `exec rails` command.

Fixes #50168.

Co-authored-by: zzak <zzakscott@gmail.com>
2023-11-25 16:42:10 -06:00
Eugene Kenny
b744c8d0f5
Merge pull request #50164 from Aerdayne/do-not-overwrite-aj-logger
Do not overwrite AJ logger if it is supplied
2023-11-25 19:05:39 +00:00
Aerdayne
e03cc187f5 Do not overwrite AJ logger if it is supplied
Use conditional assignment within 'active_job.logger' initializer
2023-11-25 09:36:45 +01:00
Jonathan Hefner
354d68e8a6
Merge pull request #50153 from akhilgkrishnan/improve-documentation-for-excerpt
Improve documentation for excerpt text helper [skip ci]
2023-11-25 00:52:54 -06:00
Akhil G Krishnan
4c9d56a5c4 Improve documentation for excerpt text helper
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-11-25 11:16:28 +05:30
Jonathan Hefner
df2961b3d7 Put Ruby code in ERB tags [ci-skip]
This allows the code to be properly syntax-highlighted.
2023-11-24 17:57:17 -06:00
Jonathan Hefner
ed694bfe0a Remove unused variable in code example [ci-skip] 2023-11-24 17:52:33 -06:00
Jonathan Hefner
4bfa69a785 Revise TextHelper#concat code example [ci-skip]
This simplifies the code example, and avoids putting `%>` _inside_ an
ERB tag, which confuses the syntax highlighter.
2023-11-24 17:19:47 -06:00
Jonathan Hefner
ca5c27ed63 Format inline code [ci-skip] 2023-11-24 16:47:20 -06:00
Jonathan Hefner
1d604a459b Quote example output strings [ci-skip]
This portrays the return values more accurately and, in some cases,
fixes syntax highlighting when using the upcoming version of SDoc
(thanks to its heuristic for detecting Ruby code vs HTML code).
2023-11-24 16:22:57 -06:00
Jonathan Hefner
dc53bb9c27 Fix prose indentation [ci-skip]
Prior to this commit, the prose was formatted as a code example.
2023-11-24 16:13:03 -06:00
Jonathan Hefner
357a49d901
Merge pull request #50165 from jonathanhefner/follow-up-48290-selector
Fix submit button selector for `type`-less buttons
2023-11-24 15:49:37 -06:00
Jonathan Hefner
701e17b910 Fix submit button selector for type-less buttons
Follow-up to #48290.

The `:is(button, input)[type='submit']` selector does not match `button`
elements that omit the `type` attribute in favor relying on its default
value (which is `"submit"`).

Co-authored-by: Javan Makhmali <javan@javan.us>
2023-11-24 15:36:13 -06:00
Jonathan Hefner
209a1a18c4
Merge pull request #50161 from fatkodima/remove-duplicate-line
Remove duplicate  assignment from ActiveRecord's Rakefile
2023-11-24 14:30:53 -06:00
fatkodima
62c0e86404 Remove duplicate assignment from ActiveRecord's Rakefile 2023-11-24 19:39:59 +02:00
Gannon McGibbon
82e33e44bf
Merge pull request #49819 from gmcgibbon/integration_with_routes
Make with_routing test helper work for integration tests
2023-11-23 22:48:19 -06:00
Gannon McGibbon
d46d5ce610 Make with_routing test helper work for integration tests
Adds support for with_routing test helpers in ActionDispatch::IntegrationTest.
Previously, this helper didn't work in an integration context because
the rack app and integration session under test were not mutated.
Because controller tests are integration tests by default, we should
support test routes for these kinds of test cases as well.
2023-11-23 22:10:45 -06:00
Jonathan Hefner
04f29cb134 Format inline code [ci-skip] 2023-11-23 11:56:56 -06:00
Jonathan Hefner
f1d3acedb5 Include Preview#url in service_urls_expire_in list [ci-skip] 2023-11-23 11:52:39 -06:00
Jonathan Hefner
252cc95d12 Link to API docs [ci-skip] 2023-11-23 11:51:49 -06:00
Jonathan Hefner
06f0710061 Prevent autolink to method's own class [ci-skip]
Linking to a class from within its own documentation is more confusing
than helpful.
2023-11-23 11:46:16 -06:00
Jonathan Hefner
c209fb3a0b
Merge pull request #50149 from fatkodima/fix-flaky-test
Fix flaky db warnings test
2023-11-23 11:29:46 -06:00
fatkodima
5375a91470 Fix flaky db warnings test 2023-11-23 19:16:54 +02:00
Jonathan Hefner
54dc0b306a Link to api.rubyonrails.org instead of edgeapi [ci-skip] 2023-11-23 11:13:15 -06:00
Vipul A M
408faa2d42
Merge pull request #49743 from yoshixi/improve-action-mailbox-incineration-doc-1
Improve docs for the action-mail box incineration
2023-11-23 18:23:31 +05:30
Rafael Mendonça França
e7ea111e3b
Merge pull request #50144 from rails/rm-deprecations-1
Remove deprecations part 1
2023-11-22 19:38:25 -03:00
Rafael Mendonça França
03dae98092
Remove deprecated :exponentially_longer value for the :wait in retry_on 2023-11-22 22:13:59 +00:00