Commit Graph

5047 Commits

Author SHA1 Message Date
Rafael Mendonça França df32c3837d
Merge pull request #52100 from jdlubrano/fix-activerecord-configs-shadowing
Fix ActiveRecord configs variable shadowing
2024-06-12 15:44:34 -04: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
Joel Lubrano e6d924ea17
Add configuration test for ActiveRecord being loaded prior to new framework defaults 2024-06-12 18:59:40 +00: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]: 0c76f17f2d

Co-authored-by: Petrik <petrik@deheus.net>
2024-06-10 23:04:23 -04:00
fatkodima c5ac244c0d Fix running migrations on other databases when `database_tasks: false` on primary 2024-06-06 21:00:54 +03: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
Rafael Mendonça França 64d5f8ba0e
Merge pull request #49679 from zzak/railties-quiet
🤫 Quiet down railties tests
2024-05-31 19:50:34 -04:00
Rafael Mendonça França 5dd8f54741
Merge tests that are doing the same thing together
This will make sure we have less tests to run since those are slow.

Generate the app once and run many assertions on it instead of generating
the same app multiple times.
2024-06-01 07:12:09 +09:00
zzak d350e048ce
Remove unnecessary --asset-pipeline=sprockets from app generator test
Since we are stubbing bundle commands, we can avoid sprockets side-effects here.

This commit also fixes the tests for preservation of sprockets during `app:update`.

Due to propshaft being the default, this test was unnecessary.
2024-06-01 07:11:31 +09:00
Rafael Mendonça França 14fbdfb7c7
Remove test for activerecord-session_store
Since 27285e7881 the special case for this gem was removed from the
codebase.

So changed this test to be about where we expect to find the
session stores.
2024-05-31 21:07:34 +00:00
Rafael Mendonça França fe57bd2462
Lower case the `link` header
Since 1fbcf54289
the early hints will be checked against Rack::Link that requires all
headers to be lower cased.

Fixes #51961.
2024-05-31 21:00:22 +00:00
Jean Boussier bc56661a3d
Merge pull request #51933 from zzak/51910
Handle case where script_name is a blank string
2024-05-31 11:12:29 +02:00
zzak 6c7a0e891c
Change railties default log_level to :error
The default of :info generates a ton of unnecessary noise in the railties logs.
2024-05-31 10:12:07 +09:00
zzak 1d8d8e128d
Stub `rails_command` to prevent `app:template` command from being run
When #48269 was merged any gem installed during `rails new` which calls `app:template` would cause the install command to be executed and consequently `bundle install` would also run.

We want to avoid running these commands in our tests because they are very expensive.

It is up to the gem (importmap, etc) to test the behavior of the install command, not railties.

Before

```
$ bin/test test/generators/plugin_generator_test.rb test/generators/app_generator_test.rb
Finished in 320.803659s, 0.8541 runs/s, 7.1913 assertions/s.
274 runs, 2307 assertions, 14 failures, 0 errors, 0 skips
```

After

```
Finished in 70.316250s, 3.9251 runs/s, 34.3164 assertions/s.
276 runs, 2413 assertions, 0 failures, 0 errors, 0 skips
```
2024-05-31 10:12:03 +09: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
zzak 234191c03b
Handle case where script_name is a blank string
TBD: where is it being set as ""

wip: add regression test
2024-05-29 21:24:07 +09: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
zzak e2adebef43
Re-enable railtie non_existent sqlite3 test from #51901 2024-05-27 17:34:17 +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
eileencodes d189cbcb56
Revert "Merge pull request #51614 from gmcgibbon/defer_route_drawing"
This reverts commit e97db3b395, reversing
changes made to a27a1751cf.

This is breaking application routes when running without eager load enabled.
2024-05-24 09:59:41 -04:00
zzak c30c5d77d9
Fix railtie config test for sqlite 3.46.0
Follow up to #51891

This resolves the following test failure:
https://buildkite.com/rails/rails/builds/107520#018fa76e-0408-4630-a75d-eac5caa16463/1199-1209

```
Failure:
ApplicationTests::ConfigurationTest#test_SQLite3Adapter.strict_strings_by_default_can_be_configured_via_config.active_record.sqlite3_adapter_strict_strings_by_default_in_an_initializer [test/application/configuration_test.rb:2896]:
Expected /no such column: non_existent/ to match "SQLite3::SQLException: no such column: \"non_existent\" - should this be a string literal in single-quotes?".
```

