Commit Graph

8544 Commits

Author SHA1 Message Date
Rafael Mendonça França
716e4a7d32
Merge pull request #52091 from jasonkim/to-time-use-timezone
Add a config for preserving timezone information when calling `to_time` on TimeWithZone object
2024-06-26 16:16:05 -04:00
Sam Ruby
0350187882 Fix mailer templates to be rubocop compliant
- spaces around array elements
- only emit blank lines between new blocks of code
2024-06-23 07:28:25 -04:00
Rafael Mendonça França
fc60a394c0
Merge pull request #52175 from y-yagi/correctly_generate_devcontainer_for_mysql2
Correctly generate Devcontainer setting for applications that using mysql2 gem
2024-06-21 17:09:17 -04:00
Rafael Mendonça França
bc67961679
Merge pull request #52179 from Uaitt/Dockerfile-FromAsCasing-offenses
Fix `FromAsCasing` offense while building a Dockerfile
2024-06-21 16:59:59 -04:00
Jeremy Daer
eea3d5adcf Revert lazy routesets (#52012) due to polymorphic routing regression
References https://github.com/rails/rails/pull/52012#issuecomment-2183415161

Revert "Merge pull request #52033 from Shopify/amend_lazy_routes_changelog"

This reverts commit 743128b2307b6e1bd59acb9dc8358592d264c573, reversing
changes made to 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8.

Revert "Merge pull request #52012 from Shopify/defer_route_drawing"

This reverts commit 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8, reversing
changes made to 5dabff4b7bf4cc5e2e552efb78c6a3f3e44bed37.
2024-06-21 13:59:43 -07:00
Lorenzo Zabot
9b43e91108 Fix FromAsCasing offenses while building a Dockerfile 2024-06-21 14:07:02 +02:00
Yuji Yaginuma
fd0d2de9ad Correctly generate Devcontainer setting for applications that using mysql2 gem
Currently, `devcontainer` command sets an adapter name, but
`DevcontainerGenerator` requires a database name.
16d8b82d5e/railties/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb (L11)
16d8b82d5e/railties/lib/rails/generators/database.rb (L6)

So the `devcontainer` command doesn't generate the setting for
MySQL. This fixes to generate the correct setting.
2024-06-21 17:16:40 +09:00
Sam Ruby
8eafbc1b19 make "g scaffold" with no field produce rubocop compliant code
When there are no fields:
  * Omit blank line in migration prior to "t.timestamps"
  * Omit leading and trailing spaced in empty hashes in
    create and update controller and api functional tests

Co-authored-by: zzak <zzakscott@gmail.com>
2024-06-20 22:11:09 -04:00
Jason Kim
9dcf17ec4c Add a config for preserving timezone information
when calling `to_time` on TimeWithZone object

Co-authored-by: jhawthorn <jhawthorn@github.com>
2024-06-13 14:56:40 -07:00
Rafael Mendonça França
5cb2603d56
Merge pull request #52040 from zzak/re-52026
Rails::ConsoleMethods deprecation warning should point to the source
2024-06-13 15:25:35 -04:00
Yuji Yaginuma
44a64ce904 Correctly output driven_by setting for Development Containers
Currently, `ENV["SELENIUM_HOST"]` is evaluated when generating a file. So
the result was the following.

```
  driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
    browser: :remote,
    url: "http://:4444"
  }
```

This PR fixes to output the URL setting just as a string. The after
result is the following.

```
  driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: {
    browser: :remote,
    url: "http://#{ENV["SELENIUM_HOST"]}:4444"
  }
```
2024-06-13 16:30:20 +09:00
Rafael Mendonça França
68b6a1cc57
Merge pull request #52064 from feliperaul/improve_message_verifier_and_signed_id_docs
[ci skip] Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
2024-06-12 18:00:28 -04:00
Felipe
ad20d9e7ec
Improve ActiveSupport::MessageVerifier and ActiveRecord::SignedId docs
The documentation on ActiveSupport::MessageVerifier used the “sensitive data” string as an example; that wording might induce the developer to think we’re dealing with encryption, while the payload is actually only Base64 encoded and is not protected at all.

We also improve the documentation on ActiveRecord::SignedId, which uses MessageVerifier and thereby will also expose the ID as encoded cleartext, making explicit that it’s not encryption, only signing.

Lastly, we refer the developer to MessageEncryptor if the payload needs to be encrypted.
2024-06-12 20:46:27 +00:00
Rafael Mendonça França
c666dac546
Merge pull request #49240 from deepakmahakale/notes-ui
Add an internal route for bin/rails notes
2024-06-12 15:08:49 -04:00
Rafael Mendonça França
db1bbc4070
Merge pull request #52069 from otorain/fix-redundant-package-in-ci-template
remove redundant database package from ci.yml.tt template
2024-06-12 15:06:33 -04:00
Rafael Mendonça França
8229339593
Merge pull request #52095 from ioquatix/rack-version-constant
Print `Rack.release` as part of default Rails welcome page.
2024-06-12 14:24:24 -04:00
Samuel Williams
423959b5b5
Print Rack.release as part of default Rails welcome page. 2024-06-12 10:36:25 +09:00
Rafael Mendonça França
2ebb508cd8
Merge pull request #52086 from y-yagi/bring_back_pumarb_to_app_update
Bring back `puma.rb` to target of `app:update`
2024-06-11 19:37:18 -04:00
Yuji Yaginuma
e4f8604602 Bring back puma.rb to target of app:update
This is a partial revert of #41083.

`puma.rb` may update by users, but  Rails has improved `puma.rb` sometimes.
For example, 06d614ada9e4609ff83659e842f48af3232a03a5 and f719787c582839fd2fcd886d70b43da3ddad2ceb.

To allow users to know those improvements, I think we should update
`puma.rb` by `app:update`.
2024-06-11 16:06:30 +09:00
Hartley McGuire
c2901eb084
Restore some config.secret_key_base functionality
The [deprecated secrets removal][1] ended up removing a bit of
non-deprecated functionality related to config.secret_key_base:

- the original implementation prioritized the value of
  config.secret_key_base over other sources in all environments
- if unset, the value of config.secret_key_base would be updated to
  whichever fallback value was found

The new implementation only sets config.secret_key_base to a fallback
value when Rails.env.local?, and never considers it at all in
production.

This commit aims to restore this missing functionality as well as
simplify the implementation:

- Rails.application.secret_key_base now always delegates to
  config.secret_key_base (like the pre-secret-removal implementation)
- secret_key_base validation was moved from the reader to the writer
- config.secret_key_base now handles setting itself to a fallback value
  when unset
- In addition, generate_local_secret was simplified because it
  previously did 3 things: file manipulation, setting
  config.secret_key_base, and returning a value. Now it only creates the
  file if necessary and returns the value stored in it

The new implementation has an additional benefit, which is that manually
set config.secret_key_base values are now validated, whereas previously
only fallback values were validated.

[1]: 0c76f17f2dbf0d7ad90c890e6f334743cacce41f

Co-authored-by: Petrik <petrik@deheus.net>
2024-06-10 23:04:23 -04:00
ian
5871d21d5d remove the redundant database package from ci.yml.tt template 2024-06-10 23:52:28 +08:00
zzak
33a748a7cf
Rails::ConsoleMethods deprecation warning should point to the source
Before:

```
 (called from Rails::ConsoleMethods.include at /home/zzak/code/rails/railties/lib/rails/console/methods.rb:6)
```

After:

```
 (called from block in <class:Engine> at /home/zzak/.rbenv/versions/3.4.0/lib/ruby/gems/3.4.0+0/bundler/gems/mission_control-jobs-7295d75ed735/lib/mission_control/jobs/engine.rb:73)
```

Co-authored-by: Wojciech Wnętrzak <w.wnetrzak@gmail.com>
2024-06-08 19:54:56 +09:00
Gannon McGibbon
6622075802
Merge pull request #52012 from Shopify/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called.
2024-06-06 11:23:47 -05:00
Rafael Mendonça França
5cfc1f8f56
Remove the default network from the devcontainer compose
And stop exposing the capybara server port to all interfaces.

We were using this just to make sure the selenium container can access
the capybara server but it can with the default bridge network.
2024-06-04 19:18:07 +00:00
Gannon McGibbon
7ac333858c Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-06-04 11:12:12 -05:00
Matthew Draper
43fcdfa4d0 Revert "Remove deprecated support for the pre-Ruby 2.4 behavior of to_time"
This reverts commit b1b2c6d59c3e82ff8eed95f5556a902a4c03abd9.
2024-06-02 23:52:59 +09:30
Rafael Mendonça França
157f1df8fb
Require action_view/helpers instead of rails-html-sanitizer
This will avoid a warning about circular dependencies.

/circular require considered harmful.*rails-html-sanitizer/

This happens because `rails-html-sanitizer` requires `action_view/helpers`
that requires `action_view/helpers/sanitize_helper` that requires
`rails-html-sanitizer`.

I'll properly fix this in rails-html-sanitizer later removing the code
that needs to be added to ActionView::Helpers in that gem.
2024-05-31 20:25:06 +00:00
Rafael Mendonça França
5fea59c076
Rename template folder to avoid . prefix
The gemspec doesn't include files with the `.` prefix, so the released
gem didn't include the devcontainer templates. This commit renames the
folder to avoid the `.` prefix, following the same pattern as all
the other `.` templates.
2024-05-31 18:25:26 +00:00
Rafael Mendonça França
4e1750603e
Merge pull request #51959 from Earlopain/prism-test-parser-relax
Relax the prism test parser conditions
2024-05-30 17:57:55 -04:00
Earlopain
c7c974335d
Relax the prism test parser conditions
Checking explicitly against `test` break extensions that provide their
own methods to generate tests, like `minitest-spec-rails` or `minitest-rails`.

Fixes #51956
2024-05-30 22:28:38 +02:00
Chris Oliver
e360d1ee8c
Update public directory during app:update command 2024-05-30 18:52:22 +00:00
Jon Evans
b7f7b0cb2f
Switch example editor to code instead of mate
It's been almost 10 years since the last TextMate update. 😢

I've seen developers be confused here - "huh, what's mate?" - and while I do not want to be seen as advocating for a particular editor, I would bet that more developers are on VS Code than are still holding on to TextMate.
2024-05-29 19:56:25 -06:00
Jean Boussier
f719787c58 Restore automatic detection of processor count in default puma config
It has to be reverted because the previous implementation wasn't
cgroup aware so it would often start way too many processes on various
shared hosting platforms.

Thanks to https://github.com/ruby-concurrency/concurrent-ruby/pull/1038
concurrent-ruby 1.3 now offer a cgroups aware method to detect how
many processors we can actually use.
2024-05-29 16:46:51 +02:00
Rafael Mendonça França
bcba3f327a
Use docker.io as the default registry for Ruby images
The `registry.docker.com` registry isn't documented and have a delay
when pulling images. The `docker.io` registry is the default registry
for Docker images and is the one used by the Docker CLI.
2024-05-28 18:21:48 +00:00
wonda-tea-coffee
e71ba8f914 Fix typo 2024-05-27 18:58:28 +09:00
David Heinemeier Hansson
1b3fc3c82e
Change asset pipeline default to Propshaft in Rails 8 (#51799)
* Change asset pipeline default to Propshaft

* Use :all for stylesheets when propshaft is active

* Switch to using propshaft as the default (still need to find a way to tests against sprockets too)

* Fix tests that rely on sprockets being used

* Fix Propshaft tests (#51913)

* Update railties/test/generators/shared_generator_tests.rb

Co-authored-by: Lázaro Nixon <lazaronixon@hotmail.com>

---------

Co-authored-by: Lázaro Nixon <lazaronixon@hotmail.com>
2024-05-25 20:48:35 -07:00
Carlos Antonio da Silva
942be52465 Use the railties deprecator instead of creating a new one
Add tests to verify the app and helpers files deprecation / backwards
compatibility, and remove the `.rb` extension from the message, since we
generally require without them.
2024-05-24 15:19:13 -03:00
Carlos Antonio da Silva
46cd9f7406
Merge pull request #51839 from Shopify/keep-deprecated-files
Add app.rb and helpers.rb back for backward compatibility
2024-05-24 15:04:24 -03:00
eileencodes
d189cbcb56
Revert "Merge pull request #51614 from gmcgibbon/defer_route_drawing"
This reverts commit e97db3b3957781c781a61fb01265feb2b57688bb, reversing
changes made to a27a1751cfd499f69499e943f12e3400b55a323e.

This is breaking application routes when running without eager load enabled.
2024-05-24 09:59:41 -04:00
Stan Lo
0b18caccf2
Add app.rb and helpers.rb back
Those files were removed in #51760, but gems like `console1984` depend
on these files for legacy Rails console command extensions.
So keeping files around is required for backward-compatibility.
2024-05-24 06:24:50 +09:00
Rafael Mendonça França
b284f8b867
Merge pull request #51896 from rails/rm-make-invert-opt-in
Don't enable automatically_invert_plural_associations by default
2024-05-23 15:49:51 -04:00
Rafael Mendonça França
15381dd3b1
Merge pull request #51894 from rails/rm-enable-yjit
Move plumbing to enable yjit to inside the framework
2024-05-23 15:19:39 -04:00
Rafael Mendonça França
a8a848d76e
Don't enable automatically_invert_plural_associations by default
This can cause a lot of issues that are hard to detect.

It is better to make this opt-in for people that want to use it.

In Rails 8 we can revisit if we want to enable this config by default.
2024-05-23 19:15:01 +00:00
Rafael Mendonça França
30e6a197df
Move plumbing to enable yjit to inside the framework
There is no reason to expose all those details to users and this
has the benefit that now are can ensure that the YJIT is enabled
after all initialization is done.
2024-05-23 19:01:29 +00:00
Andrew Novoselac
df203b2e90
Create a devcontainer command
This command boots the application, and generates a Dev Container setup based on the current configuration of the application.
2024-05-23 18:50:51 +00:00
Andrew Novoselac
4d62ea3ed4
Update database.yml from DevcontainerGenerator
Postgresql's database.yml has devcontainer specific logic that should only appear when the app has a devcontainer. We need the DevcontainerGenerator to update database.yml, so when it is called by the devcontainer command the database.yml will have the right configuration.

This commit also fixes db:system:change to make sure it updates the database.yml with the correct devcontainer configuration.
2024-05-23 18:43:22 +00:00
Andrew Novoselac
1275e93594
Update application_system_test_case.rb from DevcontainerGenerator
Instead of relying on the template to be dev container aware and generate the correct configuration, let's just update the configuration in place when running the DevcontainerGenerator. This will allow the devcontainer command to update this file with the configuration needed for devcontainers without overwriting the entire file.
2024-05-23 18:43:21 +00:00
Andrew Novoselac
f31b6f02ea
Extract Dev Container implementation into its own generator
This refactoring prepares the way to implement a devcontainer command to add an devcontainer to an existing app.
2024-05-23 18:43:20 +00:00
Andrew Novoselac
a61bfe49a5
Make devcontainer opt-in when creating a new application
For Rails 7.2 we will make devcontainer and opt-in feature for new applications. When creating a new app, you can generate a devcontainer by passing the --devcontainer flag.
2024-05-23 18:43:19 +00:00
Rafael Mendonça França
c906f75282
Merge pull request #51822 from excid3/plugin-github-actions
Add rubocop and GitHub Actions to plugin generator
2024-05-23 14:08:58 -04:00