Commit Graph

15099 Commits

Author SHA1 Message Date
Alex Ghiculescu
957a3e5e55 Add BACKTRACE env variable to turn off backtrace for normal running, not just tests 2024-01-04 07:25:12 +10:00
Rafael Mendonça França
0d940e376c
Don't run rubocop after generation on Ruby 3.4+ 2024-01-03 21:16:19 +00:00
Rafael Mendonça França
c11ad35783
Remove apply_rubocop_autocorrect_after_generate! from development.rb in build_app
This will fix tests for versions of Ruby that Rubocop doesn't
have a parser for.
2024-01-03 21:16:18 +00:00
Sean Doyle
9a58f7eccd Raise ArgumentError when reading from config.x with arguments
The flexibility provided by `config.x` supports arbitrarily defining new
configuration objects on-the-fly. Each new intermediate configuration
object is constructed during chaining from its ancestor through a method
invocation made without arguments.

Conversely, writing to leaf configuration values occurs when the invoked
method's name ends with `=`, and the new configuration value is assigned
to whatever that method's arguments are.

There are no cases when reading from a `config.x` value or building the
intermediate values involves arguments.

Prior to this commit, a read invoked with a method arguments would
ignore those arguments. While this is robust and error-free, it's
possible to obscure misuse.

For example, consider a line like:

```ruby
config.x.my_config.enabled = true
config.x.my_config.enabled #=> true
```

Now consider that first line with a typo that omits the `=`:

```ruby
config.x.my_config.enabled true
config.x.my_config.enabled #=> nil
```

