Commit Graph

71352 Commits

Author SHA1 Message Date
Kasper Timm Hansen
fb765de0ee
Use class_methods throughout codebase. 2018-12-19 22:51:42 +01: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
78a530282e
[ci skip] Docs: fix spelling, routing setup call and formatting. 2018-12-19 19:01:53 +01:00
Kasper Timm Hansen
83312db72d
Merge pull request #12 from dixpac/add_logger_when_auto_generating_message_id
Added logging when Message ID wasn't extracted
2018-12-19 18:30:10 +01:00
Dino Maric
0298725f02 Added logging when Message ID wasn't extracted 2018-12-19 18:27:19 +01:00
Kasper Timm Hansen
abae9d0e0a
Clarify implicit meaning of 'workers: 2' in parallelization tests. 2018-12-19 17:19:28 +01:00
yuuji.yaginuma
e7a7e174c1 Pass the correct value as JSON
This takes away the following log.

```
Error occurred while parsing request parameters.
Contents:

{:foo=>"heyo"}
```
Pass the correct value as JSON
2018-12-19 12:47:36 +09:00
Ryuta Kamizono
a1652c196e MySQL: ROW_FORMAT=DYNAMIC create table option by default
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the
default row format for InnoDB tables. The default setting is `DYNAMIC`.

The row format is required for indexing on `varchar(255)` with `utf8mb4`
columns.

As long as using MySQL 5.6, CI won't be passed even if MySQL server
setting is properly configured the same as MySQL 5.7
(`innodb_file_per_table = 1`, `innodb_file_format = 'Barracuda'`, and
`innodb_large_prefix = 1`) since InnoDB table is created as the row
format `COMPACT` by default on MySQL 5.6, therefore indexing on string
with `utf8mb4` columns aren't succeeded.

Making `ROW_FORMAT=DYNAMIC` create table option by default for legacy
MySQL version would mitigate the indexing issue on the user side, and it
makes CI would be passed on MySQL 5.6 which is configured properly.
2018-12-19 08:53:16 +09:00
Ryuta Kamizono
0fa5b5510c Use utf8mb4 charset for internal tables if the row format DYNAMIC by default
The indexing issue on `utf8mb4` columns is resolved since MySQL 5.7.9.
2018-12-19 08:38:12 +09:00
Sergey Ponomarev
9c8d4850f1
Add streams assert methods to ActionCable channel test case 2018-12-18 17:37:53 -05:00
Kasper Timm Hansen
5b5319413a
Merge pull request #34739 from sambostock/correct-nested-config-documentation
Single nest config in configuration guides
2018-12-18 22:32:46 +01:00
Sam Bostock
61854ac301
Single nest config in configuration guides
Double nesting of configuration is not supported (without using an
intermediate object), even though the docs suggest it is.

[ci-skip]
2018-12-18 16:29:00 -05:00
Kasper Timm Hansen
849f2b6634
Resurrect installer.
Running `./bin/rails generate mailbox application --no-test-framework` generates:

```

class ApplicationMailbox < ApplicationMailbox
  def process
  end
end
```

which is not correct for the application mailbox. It shouldn't
respond to process but it should contain a routing hint.

Generally generators aren't meant to be used like the previous commit.
The mailbox generator can certainly add in the ApplicationMailbox
if missing, but it shouldn't be called with "application" as an argument.

Also adds back auto inserting an `ingress` config line in
`config/environmnets/production.rb`.

Fixes #13.

[Kasper Timm Hansen, Andrew Babichev]
2018-12-18 22:11:22 +01:00
Kasper Timm Hansen
7cf7ba4db5
Refit generator file structure to match Action Cable.
Fits with rails/generators/channel containing:

 - channel_generator.rb
 - templates/
 - USAGE
2018-12-18 22:05:42 +01:00
Ryuta Kamizono
28dacff5ed Eliminate "warning: assigned but unused variable - testEof"
https://github.com/ammar/regexp_parser/pull/57

