Commit Graph

8419 Commits

Author SHA1 Message Date
Rafael Mendonça França 35efaca34e
Merge pull request #51588 from duduribeiro/add-devcontainer-forward-ports
Change devcontainer.json to forward used ports for the project
2024-04-18 13:47:50 -03:00
Mike Dalessio fd1c635d2f Allow sqlite3 to float to version 2 2024-04-18 11:34:24 +02:00
Cadu Ribeiro 6a0f59a456 Change devcontainer.json to forward used ports for the project 2024-04-17 16:23:17 -03:00
Jean Boussier cb72a919e1
Merge pull request #51445 from shouichi/remove-node-modules-from-the-final-image
Remove node_modules from the final image
2024-04-17 18:42:37 +02:00
Rafael Mendonça França 1428ef984e
Merge pull request #51572 from Bodacious/patch-1
Wrap YJIT guard clause in parentheses
2024-04-16 16:59:22 -03:00
Cadu Ribeiro 6b9948938c Add node and yarn to devcontainer when creating a project with Javascript 2024-04-15 23:31:50 -03:00
Gavin Morrice c325216cdc
Wrap YJIT guard clause in parentheses 2024-04-15 16:28:20 +01:00
Rafael Mendonça França d8ca552e41
Merge pull request #51481 from andrewn617/devcontainer-user-dependency-features
Use devcontainer features for optional dependencies
2024-04-12 14:37:46 -03:00
Andrew Novoselac 765606500b Ensure that environment variables should always be strings, not booleans.
This specifically is affecting the mysql and mariadb ALLOW_EMPTY_PASSWORD flag. It seems VSCode is doing something to handle coercing these to strings, but an issue occurs when using docker-compose on this file.
2024-04-12 11:23:53 -04:00
Andrew Novoselac 16afdbea70 Use devcontainer features for optional dependencies
We have created our own features for optional Rails dependencies needed for active storage, postgres and mysql. Features provide a bit better ergonomics for adding or removing these from the devcontainer, and previously we were always installing these dependencies via the devcontainer's dockerfile, whether the app was using them or not.

With this change, when we generate the app, we just add the features we need to the devcontainer.json. And also, we swap features in and out as need when doing db:system:change.
2024-04-12 10:13:42 -04:00
Rafael Mendonça França d3b055eafd
Merge pull request #51518 from andrewn617/devcontainer-dev-mode
Make local rails available to devcontainer generated with `--dev`
2024-04-11 14:37:16 -03:00
Étienne Barrié 1dc7620b9f Respond with 406 when a browser is blocked by allow_browser
RFC 9110 specifies:

	The server MUST send an Upgrade header field in a 426 response
	to indicate the required protocol(s)

https://httpwg.org/specs/rfc9110.html#status.426

Status 406 Not Acceptable is more appropriate because it indicates the
resource

	does not have a current representation that would be acceptable
	to the user agent, according to the proactive negotiation header
	fields received in the request

https://httpwg.org/specs/rfc9110.html#status.406

With the proactive negociation section mentionining:

	implicit characteristics, such as the client's network address
	or parts of the User-Agent field.

https://httpwg.org/specs/rfc9110.html#proactive.negotiation
2024-04-11 10:50:24 +02:00
Carlos Antonio da Silva ca36a8083a
Merge pull request #51519 from duduribeiro/remove-duplicated-devcontainer-features-key
Remove duplicated features attribute on devcontainer.json.tt
2024-04-09 11:21:02 -03:00
Joshua Young b0f6d77e99 Fix minor typos in `enqueue_after_transaction_commit` default docs 2024-04-09 23:55:35 +10:00
Cadu Ribeiro e2333c6e80 Remove duplicated features attribute on devcontainer.json.tt 2024-04-09 10:43:24 -03:00
Andrew Novoselac ab17a6cec5 When generating an app with the --dev flag, mount the local rails repo in the devcontainer
This is useful for testing changes to how the devcontainer is generated, and will be necessary for creating a CI workflow for testing the devcontainer setup.
2024-04-08 15:30:04 -04:00
Jean Boussier 30753c1929
Merge pull request #51489 from p8/guides/improve-enqueue-after-transaction-commit-documentation
Fix documentation for `enqueue_after_transaction_commit`
2024-04-04 16:53:22 +02:00
Jean Boussier 40d6385123 Stop generating files with `git_source(:github)`
This has been built-in in Bundler for years now, and the
builtin version is much better as it allows to point to a PR
directly.
2024-04-04 15:04:16 +02:00
Petrik 97e2e93f38 Fix documentation for `enqueue_after_transaction_commit`
Correct some grammar and update the framework defaults documentation
from use `true` and `false` to `:never` and `:default`.
2024-04-04 12:06:18 +02:00
Gannon McGibbon d4c40b6cf9
Merge pull request #50941 from andrewn617/actionable-cli
Retry `ActionableError`s when running tests
2024-04-03 19:22:30 -05:00
Andrew Novoselac bc9c66583e Allow Actionable Errors encountered when running tests to be retried.
If running in an interactive console, the user will be given the option to correct the error and re-run the tests.

