Commit Graph

118 Commits

Author SHA1 Message Date
David Heinemeier Hansson
f973075aa4
Drop default permissions policy initializer (#52341)
It is too rarely used to warrant such a prominent placement in the
default structure.
2024-07-16 14:41:16 +02:00
Rafael Mendonça França
37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00: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
Hans Schnedlitz
482330d156
Do not generate pidfile in production environments (#50644)
* Remove pidfile in production

* Update changelog

* Update activestorage/test/dummy/config/puma.rb

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

* Update template and other dummy files

---------

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-01-08 14:47:25 -05:00
Jonathan Hefner
3bbf21c343 Use verb form of "fallback"
"Fallback" is a noun, whereas "fall back" is a verb.
2024-01-07 17:27:23 -06:00
Chedli Bourguiba
1b97f97664 Take AR affixes into account for Action Mailbox database models 2023-12-09 11:02:30 +01:00
Hartley McGuire
b8433879bc
Fix Action Mailbox tests
ActiveSupport::TestCase isn't defined until later in the file, so the
skip override can be added at the end to ensure it exists (similar to
what the Action Pack tests do)
2023-11-30 11:11:22 -05:00
Max Notarangelo
185c19c5ae fix typo in production initializer generator
And put "info" in quotes.
2023-11-16 15:00:07 -08:00
f0a03bd899 Remove config.public_file_server.enabled from generators
Remove the option `config.public_file_server.enabled` from the generators for all environments, as the value is the same in all environments.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-11-03 11:34:37 -05:00
Jonathan Hefner
dd428f1ef1 Present config.public_file_server.enabled as opt-out
Follow-up to #47137.

Since `config.public_file_server.enabled` is true by default, this
commit changes the `config/environments/production.rb` template to
present the setting as an opt-out.
2023-10-30 11:54:26 -05:00
Nikita Vasilevsky
19f8ab2e7d
[Tests only] Enable Minitest/AssertPredicate rule 2023-10-13 19:26:47 +00:00
Rafael Mendonça França
1f0262aa2b
Separate the CI environment from the application CI environment
Right now we are using both to test the Rails applications we generate
and to test Rails itself. Let's keep CI for the app and BUILDKITE to
the framework.
2023-10-04 09:36:51 +00:00
Bart de Water
95b6fbd00f Stop building AS::Notifications::Event manually
It's possible since Rails 6 (3ea2857943dc294d7809930b4cc5b318b9c39577) to let the framework create Event objects, but the guides and docs weren't updated to lead with this example.

Manually instantiating an Event doesn't record CPU time and allocations, I've seen it more than once that people copy-pasting the example code get confused about these stats returning 0. The tests here show that - just like the apps I've worked on - the old pattern keeps getting copy-pasted.
2023-09-29 12:34:23 -04:00
Rafael Mendonça França
fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Ronan Limon Duparcmeur
3bac56e11f Added bounce_now_with
`ActionMailbox::Base#bounce_with` enqueues the bounce email. For
situations where it is preferable to skip the email queues, this
commit introduces `#bounce_now_with`, which sends the bounce email
immediately (like `deliver_now` vs. `deliver_later`).

    # Delivers the email immediately
    MyMailbox.bounce_now_with MyMailer.my_method(args)
2023-06-28 16:17:40 +02:00
Jonathan Hefner
23243eb283
Merge pull request #46476 from justinperkins/fix/i18n-reserved-words-comments
Update comments in all three en.yml files relating to booleans
2023-05-24 13:58:38 -05:00
Justin Perkins
ad1d2bed4a Clarify YAML boolean caveat in en.yml template
This clarifies that the boolean interpretation (1) is due to YAML rather
than I18n, (2) is case insensitive, and (3) affects both keys and
values.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-05-24 13:35:53 -05:00
Jon Dufresne
e28f147329 Make the test environment show rescuable exceptions in responses
Background
----------

During integration tests, it is desirable for the application to respond
as closely as possible to the way it would in production. This improves
confidence that the application behavior acts as it should.

In Rails tests, one major mismatch between the test and production
environments is that exceptions raised during an HTTP request (e.g.
`ActiveRecord::RecordNotFound`) are re-raised within the test rather
than rescued and then converted to a 404 response.

Setting `config.action_dispatch.show_exceptions` to `true` will make the
test environment act like production, however, when an unexpected
internal server error occurs, the test will be left with a opaque 500
response rather than presenting a useful stack trace. This makes
debugging more difficult.

This leaves the developer with choosing between higher quality
integration tests or an improved debugging experience on a failure.

I propose that we can achieve both.

Solution
--------

Change the configuration option `config.action_dispatch.show_exceptions`
from a boolean to one of 3 values: `:all`, `:rescuable`, `:none`. The
values `:all` and `:none` behaves the same as the previous `true` and
`false` respectively. What was previously `true` (now `:all`) continues
to be the default for non-test environments.

The new `:rescuable` value is the new default for the test environment.
It will show exceptions in the response only for rescuable exceptions as
defined by `ActionDispatch::ExceptionWrapper.rescue_responses`. In the
event of an unexpected internal server error, the exception that caused
the error will still be raised within the test so as to provide a useful
stack trace and a good debugging experience.
2023-05-17 06:30:28 -07:00
zzak
f397f47212
Use double quotes for escaping yaml (re #47983) 2023-05-16 20:34:40 +09:00
Nishiki Liu
1df5ece43b feat: use config pk type in Action Mailbox migration 2023-05-04 08:19:36 -07:00
Josh Brito
43ec5737c7 Update comment to reference values with single quotes as opposed to double 2023-04-18 21:32:37 -07:00
Andrew Novoselac
6902cbce1b Introducs TestFixtures#fixture_paths.
Multiple fixture paths can now be specified using the `#fixture_paths` accessor.
2023-03-14 19:02:56 -04:00
Rafael Mendonça França
e78ed07e00
Merge pull request #47259 from skipkayhil/hm-regenerate-dummies
Full refresh of framework dummy applications
2023-03-01 18:08:58 -05:00
Hartley McGuire
ba028a48f6
Fix Action Mailbox, Action Text strict warnings
These appear to have been missed when the change was made in
d917896f45ad680f43036d8ff6d48d7e5e198d23
2023-02-23 17:34:55 -05:00
Hartley McGuire
915159f524
Remove Webpacker files in Action Mailbox dummy app
Similar to 89a24d6216eb771c1d9bdb7cef883ca50001ca93, but importmaps are
not added because no javascript is used in the app
2023-02-18 17:51:26 -05:00
Hartley McGuire
0e3a5331a1
Regenerate Action Mailbox dummy app
Generated using the following script and manually reviewed after:
skipkayhil/rails-bin@6898611730

The :messages route was removed because there isn't actually a
MessagesController.

config/boot.rb also has its Gemfile path fixed to point at the root
Gemfile because Action Mailbox does not have a Gemfile.
2023-02-18 17:51:22 -05:00
Jesse Johnson
f4829b784a
ActionMailbox::IncinerationJobTest create test email without routing
Fixes #47020
2023-02-07 11:45:07 -08:00
David Heinemeier Hansson
2b1fa89e44
Log to stdout in production by default (#47138)
* Logging to a file doesn't make sense in production

You're going to run out of space, and it doesn't play well with containers. Either you log to STDOUT, and let your container setup aggregate the logs, or you'll be switching to syslogger or whatever. You won't be logging to a file in production any more.

* Remove from Dockerfile too

* Did not mean to change this default

But we should make it easy to see how to change it.

* Restore what we had
2023-01-25 21:10:22 +01:00
David Heinemeier Hansson
e8f481b924
Turn on static file server by default (#47137)
Modern deployments don't need NGINX/Apache when using CDNs or caching LBs in front. This means file serving works out of the box too.
2023-01-25 18:19:05 +01:00
Alex Ghiculescu
e18c23fc2b Make raise_on_missing_translations raise on any missing translation
Fixes https://github.com/rails/rails/issues/47057
Superseeds https://github.com/rails/rails/pull/45361
2023-01-23 10:17:11 -07:00
Rafael Mendonça França
39baf27007
Merge pull request #46300 from honzasterba/honzasterba/mailbox_ingress_encoding_fix
Fix ingress controllers' ability to accept non UTF-8 encoded emails
2023-01-20 17:31:21 -05:00
Rafael Mendonça França
5c835bd669
Make explicit this config only affects controllers are views 2023-01-19 20:21:29 +00:00
Jan Sterba
4b8511859a Fix ingress controllers' ability to accept non UTF-8 encoded emails
Since most of the ingress controllers receive raw MIME data in POST body,
it is impossible to guaratee that these are in UTF-8 as email comes in all
possible encodings.

This patch disables force transcoding to UTF-8 by ActionController params
processing for params that contain RAW MIME email bodies.

Fix #46297
2022-12-30 23:53:10 +01:00
David Heinemeier Hansson
d18fc32999
Use storage/ instead of db/ for sqlite3 db files (#46699)
* Use storage/ instead of db/ for sqlite3 db files

db/ should be for configuration only, not data. This will make it easier to mount a single volume into a container for testing, development, and even sqlite3 in production.
2022-12-12 08:32:12 +01:00
Andy Stewart
12867b1f32 Add X-Forwarded-To addresses to recipients 2022-11-22 15:41:28 +00:00
Evan Brooks
8d3408e41a Update mailer templates meta tag mailer.html.erb 2022-11-14 21:38:07 -04:00
Eike Send
5ba8aa5854
Facilitate use of any regular ERB in database.yml
Commit 37d1429ab1d introduced the DummyERB to avoid loading the environment when
running `rake -T`.

The DummyCompiler simply replaced all output from `<%=` with a fixed string and
removed everything else. This worked okay when it was used for YAML values.
When using `<%=` within a YAML key, it caused an error in the YAML parser,
making it impossible to use ERB as you would expect. For example a
`database.yml` file containing the following should be possible:

  development:
    <% 5.times do |i| %>
    shard_<%= i %>:
      database: db/development_shard_<%= i %>.sqlite3
      adapter: sqlite3
    <% end %>

Instead of using a broken ERB compiler we can temporarily use a
`Rails.application.config` that does not raise an error when configurations are
accessed which have not been set as described in #35468.

This change removes the `DummyCompiler` and uses the standard `ERB::Compiler`.
It introduces the `DummyConfig` which delegates all known configurations to the
real `Rails::Application::Configuration` instance and returns a dummy string for
everything else. This restores the full ERB capabilities without compromising on
speed when generating the rake tasks for multiple databases.

Deprecates `config.active_record.suppress_multiple_database_warning`.
2022-09-27 17:07:40 +02:00
Yasuo Honda
0b80408b24 Use system(.., exception: true) for dummy apps
Related to #46064
2022-09-20 22:53:05 +09:00
Jonathan Hefner
471ab2347f Omit workers and preload_app! from Puma config
Since Puma 5.0 (puma/puma@05936689c8),
Puma will automatically set `workers` to `ENV["WEB_CONCURRENCY"] || 0`.
Additionally, if `ENV["WEB_CONCURRENCY"]` > 1, Puma will automatically
set `preload_app`.

This can lead to confusing scenarios for users who are unaware of this
behavior and have customized `config/puma.rb`.  For example, if a user
uncomments the `workers` and `preload_app!` directives, it is clear that
Puma will preload the app, and the number of workers can be configured
by setting `ENV["WEB_CONCURRENCY"]`.  If the user sets
`ENV["WEB_CONCURRENCY"]` > 1, but then changes their mind and removes
the `workers` or `preload_app!` directives *without* clearing
`ENV["WEB_CONCURRENCY"]`, Puma will still preload the app and launch
`ENV["WEB_CONCURRENCY"]` number of workers.  Similarly, if a user
uncomments *only* the `workers` directive and sets
`ENV["WEB_CONCURRENCY"]` > 1, Puma will preload the app even though the
`preload_app!` directive is still commented out.

To avoid such scenarios, this commit removes the commented-out `workers`
and `preload_app!` directives from the default `config/puma.rb`.

Also, to improve discoverability of available configuration options,
this commit adds a link to the Puma DSL documentation at the top of the
file.
2022-06-03 12:38:21 -05:00
Dorian Marié
ebf916af2e Fixes development Action Mailbox new mail form
I wanted to add a test for sending an attachment that is an empty string
and a file but got this error:

NoMethodError: undefined method `original_filename' for "#<Rack::Test::UploadedFile:0x000000010840d388>":String

Related: #44702

Fixes #45088

-----

Started POST "/rails/conductor/action_mailbox/inbound_emails" for ::1 at 2022-05-14 07:34:19 +0200
Processing by Rails::Conductor::ActionMailbox::InboundEmailsController#create as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "mail"=>{"from"=>"", "to"=>"", "cc"=>"", "bcc"=>"", "x_original_to"=>"", "in_reply_to"=>"", "subject"=>"", "body"=>"", "attachments"=>[""]}, "commit"=>"Deliver inbound email"}
Completed 500 Internal Server Error in 7ms (ActiveRecord: 0.0ms | Allocations: 2600)

NoMethodError (undefined method `original_filename' for "":String

            mail.add_file(filename: attachment.original_filename, content: attachment.read)
                                              ^^^^^^^^^^^^^^^^^^):

actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:26:in `block (2 levels) in new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `each'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `block in new_mail'
<internal:kernel>:90:in `tap'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:23:in `new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:17:in `create'

Co-Authored-By: Patrício dos Santos <hello@psantos.dev>
2022-05-15 22:59:48 +02:00
Xavier Noria
2953ae5c8a Define config.enable_reloading to be !config.cache_classes
Every time I write `config.cache_classes` I have to pause for a moment to make
sure I get it right. It makes you think.

On the other hand, if you read `config.enable_reloading = true`, does the
application reload? You do not need to spend 1 cycle of brain CPU to nod.
2022-04-14 18:11:36 +02:00
Lewis Buckley
246c13f8df
Change the AS::Notification payload to include the mailbox instance 2022-03-10 09:43:34 +00:00
Lewis Buckley
599e73bc00
Instrument Action Mailbox processing
Use ActiveSupport::Notifications to instrument Action Mailbox for
logging or performance monitoring.
2022-03-09 10:06:43 +00:00
Jonathan Hefner
4917ee9df6 Use dynamic Rails version in framework dummy apps
This matches what we currently generate for plugin dummy apps.
2021-12-08 11:31:49 -06:00
Rafael Mendonça França
83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Alex Ghiculescu
5acc32ac54
Generate less initializers in new/upgraded Rails apps (part 2) (#43237) 2021-09-17 09:06:17 +02:00
Rafael Mendonça França
fd41ea1f2d
Merge branch 'main' into less-initializers 2021-09-15 17:18:49 -04:00
Xavier Noria
89801b2a43 Depend on ruby/debug, replacing Byebug
ruby/debug is a new debugger that is going to ship with CRuby.

It makes sense for Rails to switch to this one because that is
where the language is heading, and because Byebug is not fully
compatible with Zeitwerk. See

    https://github.com/deivid-rodriguez/byebug/issues/564

While ruby/debug has not been heavily tested with Zeitwerk,
casual usage seems to suggest it works without issues, including
explicit namespaces, which is where Byebug and Zeitwerk conflict.

Byebug is terrific, thanks a lot for all these years. ❤️
2021-09-08 17:35:41 +02:00
Koichi ITO
65af100ddd Tweak unreachable assertion tests in the block of assert_raises
I found an unexpected use of assertion in the block of `assert_raise`
when I implemented https://github.com/rubocop/rubocop-minitest/pull/137.
It is expected to be asserted after an exception is raised in
`assert_raise` block, but in actually it is not asserted after an
exception is raised. Therefore, this PR removes or updates assertions
that have not been asserted after an exception has raised.

This PR will add `rubocop-minitest` and enable
`Minitest/UnreachableAssertion` cop to able similar auto-detection,
but will remove `rubocop-minitest` from this PR if you don't like it.
2021-08-17 20:33:08 +09:00
David Heinemeier Hansson
e34300a921
Stop trying to configure listen by default on compatible platforms (#42985)
* Stop trying to configure listen by default on compatible platforms

Modern computers with SSDs don't see much/any benefit from having an evented file update watcher. Remove complexity by taking this spinning-drive concession out.

* Actually need listen for testing the opt-in

* Test no longer relevant
2021-08-11 15:18:43 +02:00