```
% be ruby -w -Itest test/controller/filters_test.rb
/Users/kamipo/src/github.com/rails/rails/vendor/bundle/ruby/2.5.0/gems/addressable-2.5.2/lib/addressable/idna/pure.rb:154: warning: assigned but unused variable - startercc
/Users/kamipo/src/github.com/rails/rails/vendor/bundle/ruby/2.5.0/gems/regexp_parser-1.2.0/lib/regexp_parser/scanner.rb:1146: warning: assigned but unused variable - testEof
Run options: --seed 32647

# Running:

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

Finished in 0.291176s, 175.1518 runs/s, 343.4349 assertions/s.
51 runs, 100 assertions, 0 failures, 0 errors, 0 skips
```
2018-12-19 06:03:25 +09:00
Kasper Timm Hansen
a2c3b28257
Remove actions argument from Mailbox generator.
Generators only have the public `process` action, so there's nothing
else to generate here.

Skip the needless indirection.
2018-12-18 21:46:35 +01:00
Kasper Timm Hansen
9082a0928f
Test namespacing is supported. 2018-12-18 21:46:17 +01:00
Kasper Timm Hansen
272268fda5
Include proper suffix to assert no file correctly. 2018-12-18 21:45:43 +01:00
Kasper Timm Hansen
3b68b404a4
[ci skip] Remove needless changelog entry, as bug fix was backported to 5.2. 2018-12-18 21:13:11 +01:00
Kasper Timm Hansen
35e0190ac5
Merge pull request #34737 from r7kamura/feature/test-case-params-nil
Allow nil params on controller HTTP test methods
2018-12-18 21:07:43 +01:00
Ryuta Kamizono
96dee049c4 More exercise test_running_prepended_before_and_after_action
Just testing that `after_action` is invoked before
`prepend_after_action`.
2018-12-19 03:37:20 +09: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
Javan Makhmali
2f6456cbe1
Merge pull request #34635 from WoH/data-disable-forever
UJS: Do not disable previously disabled elements
2018-12-18 10:54:12 -05:00
r7kamura
eb37fd0aec Allow nil params on controller HTTP test methods 2018-12-18 21:44:05 +09:00
Ryuta Kamizono
d99984d48c Add test case for ce48b5a366482d4b4c4c053e1e39e79d71987197 2018-12-18 11:18:18 +09:00
yuuji.yaginuma
caa3cc8868 Do not add parent directory to file system monitoring
`EventedFileUpdateChecker` will search the parent directory if the
specified directory does not exist.

Since `test/mailers/previews` is included in the watch target by default,
if there is no test directory (e.g. using `rspec`), the Rails root directory
will be included in the watch target.

```
$ rails new app
$ cd app
$ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)"
false
$ rm -rf test
$ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)"
true
```

This causes `node_modules` to be included in watch target. Adding parent
directories to watch target may include unexpected directories.

In order to avoid this, fixed that parents of nonexistent directories are
not added to the watch targets, instead checking that the directory
exists when checking changes.

Related to #32700.

