Commit Graph

4160 Commits

Author SHA1 Message Date
Rafael França
3cf6378a5b
Merge pull request #41584 from jonathanhefner/route-action-reuse-existing-namespace
Inject route with namespace into existing blocks
2021-05-06 13:44:34 -04:00
John Bampton
6e85b6b86e Add spell checking with codespell as a GitHub Action
`codespell` works with a small custom dictionary and seems to find perhaps more spelling mistakes than `misspell` which really only fixes commonly misspelled English words.

Not all spell checkers can check all file types and most spell checkers can't find all the errors.

https://github.com/codespell-project/codespell
https://pypi.org/project/codespell/
2021-05-04 14:46:21 +10:00
Ashik Salman
68a9d6367e Used double quotes in template file for consistency. 2021-04-30 02:58:51 +05:30
Rafael Mendonça França
52db7f2ef3
Configure a default timeout for the smtp delivery method
The default is set to 5 and only applied for new applications or
applications that opt-in for this new default.

Closes #42089.

[André Luis Leal Cardoso Junior + Rafael Mendonça França]
2021-04-28 03:59:19 +00:00
Jean Boussier
487ff1330c
Merge pull request #42008 from iridakos/bugs/42007-runner-file-load
Expand path of user provided file in runner
2021-04-22 20:21:29 +02:00
Gannon McGibbon
cc557db0e2 Allow loading nested locales in engines 2021-04-21 17:45:09 -04:00
Jean Boussier
3fe0ab52df Ensure Rails.application.config_for always cast hashes to ActiveSupport::OrderedOptions.
Fix: #42037
2021-04-21 17:32:42 +02:00
Lazarus Lazaridis
896733c2e3 Add tests for rails runner
* Refs #42007
2021-04-18 13:58:02 +03:00
Ricardo Díaz
cbec080dc4 Allow test parallelization with processes to fail fast
Running tests in parallel with processes wasn't failing fast when the
option was enabled. The problem was that even when the reporter raised
the `Interrupt` exception, the queue was not emptied, so workers keep
processing jobs as if nothing happened.

This patch basically intercepts the `Interrupt` exception that may
come from the reporter, and tells the server to clear the jobs queue,
so that it can continue the shutdown process as usual. The exception
must then continue its journey so that the backtrace is displayed.
2021-04-16 19:23:57 -05:00
John Bampton
7260f79d7a chore: fix grammar and spelling in Markdown and Ruby files 2021-04-15 19:32:27 +10:00
Rafael França
3541f05103
Merge pull request #41923 from jbampton/fix-spelling
chore: fix spelling in railties/test/generators
2021-04-13 11:37:07 -04:00
Hartley McGuire
7bfcf4b313 Remove Rack::Runtime and deprecate referencing it
Previous discussion: #38412, #38325, 37423e4, 24f9c03

- Rack::Runtime is replaced by FakeRuntime, which is a dummy middleware
  that just passes requests on and cannot be used in middleware operations
- Using Rack::Runtime in middleware operations (relative inserts, moves,
  etc.) throws a deprecation warning and uses FakeRuntime instead
- if an application adds Rack::Runtime explicitly (use, unshift, etc.),
  then the deprecation warning does not happen and FakeRuntime is
  ignored
- docs are updated to no longer reference Rack::Runtime
2021-04-12 14:31:12 -04:00
John Bampton
8d383382b9 chore: fix spelling in railties/test/generators 2021-04-12 09:24:57 +10:00
John Bampton
13b1d9dc35 chore: fix grammar and spelling 2021-04-12 05:30:44 +10:00
Jonathan Hefner
ddcfde2226 Populate ARGV with Rails::Command.invoke args
Follow-up to #38495.

Similar to #40994, but for all Rails commands.  Programmatic and CLI
invocations of Rails commands will still behave identically, and `ARGV`
will still be isolated between invocations.

