Commit Graph

12711 Commits

Author SHA1 Message Date
Arun Agrawal
50e3680768 Bump license years for 2019 2018-12-31 10:24:38 +07:00
George Claghorn
e7bcbf7b29
Add Rake task for testing mailboxes 2018-12-30 16:17:16 -05:00
George Claghorn
7c4457447e Don't load Action Mailbox when Active Storage is skipped 2018-12-29 07:24:56 -05:00
yuuji.yaginuma
fb173b6613 Do not show suggestion message when not exist suggestion
**before**

```
$ ./bin/rails g g
Could not find generator 'g'. Maybe you meant nil?
Run `rails generate --help` for more options.
```

**after**

```
$ ./bin/rails g g
Could not find generator 'g'.
Run `rails generate --help` for more options.
```
2018-12-29 18:57:55 +09:00
bogdanvlviv
e306c8c4d4
Ensure that the app generator skips action mailbox when --skip-active-record is given
Related to https://github.com/rails/rails/pull/34816#issuecomment-450378366
Follow up ddaf06779a
2018-12-28 19:32:53 +02:00
George Claghorn
ddaf06779a Don't load Action Mailbox when Active Record is skipped 2018-12-28 00:48:52 -05:00
George Claghorn
fb69964187 Load Action Mailbox when other components are skipped 2018-12-28 00:31:43 -05:00
George Claghorn
11a8ba1272 Generate Action Mailbox's API docs 2018-12-26 15:53:49 -05:00
George Claghorn
a5b2fff64c Import Action Mailbox 2018-12-25 21:32:35 -05:00
Yasuo Honda
05781f1f9c No need to handle if FrozenError is available
Rails 6 requires Ruby 2.5, which introduces `FrozenError`
https://docs.ruby-lang.org/en/2.5.0/NEWS.html

Related to #31520
2018-12-23 13:26:20 +00:00
Eileen Uchitelle
555c1a3a54 Fix app boot for Ruby 2.4
I have a test app that was on Ruby 2.4. When I pulled Rails master the
app no longer would boot because of this change and I saw the following
error:

```
SyntaxError:
/Users/eileencodes/open_source/real_rails/railties/lib/rails/all.rb:18:
syntax error, unexpected keyword_rescue, expecting keyword_end
rescue LoadError
      ^
```

Ruby 2.4 doesn't support removing redundant begins so the real issue is
that this app is on Ruby 2.4 and not on Ruby 2.5. But it's super
confusing for a user to understand the reason the app is failing to boot
is because we need Ruby 2.5.

I added this redundant begin back because we need to give a clearer
error message.
2018-12-21 12:24:40 -05:00
Ryuta Kamizono
892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00
Ryuta Kamizono
d5699198a4 Module#{attr,attr_accessor,attr_reader,attr_writer} become public since Ruby 2.5
https://bugs.ruby-lang.org/issues/14132
2018-12-21 02:05:27 +09:00
Ryuta Kamizono
8034dde023 Module#{define_method,alias_method,undef_method,remove_method} become public since Ruby 2.5
https://bugs.ruby-lang.org/issues/14133
2018-12-21 01:39:18 +09:00
Kasper Timm Hansen
1b7c3222e8
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034

* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
2018-12-19 21:47:50 +01:00
Kasper Timm Hansen
abae9d0e0a
Clarify implicit meaning of 'workers: 2' in parallelization tests. 2018-12-19 17:19:28 +01:00
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