[Matthew Draper & Yuji Yaginuma]
2018-12-18 08:09:16 +09:00
Ryuta Kamizono
30eab94d2f
Fix View.new method call with arguments syntax
[ci skip]
2018-12-18 07:16:55 +09:00
Vipul A M
51a1abc8fb
Merge pull request #34733 from tjschuck/view_context_doc_formatting
Fix doc formatting [ci skip]
2018-12-18 06:06:45 +08:00
T.J. Schuck
1981fb2dfd Fix doc formatting
[ci skip]
2018-12-17 16:10:26 -05:00
Eileen M. Uchitelle
528c5bb224
Merge pull request #33145 from gsamokovarov/host-authorization
Guard against DNS rebinding attacks by whitelisting hosts
2018-12-17 11:41:15 -05:00
Eileen M. Uchitelle
02b931c764
Merge branch 'master' into host-authorization 2018-12-17 10:24:38 -05:00
Kasper Timm Hansen
048e3172f5
Merge pull request #34717 from tbuehlmann/controller-test-parsed-body
Allow using parsed_body in ActionController::TestCase
2018-12-17 16:01:31 +01:00
Bogdan
fdb2719308 Extend documentation of ActiveSupport::Notifications.subscribe (#34721)
* Extend documentation of `ActiveSupport::Notifications.subscribe`

Add mention that a block with only one argument passed to the method
will yield an event object.

Related to #33451

* Emphasize that `SubscribeEventObjects` is a test class by adding suffix `Test`
2018-12-17 17:25:55 +09:00
David Heinemeier Hansson
ba64c6d65d
Merge pull request #10 from dixpac/subtile_generator_mention_in_readme
Subtile mention of generator inside README
2018-12-16 08:07:03 -08:00
George Claghorn
cf15bb698f
Merge pull request #11 from dixpac/fix_required_ruby_version
Set ruby >= 2.4.1 as min required version
2018-12-16 10:02:38 -05:00
Dino Maric
8ea1b0f7c7 Set ruby >= 2.4.1 as min required version
This matches Rails master, and it should make TravisCI green.
2018-12-16 14:08:58 +01:00
Dino Maric
9d09c68b6c Subtile mention of generator inside README
Just a small mention that we can use generators inside README.
2018-12-16 12:59:51 +01:00
Tobias Bühlmann
8246a8139c
Allow using parsed_body in ActionController::TestCase
… by switching the initialzation of an appropriate response parser
in `ActionDispatch::TestResponse` from eagerly to lazily.

By doing so, the response parser can be correctly set for
`ActionController::TestCase`, which doesn't include
the content type header in the constructor but only sets it at
a later time.

Fixes #34676.
2018-12-16 12:27:37 +01:00
George Claghorn
b91c615662 Hook up Travis CI 2018-12-16 00:14:14 -05: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
David Heinemeier Hansson
8ab794280d
Merge pull request #9 from dixpac/dix/fix_generators
Fix Rails generators
2018-12-15 09:20:21 -08:00
Dino Maric
8415a6c5cf Fix Rails generators
1.Don't generate ApplicationMailboxTest when executing installer
2. Hookup test_unit, so console doesn't throw errors
2018-12-15 16:33:39 +01:00
Ryuta Kamizono
ce48b5a366 Prevent infinit method_missing loop on attribute methods
If a klass has acceptance validation and then
`klass.undefine_attribute_methods` is happened before an attribute
method is called, infinit loop is caused on the `method_missing` defined
by the `LazilyDefineAttributes`.

https://travis-ci.org/rails/rails/jobs/467053984#L1409

To prevent the infinit loop, the `method_missing` should ensure
`klass.define_attribute_methods`.
2018-12-15 18:07:13 +09: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
Vipul A M
f23cdd4f83
Merge pull request #32872 from utilum/soften_migrations_guide_generator_section
Expand intro to generator in Migrations Guide
2018-12-15 11:23:52 +09:00
Mariusz Hausenplas
2701a18d38 Add examples describing error handling in ActiveSupport::Notifications and ActiveSupport::LogSubscriber documentation files 2018-12-14 22:59:44 +01:00
David Heinemeier Hansson
749e923539
Merge pull request #8 from dgilperez/adds-generator
Add Mailbox and MailboxTest generators
2018-12-14 13:04:36 -08:00
David Gil
acae20e2ab renames file names 2018-12-14 21:42:20 +01:00
David Gil
5c3f0d2e19 Uses the new generator to install ApplicationMailbox in action_mailbox:install rake 2018-12-14 21:40:04 +01:00
David Gil
d872de3c69 Add Mailbox and MailboxTest generators 2018-12-14 21:24:03 +01:00