Reverts #40994.
2021-04-03 10:12:52 -05:00
Ricardo Díaz
1d50a37a6f Don't override ActiveSupport::TestCase.test_order
Seemingly some test suites depend on this

Updated tests to verify the change to the parallelization flag instead
2021-03-31 15:21:54 -04:00
Lee Quarella
65f350166a Remove overwriting test_order
Reverts a change from
2327ebfdc6
which can overwrite `test_order` that may have been manually set in
config. This can cause a situation where the user is depending on a
particular `test_order` but is unknowingly forced into another.
2021-03-31 11:50:08 -04:00
Rafael França
6675f6b785
Merge pull request #41255 from euxx/fix-create-migration-generator-with-pretend-option
Fix create migration generator with `--pretend` option
2021-03-29 22:27:34 -04:00
Rafael França
7702ce8243
Merge pull request #40789 from csutter/deprecate-remote-ip-single-value
Deprecate assigning single `trusted_proxies` value
2021-03-24 02:27:57 -04:00
Eileen M. Uchitelle
ad9e52066c
Merge pull request #41684 from ricardotk002/disable-parallel-testing
Disable parallel testing when running individual files
2021-03-23 09:06:57 -04:00
Henrik Nyh
c13fee85ba More consistent quotes in template files 2021-03-22 22:07:27 +00:00
Ricardo Díaz
2327ebfdc6 Disable parallel testing when running individual files
Setting up the parallel workers could be an overhead when running
individual files.

This patch disables that process in case the number of files to run
is less than one.

Results running a sample file:

Before:

```
actionpack $ bin/test test/controller/parameters/accessors_test.rb
Run options: --seed 48261

........................................................................

Finished in 0.211923s, 339.7460 runs/s, 552.0873 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```

After

```
actionpack $ bin/test test/controller/parameters/accessors_test.rb

Run options: --seed 5461

........................................................................

Finished in 0.008411s, 8560.2189 runs/s, 13910.3557 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```
2021-03-18 02:06:42 -05:00
Debbie Milburn
03aa08526a
Merge branch 'main' into add-rails-development-hosts-env-variable 2021-03-09 11:59:11 -05:00
Xavier Noria
dc7817cb42 Deletes logging from AS::Dependencies 2021-03-09 10:02:03 +01:00
Gannon McGibbon
bf57e7ff9d Add app concern and test keepfiles to generated engine plugins 2021-03-09 00:04:29 -05:00
Xavier Noria
0d523d8365 Drops support for classic mode
This starts a series of patches in which we drop classic mode. The final
result no longer has a const_missing callback, there is no hook/unhook,
and so on.