Co-authored-by: Mike Dalessio <mike.dalessio@gmail.com>
2024-05-24 07:15:20 +09: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 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 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
Yasuo Honda 5c92d45e8a
Merge pull request #51838 from jeromedalbert/no-kamal-storage-volume-if-not-needed
Don’t configure Kamal storage volume if not needed
2024-05-21 08:46:26 +09:00
Yasuo Honda ba6e556f39
Merge pull request #51837 from jeromedalbert/no-storage-if-not-needed-1
Don’t create storage folder if not needed
2024-05-21 08:45:57 +09:00
Jerome Dalbert 3156e50838
Don’t configure Kamal storage volume if not needed
Configuring a persistent storage volume in Kamal
is needed only for sqlite or Active Storage. If
using a different database or the
--skip-active-storage option, this configuration
can be skipped.
2024-05-19 18:30:36 -07:00
Chris Oliver 7594a73942
Add rubocop and GitHub Actions to plugin generator
When creating new Rails plugins, rubocop and GitHub Actions are now
included to make linting and testing easier.
2024-05-18 09:19:12 -05:00
Jerome Dalbert 918c71fa5a Don’t create storage/ directory if not needed
The storage/ directory is used for sqlite or
Active Storage. If using a different database
and the --skip-active-storage option, this
directory is not needed.
2024-05-17 10:52:15 -07:00
Hartley McGuire 6ec2384e07
Allow test command invocations to exit failure
Minitest will now exit 1 when a `-n` type test filter is used and no
test cases end up being run. However, these tests are not really
concerned with the exit code, just that `test:prepare` doesn't run.

This commit adds `allow_failure: true` to the test command invocations
so that we can continue to test whether `test:prepare` is run without
caring about the exit status of the test command.
2024-05-15 18:50:06 -04:00
Rafael Mendonça França a82e432b83
Merge pull request #51763 from JoeDupuis/postgresql-adapter-decode-dates-config
Add `active_record.postgresql_adapter_decode_dates` config
2024-05-15 14:55:15 -04:00
Rafael Mendonça França b56ee17db6
Merge pull request #51783 from JoeDupuis/fix-fail-fast-flake
Fix test runner --fail-fast test flake
2024-05-15 14:42:06 -04:00
Joé Dupuis 478874ae1b
Add `active_record.postgresql_adapter_decode_dates`
to toggle automatic decoding of dates column with the
PostgresqlAdapter.

PR #51483 is a breaking change and should have been gated behind a
config.
2024-05-15 18:38:08 +00:00
Carlos Antonio da Silva 72fccfb5d6 Fix console tests
We need to pass the verbose option in order to test the full expected
output. Not sure why these were green on the branch.

Introduced by #51732.
2024-05-14 20:59:11 -03:00
Carlos Antonio da Silva 5e3611ea5a
Merge pull request #51732 from Shopify/fix-rails-console-prompt
Avoid setting fixed app name in console prompt
2024-05-14 18:56:21 -03:00
David Heinemeier Hansson bee3fa41ca
Add Kamal by default to Rails 8 (#51798)
* Add Kamal by default
2024-05-13 17:32:42 -07:00
Rafael Mendonça França a70d89c519
Merge pull request #51766 from Shopify/revert-actionable-errors-retry
Revert "Merge pull request #50941 from andrewn617/actionable-cli"
2024-05-13 18:28:42 +00:00
Rafael Mendonça França cb1c789ca2
Merge pull request #51765 from Shopify/refactor-devcontainer-implementation
Clean up database generators implementation
2024-05-13 14:19:44 -04:00
Rafael Mendonça França 5c933a3d82
Merge pull request #51791 from duduribeiro/add-name-to-devcontainer-compose
Add name to DevContainer compose file
2024-05-13 14:10:47 -04:00
Andrew Novoselac c1bc7ee82e Refactoring Database generators
Extract all the DB information (gems, dockerfile packages, devcontainer etc.) into an object. This let's us remove the growing number of case statements in this code.
2024-05-13 14:07:47 -04:00
Andrew Novoselac 5b91084f20 Remove support for oracle, sqlserver and JRuby specific database adapters from the new and db:system:change commands. The supported options are sqlite3, mysql, postgresql and trilogy. 2024-05-13 14:07:47 -04:00