This commit aims to provide more direct feedback for scenarios like the
one above. There aren't legitimate use cases for invoking `#enabled`
with arguments, so raise a `ArgumentError` when encountering a read with
arguments.
2024-01-03 15:08:40 -05:00
Rafael Mendonça França
8b4e92f4be
Point rubocop to ruby 3.1 2024-01-03 19:02:32 +00:00
Rafael Mendonça França
9d18dc8505
Remove all code to work with Ruby < 3.1 2024-01-03 19:02:31 +00:00
Rafael Mendonça França
b52bd2149a
Merge pull request #50547 from faqndo97/run_importmap_audit_on_ci
Run importmap audit on CI
2024-01-03 12:08:24 -05:00
Rafael Mendonça França
588843cea1
Merge pull request #50545 from santib/use-all-ci-cores
Parallelize tests in the CI
2024-01-03 12:06:33 -05:00
Rafael Mendonça França
b0b1eb5a18
Eager load the Rails default controllers used in production (#50558)
Since those controller can be used in production we need to eager load
them to better copy-on-write and avoid tread-safety issues.
2024-01-03 11:44:09 -05:00
Rafael Mendonça França
826a3d1545
Merge pull request #50543 from santib/run-ci-on-every-pr
Adjust CI config for new Rails apps to run on PRs to any branch
2024-01-03 11:12:42 -05:00
David Heinemeier Hansson
bb5e2791e0
Add default pwa manifest and service worker file (#50528)
* Add default pwa manifest and service worker file

* Update CHANGELOG.md
2024-01-03 13:07:12 +01:00
Facundo Espinosa
44ee8b17a2 Run importmap audit on CI 2024-01-02 22:17:14 -03:00
Santiago Bartesaghi
1266d8992b Parallelize tests in the CI 2024-01-02 19:27:47 -03:00
Santiago Bartesaghi
05ce89417d Adjust CI config to run on PRs to any branch 2024-01-02 18:57:00 -03:00
Santiago Bartesaghi
aa13b5107e Add GHA actions to dependabot 2024-01-02 15:35:19 -03:00
Lázaro Nixon
42ca4de429
User content_for for titles in the application layout (#49702) 2024-01-02 17:39:35 +01:00
David Heinemeier Hansson
8397eb24da
Remove rollup and test machinery for rails-ujs (#50535)
This leaves only the final compiled targets in place.
2024-01-02 16:49:36 +01:00
David Heinemeier Hansson
361f296d05 Fix test 2024-01-02 13:56:33 +01:00
David Heinemeier Hansson
66615ac514
Replace old placeholder icon variants with a single one (#50526)
* Replace old placeholder icon variants with a single one

* Fix test
2024-01-02 12:36:18 +01:00
Wojciech Wnętrzak
0bf314cffb
Tune CI template for uploading artifact (#50533)
* Use latest version https://github.com/actions/upload-artifact#v4---whats-new
* Use only on failed test run
* When no files found, do not warn https://github.com/actions/upload-artifact#inputs
2024-01-02 12:31:26 +01:00
David Heinemeier Hansson
c57b2cd3e1
Add a default yield :head to layouts/application.html.erb (#50527)
* Add a default yield :head

Good pattern that most applications should be using.

* Make test more resilient

* Appease RuboCop
2024-01-02 12:16:29 +01:00
Koichi ITO
581074c40d
Apply autocorrection by RuboCop to files generated by bin/rails generate (#50506)
* Apply autocorrection by RuboCop to files generated by `bin/rails generate`

## Motivation / Background

RuboCop has now been included by default (#50456).
By adding the following tip to the default configuration, user can apply RuboCop's autocorrection to
code generated by `bin/rails generate` (e.g., migration file):

https://github.com/rubocop/rubocop-rails#rails-configuration-tip

This means that the generated files will be formatted according to user's .rubocop.yml custom configuration.

## Detail

Since `bin/rails generate` and `bin/rubocop` are used only in the development environment,
the target files are limited to only `config/environments/development.rb`.

## Additional information

This feature was introduced in Rails 6.1 by https://github.com/rails/rails/pull/38870.
2024-01-01 20:04:47 +01:00
Akhil G Krishnan
6069eba1c3
Fix skipped rubocop test typo (#50519) 2024-01-01 15:49:14 +01:00
Akhil G Krishnan
9bc4536d47 Add changelog entry for #50512 2024-01-01 09:35:54 +05:30
David Heinemeier Hansson
a8dcfbde95 Add step to keep screenshots of failed system tests 2024-01-01 02:11:00 +01:00
David Heinemeier Hansson
57536e5379 Fix name casing 2024-01-01 02:07:17 +01:00
David Heinemeier Hansson
e234e8380f
Switch to headless chrome by default (#50512)
So it'll work out of the box with cloud CI.
2024-01-01 01:20:05 +01:00
David Heinemeier Hansson
f50e7b66f2 Fix generator output paths 2024-01-01 01:13:38 +01:00
David Heinemeier Hansson
4fa5fd96d7 New default files 2024-01-01 01:13:38 +01:00
David Heinemeier Hansson
964ca2328e Errant debug puts 2024-01-01 01:13:38 +01:00
David Heinemeier Hansson
08a792be84
Default to creating GitHub CI files (#50508)
* Default to creating GitHub CI files
2024-01-01 00:37:12 +01:00
David Heinemeier Hansson
e3da4fc53d
Add allow_browser to set minimum versions for your application (#50505)
* Add allow_browser to set minimum versions for your application
2023-12-31 19:19:16 +01:00
Vipul A M
813afbdd74
Add brakeman to new Rails applications (#50507)
It can be skipped with the `--skip-brakeman` flag.

Closes #50501
2023-12-31 19:09:47 +01:00
Jean Boussier
1320ff0a3e
Merge pull request #2 from zzak/bump-ruby-version_check
Remove Ruby version check
2023-12-31 09:04:16 +01:00
Jean Boussier
6ba2fdb2fe Bump the required Ruby version to 3.1.0
Until now, Rails only droped compatibility with older
rubies on new majors, but I propose to change this policy
because it causes us to either keep compatibility with long
EOLed rubies or to bump the Rails major more often, and to
drop multiple Ruby versions at once when we bump the major.

In my opinion it's a bad alignments of incentives. And we'd
be much better to just drop support in new minors whenever they
go EOL (so 3 years).

Also Ruby being an upstream dependency, it's not even
a semver violation AFAICT.

Since Rails 7.2 isn't planned before a few months, we
can already drop Ruby 3.0 as it will be EOL in March.
2023-12-31 08:54:03 +01:00
zzak
110a4e6abc
Remove Ruby version check
Also includes relevant docs, inspired by 6487836af8
2023-12-31 12:38:25 +09:00
zzak
0fb5f67ac4
Add rubocop-rails-omakase to new Rails applications (#50486)
* Add rubocop to new rails app generator

This setups a basic rubocop config for new rails apps using the `rubocop-rails-omakase` gem:
https://github.com/rails/rubocop-rails-omakase

It can be skipped with the `--skip-rubocop` flag.
2023-12-30 21:13:13 +01:00
Jean Boussier
89c2f8530a Bump the required Ruby version to 3.1.0
Until now, Rails only droped compatibility with older
rubies on new majors, but I propose to change this policy
because it causes us to either keep compatibility with long
EOLed rubies or to bump the Rails major more often, and to
drop multiple Ruby versions at once when we bump the major.

In my opinion it's a bad alignments of incentives. And we'd
be much better to just drop support in new minors whenever they
go EOL (so 3 years).

Also Ruby being an upstream dependency, it's not even
a semver violation AFAICT.

Since Rails 7.2 isn't planned before a few months, we
can already drop Ruby 3.0 as it will be EOL in March.
2023-12-30 19:46:43 +01:00
Jean Boussier
6b446bee63 Remove SQLite production warning but leave production config disabled
There are valid use cases for running SQLite in production, however it must be done
with care, so instead of a warning most users won't see anyway, it's preferable to
leave the configuration commented out to force them to think about having the database
on a persistent volume etc.

Co-Authored-By: Jacopo Beschi <beschi.jacopo@gmail.com>
2023-12-27 23:32:18 +01:00
Jonathan Hefner
b0048c787a Capitalize "Rails" [ci-skip] 2023-12-19 13:16:47 -06:00
Yasuo Honda
6341e2dbb8 Ignore warnings like warning: net-smtp which is not part of the default gems since Ruby 3.1.0.
This commit addresses the CI failure against Ruby master branch.
https://buildkite.com/rails/rails/builds/102575#018c4147-8760-48ac-812c-4e63fbe242fa

This failure reproduces since this commit:
d411d8f5fe

* Steps to reproduce

Install `ruby 3.3.0dev`
```ruby
git clone https://github.com/rails/rails
cd rails/railties
rm ../Gemfile.lock
bundle
bin/test test/application/bin_setup_test.rb -n test_bin_setup_output
```

* Without this commit

```ruby
$ ruby -v
ruby 3.3.0dev (2023-12-16T21:45:33Z master d7d10f3ee8) [x86_64-linux]
$ rm ../Gemfile.lock ; bundle ; bin/test test/application/bin_setup_test.rb -n test_bin_setup_output
... snip ...
F

Failure:
ApplicationTests::BinSetupTest#test_bin_setup_output [/home/yahonda/src/github.com/rails/rails/railties/test/application/bin_setup_test.rb:51]:
--- expected
+++ actual
@@ -2,10 +2,12 @@
 The Gemfile's dependencies are satisfied

 == Preparing database ==
+/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38: warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec.
 Created database 'app_development'
 Created database 'app_test'

 == Removing old logs and tempfiles ==
+/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38: warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec.

 == Restarting application server ==
 "

bin/test test/application/bin_setup_test.rb:30

Finished in 12.553516s, 0.0797 runs/s, 0.0797 assertions/s.
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
$
```
2023-12-17 15:43:38 +09:00
Jean Boussier
3881518c47
Merge pull request #50281 from p8/activerecord/assert-queries
Expose `assert_queries` and `assert_no_queries` assertions
2023-12-12 00:29:45 +01:00
Petrik
8392c54e73 Expose assert_queries and assert_no_queries assertions
To assert the expected number of queries are made, Rails internally uses
`assert_queries` and `assert_no_queries`. These assertions can be
useful in applications as well.

By extracting these assertions to a module, the assertions can be
included where required.
These assertions are added to `ActiveSupport::TestCase` when
ActiveRecord is defined.

ActiveStorage, ActionView and ActionText are using this module now as
well, instead of duplicating the implementation.
The internal ActiveRecord::TestCase, used for testing ActiveRecord,
implements these assertions as well. However, these are slighlty more
advanced/complex and use the SQLCounter class. To keep things simple,
for now this implementation isn't used.
2023-12-11 12:31:16 +01:00
Ben Sheldon [he/him]
a9c4699751
Add runner option to disable Executor wrap 2023-12-08 09:36:33 -08:00
Chedli Bourguiba
0fe286339a Make engines aware of AR::Base table name prefix 2023-12-06 20:09:18 +01:00
Adrianna Chang
2854e378c8
Revert "Add config for validating migration timestamps" 2023-12-01 11:58:53 -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
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
c05d8ed9cd Link methods for Rails::Engine [ci-skip] 2023-11-30 11:04:38 -06:00