Commit Graph

209 Commits

Author SHA1 Message Date
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
Deepak Mahakale
e54fa13cdd
Add nodoc 2023-03-06 17:04:00 +05:30
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
zzak
d2af670dba
Remove Copyright years (#47467)
* Remove Copyright years

* Basecamp is now 37signals... again

Co-authored-by: David Heinemeier Hansson <dhh@hey.com>

---------

Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
2023-02-23 11:38:16 +01: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
Yasuo Honda
f838a74212
Merge pull request #46866 from ghousemohamed/change-year-2022-to-2023 2023-02-13 13:15:43 +09:00
Guillermo Iguaran
261f32d98d
Merge pull request #47245 from rikkipitt/master
Update ActionMailbox conductor index view
2023-02-07 12:17:05 -08:00
Jesse Johnson
f4829b784a
ActionMailbox::IncinerationJobTest create test email without routing
Fixes #47020
2023-02-07 11:45:07 -08:00
binarygit
8381bc6eef
fix typo in action_mailbox/base.rb 2023-02-06 13:10:24 +05:45
zzak
f8544410a2 Use stable guides link for package READMEs
E.g.: These show up here:
https://api.rubyonrails.org/files/actioncable/README_md.html
2023-02-04 09:01:00 +09:00
Rikki Pitt
fef4d0fe28
Update ActionMailbox conductor index view
Move links to create new inbound emails to the top of the page.
2023-02-03 13:22:31 +00:00
Petrik
6e89ae2d2e Use infinitive form verb for all task descriptions
All the common rails commands and some extended commands use the
infinitive form for the verb in the description. This changes the
remaining tasks to use the infinitive form verb as well, for
consistency.

__Before__

```console
$ bin/rails --help
...
action_mailbox:install             Installs Action Mailbox and its dependencies
...
app:template                       Applies the template supplied by LOCATION=(/path/to/template) or URL
...
credentials:diff                   Enrolls/disenrolls in decrypted diffs of credentials using git
credentials:edit                   Opens the decrypted credentials in `$EDITOR` for editing
credentials:show                   Shows the decrypted credentials
db:create                          Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use...
db:drop                            Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use d...
...
db:fixtures:load                   Loads fixtures into the current environment's database
db:migrate                         Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
db:migrate:down                    Runs the "down" for a given migration VERSION
db:migrate:redo                    Rolls back the database one migration and re-migrates up (options: STEP=x, VERSION=x)
db:migrate:up                      Runs the "up" for a given migration VERSION
db:prepare                         Runs setup if database does not exist, or runs migrations if it does
db:reset                           Drops and recreates all databases from their schema for the current environment and loads th...
db:rollback                        Rolls the schema back to the previous version (specify steps w/ STEP=n)
db:schema:cache:clear              Clears a db/schema_cache.yml file
db:schema:cache:dump               Creates a db/schema_cache.yml file
db:schema:dump                     Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['...
db:schema:load                     Loads a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SC...
db:seed                            Loads the seed data from db/seeds.rb
db:seed:replant                    Truncates tables of each database for current environment and loads the seeds
db:setup                           Creates all databases, loads all schemas, and initializes with the seed data (use db:reset t...
db:system:change                   Changes `config/database.yml` and your database gem to the target database
db:version                         Retrieves the current schema version number
destroy                            Removes code generated by `bin/rails generate`
dev:cache                          Toggles development mode caching on/off
encrypted:edit                     Opens the decrypted file in `$EDITOR` for editing
encrypted:show                     Shows the decrypted contents of the file
...
log:clear                          Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test...
middleware                         Prints out your Rack middleware stack
notes                              Shows comments in your code annotated with FIXME, OPTIMIZE, and TODO
...
routes                             Lists all the defined routes
runner                             Runs Ruby code in the context of your application
...
secrets:edit                       Opens the secrets in `$EDITOR` for editing
secrets:show                       Shows the decrypted secrets
...
tmp:create                         Creates tmp directories for cache, sockets, and pids
version                            Shows the Rails version
...
zeitwerk:check                     Checks project structure for Zeitwerk compatibility
```

__After__

```console
$ bin/rails --help
...
action_mailbox:install             Install Action Mailbox and its dependencies
...
app:template                       Apply the template supplied by LOCATION=(/path/to/template) or URL
...
credentials:diff                   Enrolls/disenrolls in decrypted diffs of credentials using git
credentials:edit                   Opens the decrypted credentials in `$EDITOR` for editing
credentials:show                   Shows the decrypted credentials
db:create                          Create the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use ...
db:drop                            Drop the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db...
...
db:fixtures:load                   Load fixtures into the current environment's database
db:migrate                         Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
db:migrate:down                    Run the "down" for a given migration VERSION
db:migrate:redo                    Roll back the database one migration and re-migrate up (options: STEP=x, VERSION=x)
db:migrate:status                  Display status of migrations
db:migrate:up                      Run the "up" for a given migration VERSION
db:prepare                         Run setup if database does not exist, or run migrations if it does
db:reset                           Drop and recreate all databases from their schema for the current environment and load the s...
db:rollback                        Roll the schema back to the previous version (specify steps w/ STEP=n)
db:schema:cache:clear              Clear a db/schema_cache.yml file
db:schema:cache:dump               Create a db/schema_cache.yml file
db:schema:dump                     Create a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['S...
db:schema:load                     Load a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SCH...
db:seed                            Load the seed data from db/seeds.rb
db:seed:replant                    Truncate tables of each database for current environment and load the seeds
db:setup                           Create all databases, load all schemas, and initialize with the seed data (use db:reset to a...
db:system:change                   Change `config/database.yml` and your database gem to the target database
db:version                         Retrieve the current schema version number
destroy                            Remove code generated by `bin/rails generate`
dev:cache                          Toggle development mode caching on/off
encrypted:edit                     Open the decrypted file in `$EDITOR` for editing
encrypted:show                     Show the decrypted contents of the file
...
log:clear                          Truncate all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test...
middleware                         Print out your Rack middleware stack
notes                              Show comments in your code annotated with FIXME, OPTIMIZE, and TODO
...
routes                             List all the defined routes
runner                             Run Ruby code in the context of your application
...
secrets:edit                       Open the secrets in `$EDITOR` for editing
secrets:show                       Show the decrypted secrets
...
tmp:create                         Create tmp directories for cache, sockets, and pids
version                            Show the Rails version
...
zeitwerk:check                     Check project structure for Zeitwerk compatibility
```

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-02-01 22:43:04 +01:00
George Claghorn
4914529180
Revert "Add nodoc to Mail module [ci-skip]" 2023-01-28 16:57:04 -05: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
Petrik de Heus
c20998c00d
Revert "Remove changelog entry for bugfix [#46300]" 2023-01-22 14:49:24 +01:00
zzak
b8bc9ec9c2 Remove changelog entry for bugfix [#46300]
We usually only put features / major changes in the changelog

ref: https://github.com/rails/rails/pull/46879#issuecomment-1375676523
2023-01-21 10:24:09 +09: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
Jean Boussier
47f21c5aea
Merge pull request #46993 from skipkayhil/fix-actionmailbox-requires
Fix missing requires in Action Mailbox
2023-01-19 17:00:51 +01:00
Yasuo Honda
07d32aada7 Add rake test:isolated for Action Mailbox
This commit adds isolated test for Action Mailbox
```
$ cd actionmailbox
$ bundle exec rake test:isolated
```
2023-01-16 14:38:17 +09:00
Hartley McGuire
2e920b0097
Fix missing requires in Action Mailbox
Previously, trying to `require "action_mailbox"` would fail if Active
Support was not previously required.

This fixes requiring Action Mailbox by adding the standard
"active_support" and "active_support/rails" requires. In addition, this
files uses `30.days` and so it needs to require core_ext/numeric/time as
well.
2023-01-12 20:20:06 -05:00
Jonathan Hefner
6225b5f59f Load version.rb for Action Mailbox and Action Text
This matches the other frameworks, ensuring that `ActionMailbox.version`
and `ActionText.version` are available when using Action Mailbox and
Action Text, respectively.

__Before__

  ```console
  $ bin/rails runner 'puts ActiveRecord.version'
  7.1.0.alpha

  $ bin/rails runner 'puts ActionMailbox.version'
  undefined method `version' for ActionMailbox:Module

  $ bin/rails runner 'puts ActionText.version'
  undefined method `version' for ActionText:Module
  ```

__After__

  ```console
  $ bin/rails runner 'puts ActiveRecord.version'
  7.1.0.alpha

  $ bin/rails runner 'puts ActionMailbox.version'
  7.1.0.alpha

  $ bin/rails runner 'puts ActionText.version'
  7.1.0.alpha
  ```
2023-01-12 17:34:49 -06:00
Ghouse Mohamed
e0559d2c1c Change 2022 -> 2023 2023-01-03 13:22:00 +05:30
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
Akira Matsuda
e28e2f784e
Ignore local .sqlite3 files that are created under storage directory
Follows up d18fc329993df5a583ef721330cffb248ef9a213
2022-12-27 11:35:26 +09:00
Eileen M. Uchitelle
c8c7a5d492
Merge pull request #46723 from okuramasafumi/nodoc-mail
Add nodoc to `Mail` module [ci-skip]
2022-12-14 09:01:51 -05:00
OKURA Masafumi
a7a5f464cd Add nodoc to Mail module [ci-skip]
`Mail` gem is an external gem and all methods extended by Rails
are undocumented. However it's listed in API document page.
It serves no purposes so it should be removed.
2022-12-14 19:02:19 +09: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
Alex Ghiculescu
9e443a861a Fix CI for Mail 2.8+
CI is broken since https://github.com/mikel/mail/pull/1120, which is in the new `mail` release.

Example: https://buildkite.com/rails/rails/builds/91421#0184e03b-58dc-43f9-aa40-55949848dc67

This commit fixes it. The `adddress_list` method was renamed.
2022-12-04 21:48:54 -06:00
Étienne Barrié
3d6a7b2faa Initialize deprecators before configuring them
Since engine initializers run later in the process, we need to run this
initializer earlier than the default.

This ensures they're all registered before the environments are loaded.
2022-11-28 10:47:26 +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
Jonathan Hefner
f434310b3b Add ActionMailbox.deprecator
This commit adds `ActionMailbox.deprecator`, and adds it to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
2022-11-01 17:39:39 -05: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
Gannon McGibbon
6be4bdc6cf Improve mailbox generator usage docs
- Makes heading styles consistent with other generators
- Adds backticks to code snippets
2022-06-21 00:30:49 -05:00
Jonathan Hefner
5f08722c40
Merge pull request #45206 from jonathanhefner/puma-config-omit-workers-and-preload_app
Omit `workers` and `preload_app!` from Puma config
2022-06-03 17:12:36 -05: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
Nate Matykiewicz
c9e48feef2
Remove 4 unroutable routes from ActionMailbox
I was auditing which routes in my app do not actually a
have corresponding controller action. ActionMailbox's
inbound_mails has these 4 routes defined, which do not
actually work.

GET /rails/conductor/action_mailbox/inbound_emails/:id/edit
PATCH /rails/conductor/action_mailbox/inbound_emails/:id
PUT /rails/conductor/action_mailbox/inbound_emails/:id
DELETE /rails/conductor/action_mailbox/inbound_emails/:id
2022-05-31 15:38:45 -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
Rafael Mendonça França
5c1bd20f0d
Merge pull request #44693 from ghousemohamed/fix-docs-related-gem-versions
Fix `#version` method docs and some typos [ci-skip]
2022-03-15 16:28:07 -04:00
Ghouse Mohamed
6ee6cb554b Fix #version docs and some typos 2022-03-16 01:48:37 +05:30
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
Brad Trick
880a1bedb9 Allow skip_forgery_protection if no protection set
Calling `skip_forgery_protection` without first calling
`protect_from_forgery`--either manually or through default
settings--raises an `ArgumentError` because `verify_authenticity_token`
has not been defined as a callback.

Since Rails 7.0 adds `skip_forgery_protection` to the
`Rails::WelcomeController` (PR #42864), this behavior means that setting
`default_protect_from_forgery` to false and visiting the Rails Welcome
page (`/`) raises an error.

This behavior also created an issue for `ActionMailbox` that was
previously fixed in the Mailbox controller by running
`skip_forgery_protection` only if `default_protect_from_forgery` was
true (PR #35935).

This PR addresses the underlying issue by setting the `raise` option for
`skip_before_action` to default to false inside
`skip_forgery_protection`.

The fix is implemented in `request_forgery_protection.rb`. The change to
`ActionMailbox`'s `base_controller.rb` removes the now-unnecessary
check of `default_protect_from_forgery`.

The tests added in `request_forgery_protection_test.rb` and
`routing_test.rb` both raise an error when run against the current
codebase and pass with the changes noted above.
2022-02-27 21:58:42 -05:00