So, in this patch we remove the ability of configuring classic, but some
of the code that remains will be further refactored.
2021-03-08 05:30:11 +01:00
Jonathan Hefner
7762770805
Use stable branch for --edge option when possible
This alleviates the need to update the code when there is a new stable
branch (for example, as done in #41454).
2021-03-07 17:45:37 -05:00
Xavier Noria
c431432f93 Add app/{helpers,models} to autoload_once_paths
The helpers of Action Text are added to a couple of non-reloadable
base classes:

  initializer "action_text.helper" do
    %i[action_controller_base action_mailer].each do |abstract_controller|
      ActiveSupport.on_load(abstract_controller) do
        helper ActionText::Engine.helpers
      end
    end
  end

Therefore, it does not make sense that they are reloadable themselves.

For the same price, we can also make the models non-reloadable, thus
saving parent applications from the unnecessary work of reloading this
engine.

We did this for turbo-rails as well.
2021-03-07 23:05:24 +01:00
John Bampton
abcb5f5050 chore: fix spelling 2021-03-07 18:09:45 +10:00
Xavier Noria
ec4e71e49a
Merge pull request #41564 from gmcgibbon/remove_require_dependency_in_templates
Remove require_dependency from controller templates
2021-03-05 23:39:17 +01:00
Mark VanLandingham
bece535c98
Add config.action_text.attachment_tag_name 2021-03-05 16:57:36 -05:00
Debbie Milburn
8c50571808 Add RAILS_DEVELOPMENT_HOSTS to allow adding authorized hosts for development
Co-authored-by: Josh Abernathy <joshaber@gmail.com>

Update railties/CHANGELOG.md

Co-authored-by: Gannon McGibbon <gannon@hey.com>

Update railties/lib/rails/application/configuration.rb

Co-authored-by: Gannon McGibbon <gannon@hey.com>

Use yield block to safely alter env variables

Remove trailing whitespace

Update railties/CHANGELOG.md wording

Co-authored-by: Marivaldo Cavalheiro <marivaldo@gmail.com>

Have comma separated list ignore spaces

Add missing comma
2021-03-05 14:03:37 -05:00
Jonathan Hefner
106e20d481 Inject route with namespace into existing blocks
This allows successive invocations of the `route` generator action to
re-use existing `namespace` blocks.
2021-03-01 13:09:41 -06:00
Gannon McGibbon
9790ae9567 Stop generating a license for in-app plugins 2021-03-01 13:38:39 -05:00
Gannon McGibbon
38715aaf9b Remove require_dependency from controller templates 2021-03-01 13:15:04 -05:00
Henrik Nyh
14ff158e73
plugin_generator_test.rb: Extract with_simulated_app
Makes tests reads clearer by hiding details.
2021-02-27 20:24:53 -05:00
Josh Goodall
715d6bc4d0 test case to illustrate isolated engine inheritance issue 2021-02-16 11:55:22 -08:00
Nick Borromeo
0f09dfca36
Guard against using VERSION with db:rollback (#41430)
* Guard against using VERSION with db:rollback

I recently ran a migration that I needed to rollback, and admittedly, I often forget the proper incantation for this 😅
so the first thing I tried was to run `bin/rake db:rollback VERSION=123454679`. I had hoped that this reverted my
migration back and at first glance I thought it worked. However on closer inspection I realized that it was a different
migration, which initially confused me.

So I looked over the docs and saw that I was using the rake task incorrectly, and promptly corrected my mistake.

Proposal

Looking at the how the `:down` task is defined we see

8dc7439058/activerecord/lib/active_record/railties/databases.rake (L206-L211)

This got me thinking that maybe it would be helpful to have the opposite of this guard defined in `rollback` so that if
`VERSION` is passed it will raise an exception instead of just negecting the extra argument. This could help the user
realize that something went wrong instead of just seeing output and assuming that the rollback happened.

Change

We now raise an execption if `VERSION` is passed when attempting to rollback a migration

* update test name and fix failing test

* remove byebug

[Nick Borromeo + Kate Travers + Rafael Mendonça França]
2021-02-15 19:30:05 -05:00
Jonathan Hefner
a21ebfa1c9 Refactor CVE-2021-22881 fix
Follow-up to 83a6ac3fee8fd538ce7e0088913ff54f0f9bcb6f.

This allows `HTTP_HOST` to be omitted as before, and reduces the number
of object allocations per request.

Benchmark:

```ruby
 # frozen_string_literal: true
require "benchmark/memory"

HOST = "example.com:80"
BEFORE_REGEXP = /\A(?<host>[a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])(:\d+)?\z/
AFTER_REGEXP = /(?:\A|,[ ]?)([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])(?::\d+)?\z/i

Benchmark.memory do |x|
  x.report("BEFORE (non-nil X-Forwarded-Host)") do
    origin_host = BEFORE_REGEXP.match(HOST.to_s.downcase)[:host]
    forwarded_host = BEFORE_REGEXP.match(HOST.to_s.split(/,\s?/).last)[:host]
  end

  x.report("BEFORE (nil X-Forwarded-Host)") do
    origin_host = BEFORE_REGEXP.match(HOST.to_s.downcase)[:host]
    forwarded_host = BEFORE_REGEXP.match(nil.to_s.split(/,\s?/).last)
  end

  x.report("AFTER (non-nil X-Forwarded-Host)") do
    origin_host = HOST&.slice(AFTER_REGEXP, 1) || ""
    forwarded_host = HOST&.slice(AFTER_REGEXP, 1) || ""
  end

  x.report("AFTER (nil X-Forwarded-Host)") do
    origin_host = HOST&.slice(AFTER_REGEXP, 1) || ""
    forwarded_host = nil&.slice(AFTER_REGEXP, 1) || ""
  end
end
```

Results:

```
BEFORE (non-nil X-Forwarded-Host)
                       616.000  memsize (   208.000  retained)
                         9.000  objects (     2.000  retained)
                         2.000  strings (     1.000  retained)
BEFORE (nil X-Forwarded-Host)
                       328.000  memsize (     0.000  retained)
                         5.000  objects (     0.000  retained)
                         2.000  strings (     0.000  retained)
AFTER (non-nil X-Forwarded-Host)
                       248.000  memsize (   168.000  retained)
                         3.000  objects (     1.000  retained)
                         1.000  strings (     0.000  retained)
AFTER (nil X-Forwarded-Host)
                        40.000  memsize (     0.000  retained)
                         1.000  objects (     0.000  retained)
                         1.000  strings (     0.000  retained)
```
2021-02-13 12:03:23 -06:00
Rafael França
3b9a877c69
Merge pull request #41399 from jonathanhefner/always-overwrite-bin-yarn
Overwrite bin/yarn when running app:binstub:yarn
2021-02-10 19:08:29 -05:00
Rafael Mendonça França
a6a121163c
Remove unnessary escape char in Regexp
Fix the test by defining a valid host on the mocked requests.
2021-02-10 22:59:17 +00:00
Jonathan Hefner
6e78549d2c Overwrite bin/yarn when running app:binstub:yarn
This ensures that commands which delegate to `app:binstub:yarn`, such as
`action_text:install`, will update `bin/yarn`.
2021-02-10 15:41:03 -06:00
Rafael França
de630cdac8
Merge pull request #41104 from f6p/skip-spring-when-locked-gems-empty
Prevent webpacker:install failures on missing Gemfile
2021-02-10 14:19:43 -05:00
Eileen M. Uchitelle
a27567596b
Merge pull request #41349 from eileencodes/add-primary_abstract_class-to-generator
Set `ApplicationRecord` to `primary_abstract_class`
2021-02-10 10:42:44 -05:00
Filip Pyda
5f92756977 Don't install webpacker if --skip-bundle or --skip-gemfile was given 2021-02-10 07:52:25 +01:00
eileencodes
1aa8190c66
Set ApplicationRecord to primary_abstract_class
Followup on https://github.com/rails/rails/pull/41258#discussion_r570441592

This makes sure that newly generated applications get their
`ApplicationRecord` set to `primary_abstract_class`. Existing applications
can opt-in to this if they're using multiple databases or have changed
their `ApplicationRecord` to a class with a different name.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2021-02-05 17:02:08 -05:00
Rafael França
abff811725
Merge pull request #40254 from prateekkish/default-main
Change default branch for new Rails projects and plugins to main
2021-02-05 15:23:40 -05:00
Ryuta Kamizono
7dd4dde53d Remove all version checking for older Rubies in tests
Code cleanup for tests.
2021-02-05 13:21:45 +09:00
Ryuta Kamizono
2e9c0e04c5 Update TargetRubyVersion to 2.7 in .rubocop.yml 2021-02-05 12:23:33 +09:00
eileencodes
0502346264
Fix Railties tests for 7.0
As of 1b455e2e9d Rails main is Rails 7.0 and not 6.2 so we need to
update the tests accordingly
2021-02-04 12:56:48 -05:00