Commit Graph

12695 Commits

Author SHA1 Message Date
Bogdan
e9f6ce617b Add option to set parallel test worker count to the physical core count of the machine (#34735)
* Add option to set parallel test worker count to the physical core count of the machine

Also, use the physical core count of the machine as
the default number of workers, and  generate the `test_helper.rb` file
with `parallelize(workers: :number_of_processors)`

Closes #34734

* Ensure that we always test parallel testing

Since #34734 we decided to use the physical core count of the machine as
the default number of workers in the parallel testing, we need to
ensure that some tests use at least 2 workers because we could
run those tests on VM that has only 1 physical core.
It also fixes tests failures on the CI since Travis server we are using
has only one physical core.
See https://travis-ci.org/rails/rails/jobs/469281088#L2352
2018-12-18 10:25:35 -08:00
Genadi Samokovarov
07ec8062e6 Introduce a guard against DNS rebinding attacks
The ActionDispatch::HostAuthorization is a new middleware that prevent
against DNS rebinding and other Host header attacks. By default it is
included only in the development environment with the following
configuration:

    Rails.application.config.hosts = [
      IPAddr.new("0.0.0.0/0"), # All IPv4 addresses.
      IPAddr.new("::/0"),      # All IPv6 addresses.
      "localhost"              # The localhost reserved domain.
    ]

In other environments, `Rails.application.config.hosts` is empty and no
Host header checks will be done. If you want to guard against header
attacks on production, you have to manually permit the allowed hosts
with:

    Rails.application.config.hosts << "product.com"

The host of a request is checked against the hosts entries with the case
operator (#===), which lets hosts support entries of type RegExp,
Proc and IPAddr to name a few. Here is an example with a regexp.

    # Allow requests from subdomains like `www.product.com` and
    # `beta1.product.com`.
    Rails.application.config.hosts << /.*\.product\.com/

A special case is supported that allows you to permit all sub-domains:

    # Allow requests from subdomains like `www.product.com` and
    # `beta1.product.com`.
    Rails.application.config.hosts << ".product.com"
2018-12-15 20:18:51 +02:00
Akira Matsuda
d57841b5c4 Ruby can show a little bit more detailed info in shorter code
This follows up adb0c7bc5116e0f6020a4ec32b7e19ea8b26f1ec
2018-12-15 13:21:58 +09:00
ujihisa
adb0c7bc51 http://localhost:3000/rails/info/properties shows more details for ease of bug reporting
Hand-merging @ujihisa's ancient patch at https://lighthouseapp.com/projects/8994/tickets/3644
2018-12-14 17:59:51 +09:00
Rafael Mendonça França
08e7b369bf
Do not show post install message on rails new 2018-12-13 20:14:19 -05:00
yuuji.yaginuma
d0bb649cbf Use string for arguments in server test
When actually execute from the command, the value of ARGV is passed to the
server. So they are String. So let's use the same type in the test.

Also, this removes the following warning in Ruby 2.6.

```
lib/rails/commands/server/server_command.rb:195: warning: deprecated Object#=~ is called on Integer; it always returns nil
```
2018-12-13 16:15:58 +09:00
Ryuta Kamizono
2c325182b8 Fix warning: shadowing outer local variable - attribute 2018-12-13 06:43:31 +09:00
Ryuta Kamizono
8fcaf3c26c Merge pull request #34691 from gmcgibbon/rm_helper_generator_suffix
Remove redundant suffixes on generated helpers.
2018-12-13 02:57:00 +09:00
Gannon McGibbon
886ac1c308 Remove redundant suffixes on generated helpers. 2018-12-12 12:22:59 -05:00
Gannon McGibbon
9bf5545ef7 Remove redundant suffixes on generated integration tests. 2018-12-12 12:12:51 -05:00
Gannon McGibbon
ea89b4588b Fix boolean interaction in scaffold system tests 2018-12-12 10:56:25 -05:00
Gannon McGibbon
b93fc47c72 Remove redundant suffixes on generated system tests. 2018-12-11 18:09:16 -05:00
Vinicius Stock
3b7a4d3d75
Upgrade Rubocop to 0.61.1 and fix offenses 2018-12-10 19:22:56 -02:00
yuuji.yaginuma
bad1041b82 Add test for reads environment credential file with environment variable key 2018-12-09 15:00:01 +09:00
David Rodríguez
f173ec77fc Abort early if generator command fails (#34420)
* No need to go through ruby

* Abort early if a generator command fails

* Reuse `rails_command` method

* Bump thor minimum dependency to 0.20.3

* Add some minimal docs

* Add a changelog entry

* Restore original logging
2018-12-07 15:01:32 +09:00
Rafael Mendonça França
884310fdd0
Improve deprecation message for enqueue returning false
And make sure new applications in Rails 6.0 has this config enabled.

Also, improve test coverage and add a CHANGELOG entry.
2018-12-05 13:52:44 -05:00
Rafael França
299a213a73
Merge pull request #33992 from kirs/enqueue-return-false
Make AJ::Base#enqueue return false if the job wasn't enqueued
2018-12-05 11:24:19 -05:00
Rafael França
25c076117c
Merge pull request #33882 from mberlanda/mberlanda/as-inheritable-options-intialization
[Realties] config_for as ActiveSupport::OrderedOptions
2018-11-30 11:42:44 -05:00
Yasuo Honda
6fb128d144 Bump the minimum version of PostgreSQL to 9.3
https://www.postgresql.org/support/versioning/

- 9.1 EOLed on September 2016.
- 9.2 EOLed on September 2017.

9.3 is also not supported since Nov 8, 2018.  https://www.postgresql.org/about/news/1905/
I think it may be a little bit early to drop PostgreSQL 9.3 yet.

* Deprecated `supports_ranges?` since no other databases support range data type

* Add `supports_materialized_views?` to abstract adapter
Materialized views itself is supported by other databases, other connection adapters may support them

* Remove `with_manual_interventions`
It was only necessary for PostgreSQL 9.1 or earlier

* Drop CI against PostgreSQL 9.2
2018-11-25 13:13:08 +00:00
yuuji.yaginuma
6d854f9d07 Compile packs before run test
Sometimes `test_scaffold_tests_pass_by_default` test fails in CI.
https://travis-ci.org/rails/rails/jobs/457621750#L2095-L2120
It seems `manifest.json` was broken.

`webpacker` will compile automatically if packs is not compiled.
If parallel test is enabled, it seems that this compilation process is
executed simultaneously in multiple processes, and it may become an
inconsistent state.
In order to avoid this, compile before running the test.
2018-11-22 18:20:28 +09:00
Alberto Almagro
f553be8908 Homogenize rails help output
In commit 6567464bedd1e39ee7390da9484ba0caa7eb3e07 we homogenized rails
commands with former rake tasks. We decided to display all commands at
the same level and merged the list of commands displayed by `rails help`.

We however forgot to actually merge the output in the command itself.
This commit fixes that.
2018-11-19 22:48:51 +01:00
Eileen M. Uchitelle
9893998f4a
Merge pull request #34410 from gmcgibbon/test_support_windows
Windows support for parallelization and instrumenter
2018-11-19 09:35:55 -08:00
Eileen M. Uchitelle
317bf45c24
Merge pull request #34476 from y-yagi/fix_no_method_error_in_parallelization
Correctly handle unknown object in parallel tests
2018-11-19 09:34:51 -08:00
yuuji.yaginuma
218e50ce59 Fix test name to match the test behavior
These tests are for testing the `rake` method.
2018-11-18 09:46:41 +09:00
yuuji.yaginuma
90266a7f1e Correctly handle unknown object in parallel tests
DRb wraps in `DRbUnknown` if the data contains a type that can not be
resolved locally. This can happen if an error occurs in the test and the
error class can not be resolved on the server side.

When this happens, an instance of `DRbUnknown` is passed to the `result`
of `Server#record`. This causes another error(undefined method assertions
for #<DRb::DRbUnknown:> (NoMethodError)) in `reporter.record`.
This can confirm by the following steps.

```
$ rails new app -B --dev; cd app
$ rails g scaffold user name:string
$ edit `config.action_controller.allow_forgery_protection = true` in environments/test.rb
$ bin/rails t
```

In the case of `DRbUnknown` occurs, can't resolve error exception. So wrap
exception with `DRbRemoteError` in the same way as an unmarshalled object.
2018-11-17 13:56:51 +09:00
Nihad Abbasov
667274edac
Fix a method call in bin/setup file
Follow up to a725539de677adbea0ced19d65647e975dbd3f84
2018-11-15 18:17:35 +04:00
Rafael França
0b75743e34
Merge pull request #34400 from gmcgibbon/rm_autoload_app_javascripts
Remove asset paths from autoload_paths
2018-11-13 17:53:55 -05:00
Rafael França
6741e70518
Merge pull request #34411 from N0xFF/master
Reset Capybara sessions if failed system test screenshot raising an exception
2018-11-13 17:21:04 -05:00
Alessandro Rodi
0d90d1e019 add a nice alias for the --webpack option 2018-11-13 16:06:42 +01:00
Yasuo Honda
8ac8396259 Ignore warnings such as Psych.safe_load is deprecated
Addressing warnings are important but it should be out of this test scope.

https://travis-ci.org/rails/rails/jobs/454145524#L4122-L4131

```
.F
Failure:
ApplicationTests::BinSetupTest#test_bin_setup_output [test/application/bin_setup_test.rb:49]:
--- expected
+++ actual
@@ -1,4 +1,5 @@
 "== Installing dependencies ==
+warning: Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.
 The Gemfile's dependencies are satisfied

 == Preparing database ==
rails test test/application/bin_setup_test.rb:38
```
2018-11-13 11:19:03 +00:00
Maxim Perepelitsa
59895db44b Reset sessions on failed system test screenshot
Reset Capybara sessions if `take_failed_screenshot` raise exception
in system test `after_teardown`.
2018-11-13 03:30:41 +07:00
Gannon McGibbon
cffbf73a47 Remove asset paths from eager_load_paths and autoload_paths
Remove `app/assets` and `app/javascript` from `eager_load_paths`
and `autoload_paths`.
2018-11-09 14:48:15 -05:00
yuuji.yaginuma
9bd5fc84cc Add test for parallel tests with unmarshable exception
Follow up #34131.
2018-11-09 18:25:26 +09:00
Gannon McGibbon
0712dfd6ae Windows support for parallelization and instrumenter
Add Windows support for `ActiveSupport::Testing::Parallelization`
and `ActiveSupport::Notifications::Instrumenter`.
2018-11-08 12:07:21 -05:00
bogdanvlviv
a444bae3f2
Remove unused argument expected_database
This argument was added in fa5a028ed9f, and #34137 but hasn't been used.
2018-11-08 16:12:34 +02:00
yuuji.yaginuma
7f7e7e8b39 Compile packs for test
`Webpacker` handles testing / development packs separately by default.
If do not specify `RAILS_ENV`, there is no merit to precompile.
2018-11-08 12:21:25 +09:00
Gannon McGibbon
ac18bda92d Add multi-db support to schema cache dump and clear
Adds support for multiple databases to `rails db:schema:cache:dump`
and `rails db:schema:cache:clear`.
2018-11-07 14:11:46 -05:00
Ryuta Kamizono
8eaffe7e89
Merge pull request #34387 from yhirano55/rails_info_properties_json
Respond /rails/info/properties.json
2018-11-07 19:23:54 +09:00
Rafael França
133e0ba33d
Merge pull request #34392 from gmcgibbon/gem_security_note_amend
Amend CVE note and security guide section wordings
2018-11-06 18:23:29 -05:00
Yoshiyuki Hirano
b6e4305c3b Add JSON support to rails properties route (/rails/info/properties).
Added json format, like this:

    {
      "Rails version": "6.0.0.alpha",
      "Ruby version": "2.5.1-p57 (x86_64-darwin17)",
      "RubyGems version": "2.7.6",
      "Rack version": "2.0.6",
      "JavaScript Runtime": "Node.js (V8)",
      "Middleware": ["Rack::Sendfile", "ActionDispatch::Static", "ActionDispatch::Executor", "ActiveSupport::Cache::Strategy::LocalCache::Middleware", "Rack::Runtime", "Rack::MethodOverride", "ActionDispatch::RequestId", "ActionDispatch::RemoteIp", "Sprockets::Rails::QuietAssets", "Rails::Rack::Logger", "ActionDispatch::ShowExceptions", "WebConsole::Middleware", "ActionDispatch::DebugExceptions", "ActionDispatch::Reloader", "ActionDispatch::Callbacks", "ActiveRecord::Migration::CheckPending", "ActionDispatch::Cookies", "ActionDispatch::Session::CookieStore", "ActionDispatch::Flash", "ActionDispatch::ContentSecurityPolicy::Middleware", "Rack::Head", "Rack::ConditionalGet", "Rack::ETag", "Rack::TempfileReaper"],
      "Application root": "/path/to/app",
      "Environment": "development",
      "Database adapter": "sqlite3",
      "Database schema version": 0
    }
2018-11-07 08:14:09 +09:00
Guillermo Iguaran
90ee327b63
Merge pull request #34375 from y-yagi/add_connect_src_to_default_csp_initializer
Add `connect_src` example to content security policy initializer
2018-11-06 18:11:15 -05:00
Gannon McGibbon
e74fdbe00c Amend CVE note and security guide section wordings
Reword first sentence of dep management and CVE section of
security guide. Also, reword and move gemspec notes above deps.

[ci skip]
2018-11-06 18:06:57 -05:00
Gannon McGibbon
1c11688b56 Add CVE note to security guide and gemspecs
[ci skip]
2018-11-06 14:25:36 -05:00
yuuji.yaginuma
fd30a3237c Add connect_src example to content security policy initializer
If want to use `webpack-dev-server` with CSP enabled, need to specify
`connect-src`.
Related to: cd7ecf4d48

This is a matter of `webpacker`. But since `webpacker` is now used by
default, to prevent user confusion, I think that better to include an
example of `connect-src.`
2018-11-04 10:51:39 +09:00
yuuji.yaginuma
caad9e1080 Keep new line after the last dependency
If add a package with `yarn`, it will have a newline after the last
dependency so let's match with that.
2018-11-04 10:00:19 +09:00
Yasuo Honda
639f8fd9e5 Restore encoding: utf8mb4 in database.yml
rails/rails#33853 and rails/rails#33929 removed `encoding: utf8mb4` from database.yml
since at that time MySQL 5.1 is supported with the master branch.

Since MySQL 5.1 has been dropped, we can restore `encoding: utf8mb4` in database.yml
2018-10-30 12:17:48 +00:00
Kir Shatrov
ee9fc12024 Make AJ::Base#enqueue return false if the job wasn't enqueued 2018-10-28 15:02:44 -04:00
Ryuta Kamizono
61490805fe
Merge pull request #34208 from yskkin/inspect_with_parameter_filter
Implement AR#inspect using ParameterFilter
2018-10-26 19:05:34 +09:00
Rafael Mendonça França
8cdb5df7c5
Do not need to mention the method that is being called in the exception
What is important to tell is that the database configuration could not
be loaded.

Fixes #34296.
2018-10-23 18:00:28 -04:00
Rafael França
7bd7241e02
Merge pull request #34275 from bogdanvlviv/skip_yarn-to-skip_javascript
Remove `--skip-yarn` in favor of `--skip-javascript`
2018-10-23 17:25:23 -04:00