Co-authored-by: Gannon McGibbon <gannon.mcgibbon@gmail.com>
2024-04-03 19:32:34 -04:00
Jean Boussier e922c59207 Implement Active Job enqueue_after_transaction_commit
A fairly common mistake with Rails is to enqueue a job from inside a
transaction, with a record as argumemnt, which then lead to a RecordNotFound
error when picked up by the queue.

This is even one of the arguments advanced for job runners backed by the
database such as `solid_queue`, `delayed_job` or `good_job`.

But relying on this is undesirable in my opinion as it makes the Active Job
abstraction leaky, and if in the future you need to migrate to another backend
or even just move the queue to a separate database, you may experience a lot of
race conditions of the sort.

To resolve this problem globally, we can make Active Job optionally transaction
aware, and automatically defer job queueing to `after_commit`.

Co-Authored-By: Cristian Bica <cristian.bica@gmail.com>
2024-04-03 16:32:16 +02:00
Shouichi Kamiya 7c7968907b Remove node_modules from the final image 2024-03-29 11:52:56 +09:00
Steve Polito 7242fd7f5c
Conditionally skip test job in ci.yml (#51289)
Skip generating a `test` job in ci.yml when a new application is
generated with the `--skip-test` option.

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-03-25 13:55:20 -07:00
Rafael Mendonça França 98b3183356
Merge pull request #51390 from andrewn617/devcontainer-use-ruby-feature
Devcontainer using ruby image
2024-03-25 16:43:49 -03:00
Rafael Mendonça França cccbedf651
Merge pull request #51393 from stevepolitodesign/sp-node-lts
Bump `NODE_LTS_VERSION` to 20.11.1
2024-03-25 15:57:22 -03:00
Edouard CHIN cac6568837
Merge pull request #51389 from lxxxvi/add-documentation-for-rails-env-local-questionmark
[ci skip] Documentation for `Rails.env.local?`
2024-03-25 15:43:35 +01:00
Carlos Antonio da Silva 61a3e61e77 Minor text / error message tweaks, fixes, and punctuation
Improve a few sentences and add punctuation to some recent changelog &
guide entries.

[ci skip]
2024-03-25 10:21:08 -03:00
Steve Polito 0f18fe1322 Bump `NODE_LTS_VERSION` to 20.11.1
In e8638c9a94 we introduced a constant to
store the version of Node to be used when generating `.node-version`.

Since then, the [current LTS][LTS] version of Node is now `20.11.1` as
of [2024-02-14][date].

[LTS]: https://nodejs.github.io/nodejs.dev/en/about/releases/
[date]: https://nodejs.org/en/blog/release/v20.11.1
2024-03-25 05:27:49 -04:00
Jean Boussier 7a8e58bcb3 Put plural inverse association inference behind a configuration flag
Ref: https://github.com/rails/rails/pull/50284

While having the inverse association configured it generally positive
as it avoid some extra queries etc, infering it may break legecy code,
as evidenced by how it broke `ActiveStorage::Blob` in https://github.com/rails/rails/pull/50800

As such we can't just enable this behavior immediately, we need to provide
and upgrade path for users.
2024-03-25 10:24:21 +01:00
Andrew Novoselac 060eb5fe4a Add requires for YAML and JSON in the DB System Change generator
These were missed in rails/rails@c90a8701
2024-03-22 09:23:08 -04:00
Andrew Novoselac 5fcbc2c421 Update the Rails app devcontainer to use the Rail's orgs ruby image 2024-03-22 09:23:07 -04:00
mario ddeb955d45 add documentation for Rails.env.local? 2024-03-22 13:16:02 +01:00
Rafael Mendonça França 5ab13c5a77
Merge pull request #51337 from fatkodima/secret_key_base-deprecation-in-development
Show warning for `secret_key_base` in development too
2024-03-18 14:37:32 -07:00
Jean Boussier 5411787a15
Merge pull request #51005 from zzak/test-runner-did-you-mean
Rails test command suggests similar test files when the given file is not found
2024-03-16 10:38:07 +01:00
zzak 346f516fa1
Rails test command suggests similar test files when the given file is not found.
For example, if you run `rails test test/models/usr_tsst.rb` and the file does not exist,
Rails will suggest `test/models/users_test.rb` as a possible file.

```
Could not load test file: test/models/usr_tsst.rb. Did you mean? test/models/user_test.rb
```

Co-authored-by: Aaron Patterson <aaron@rubyonrails.org>
2024-03-16 17:54:34 +09:00
fatkodima b96b936a19 Show warning for `secret_key_base` in development too 2024-03-15 23:34:43 +02:00
Mike Dalessio 8957ba58d5
Fix sanitizer vendor config with 7.1 defaults
rails-html-santizer is a dependency of Action View and a transitive
dependency of Action Text (via Action Pack), but may not be loaded
until after railties sets configuration defaults.

This change `require`s rails-html-sanitizer immediately before it's
needed, and avoids the possibly-incorrect assumption that
Rails::HTML::Sanitizer is already defined.

Closes #51246

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-03-06 16:54:16 -05:00
Jean Boussier 7263da542b Deprecate `ConnectionPool#connection`
Replaced by `#lease_connection` to better reflect what it does.

`ActiveRecord::Base#connection` is deprecated in the same way
but without a removal timeline nor a deprecation warning.

Inside the Active Record test suite, we do remove `Base.connection`
to ensure it's not used internally.

Some callsites have been converted to use `with_connection`,
some other have been more simply migrated to `lease_connection`
and will serve as a list of callsites to convert for
https://github.com/rails/rails/pull/50793
2024-03-01 14:32:55 +01:00
Steve Polito 59a3dd4729
Set `action_mailer.default_url_options` values in `development` and `test` (#51191)
* Set `action_mailer.default_url_options` values in `development` and `test`.

Prior to this commit, new Rails applications would raise
`ActionView::Template::Error` if a mailer included a url built with a
`*_path` helper.

Since we already know [new apps will be served on `localhost:3000`][new
apps], we set this as the value in `development`.

In an effort to remain consistent with existing patters, we set the
`host` to `www.example.com` in `test.

[new apps]: 47300002db/README.md?plain=1#L81

* Update railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

---------

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-02-27 16:19:23 -05:00
Rafael Mendonça França b6285e98f0
Make sure `assert_initializer` accepts a block 2024-02-23 21:54:54 +00:00
Steve Polito fb16702fee Introduce `Rails::Generators::Testing::Assertions#assert_initializer`
Compliments the existing [initializer][] generator action.

```rb
assert_initializer "mail_interceptors.rb"
```

[initializer]: https://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-initializer
2024-02-23 10:54:25 -05:00
Jean Boussier a918394974 Refactor InternalMetadata, MigrationContext to belong to the pool
Extracted from: https://github.com/rails/rails/pull/50793

Similar to the recent refactoring of schema caches, rather than to directly
hold a connection, they now hold a pool and checkout a connection when needed.
2024-02-22 12:46:41 +01:00
Eugene Kenny 4b9b1ef5fa Don't force controller or integration tests to load
2730f10560 replaced references to
ActionController::TestCase and ActionDispatch::IntegrationTest in this
file with lazy load hooks to avoid loading them prematurely, but these
requires meant that they were still loaded anyway.
2024-02-21 03:46:41 +00:00
Rafael Mendonça França de139607cc
Merge pull request #51112 from dorianmariecom/dorian/to_s-for-generated-attribute
`Rails::Generators::GeneratedAttribute#to_s`
2024-02-20 17:24:50 -05:00
Rafael Mendonça França eccc6061f4
Remove deprecated behavior that would rollback a transaction block when exited using `return`, `break` or `throw`. 2024-02-20 21:56:51 +00:00
Rafael Mendonça França 4bf2c4cea1
Remove deprecated behavior to support referring to a singular association by its plural name 2024-02-20 21:50:36 +00:00
Viktor Schmidt 052b5ed69a
Improve title tag for new apps (#51134)
* Fix regex for application name assertion

* Change title tag to default to a titleized app name
2024-02-20 13:32:33 -08:00
Dorian Marié dd73f37be9
Rails::Generators::GeneratedAttribute#to_s 2024-02-20 20:57:54 +00:00
Rafael Mendonça França c6c8d1d3c4
Merge pull request #51141 from peterberkenbosch/update-test-case-generator-to-codestyle
Fix linting error for generated system test case.
2024-02-20 15:16:12 -05:00