Commit Graph

12892 Commits

Author SHA1 Message Date
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 6567464bed 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 a725539de6
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 fa5a028ed9, 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
George Claghorn 5ee9fd6432
Merge pull request #34289 from jschulenklopper/patch-1
Add missing dot in comment in .gitignore template
2018-10-22 19:17:17 -05:00
bogdanvlviv 129f8ac6ff
Remove node_modules path from assets load paths since we use webpack by default
Related to #33079
2018-10-22 23:52:28 +03:00
Rafael França e853acb9b4
Merge pull request #34222 from bogdanvlviv/unify-changelog-entries
Unify changelog entries related to `database` option of Rails generators [ci skip]
2018-10-22 16:49:31 -04:00
Jochem Schulenklopper 1a5b353961
Add missing dot in comment in .gitignore template
My submission for the tiniest commit and PR contest: add a missing dot in a comment line in the generator template for .gitignore.
(I just noticed this missing; consistency is king :-)
2018-10-22 21:14:12 +02:00
bogdanvlviv 2e37fb655d
Remove `--skip-yarn` in favor of `--skip-javascript`
Since #33079 Webpacker the default JavaScript compiler for Rails.
Webpacker uses `yarn` so seems like it doesn't make sense for Rails to keep
`--skip-yarn` option.
2018-10-22 16:54:10 +03:00
Ryuta Kamizono dc67615920
Merge pull request #34279 from bogdanvlviv/remove-extra-remove_file-skip_action_cable
Remove extra call `remove_file` on `rails new` with `--skip_action_cable`
2018-10-22 21:56:00 +09:00
Ryuta Kamizono ced65eb9a7
Merge pull request #34274 from bogdanvlviv/remove-yarn-files-from-gitignore-template
Remove yarn's files from `.gitignore` template
2018-10-22 10:03:57 +09:00
bogdanvlviv 2593ee3f49
Remove extra call `remove_file` on `rails new` with `--skip_action_cable`
There is no need to remove this file since the line below
removes entire directory in which that file is placed.
2018-10-22 01:35:34 +03:00
Ryuta Kamizono 855ae222a9
Merge pull request #34277 from bogdanvlviv/remove-javascripts-javascripts_engine-options-for-generators
Remove `javascripts` and `javascript_engine` options for generators
2018-10-22 07:12:55 +09:00
bogdanvlviv 24367edbe6
Remove `javascripts` and `javascript_engine` options for generators
It is unused since #33079
2018-10-22 00:12:15 +03:00
bogdanvlviv 7093ee8ec5
Remove `:javascript` from `Rails::PluginBuilder::PASSTHROUGH_OPTIONS`
`--javascript` option was removed by 42198064c3
2018-10-22 00:00:32 +03:00
bogdanvlviv 9629354abb
Remove yarn's files from `.gitignore` template for new rails app
Webpacker already does it,
see 895d2cfc15/lib/install/template.rb (L25-L33)

I also opened PR https://github.com/rails/webpacker/pull/1765 in order
to make it add `/yarn-error.log` file too.
2018-10-21 22:40:01 +03:00
Bogdan b004e767e0 Correct some tests related to changes in #33079 (#34272)
* Fix assertions of auto-generated ActiveStorage JS

Since #33079

* Correct message on the `assert_equal` failure

Related to #33079

* Test ActionCable's js files

This commit adds `app/javascript/channels/consumer.js`, and
`app/javascript/channels/index.js` to `DEFAULT_APP_FILES` in order
to assert their existance in `test_skeleton_is_created`.

Related to #33079

* Assert no match `javascript_pack_tag` in `application.html.erb`

Since #33079 `rails new` generates `application.html.erb` file
with `javascript_pack_tag` instead of `javascript_include_tag`.

Note that there some tests that asserting no matching
`javascript_include_tag` in the `application.html.erb` file
for newly generated rails plugins.
It is related to #34009 and shouldn't be changed right now.
2018-10-22 02:29:58 +09:00
Ryuta Kamizono 6d37c6c41a
Merge pull request #34260 from frodsan/fix/remove-unnecessary-escape-char
Remove unnecessary escape character
2018-10-20 15:00:14 +09:00
yuuji.yaginuma 931120d37d Avoid running `webpacker:install` on tests that don't need it
If use `run_generator` to run the generator, `--skip-webpack-install`
is specified automatically.
3101a4136b/railties/lib/rails/generators/testing/behaviour.rb (L71)

However, when executing the generator independently (for example, to use
stub), `webpacker:install` was executed.
Since this includes `yarn install`, it should be avoided in unnecessary
testing.
2018-10-20 14:41:51 +09:00
Francesco Rodríguez 0f7655c325 Remove unnecessary escape character 2018-10-19 15:59:20 +02:00
Mauro Berlanda 264152af2b
chore: implement config_for as ActiveSupport::OrderedOptions 2018-10-19 14:37:06 +02:00
yuuji.yaginuma 86a12b6f29 Avoid running bundler on tests that don't need it
If the dev option is specified, Gemfile contains gem which specifies GitHub.
This will take time to execute, so should avoid it in unnecessary tests.
2018-10-19 17:56:09 +09:00
Yoshiyuki Kinjo 32b03b4615 Implement AR#inspect using ParamterFilter.
AR instance support `filter_parameters` since #33756.
Though Regex or Proc is valid as `filter_parameters`,
they are not supported as AR#inspect.

I also add :mask option and #filter_params to
`ActiveSupport::ParameterFilter#new` to implement this.
2018-10-19 14:16:03 +09:00
David Rodríguez 60e6269598
Fix generated Gemfile missing gems on jruby 2018-10-17 12:51:23 -03:00
Ryuta Kamizono b0b0cd1fd7 Merge pull request #29204 from RasPat1/issue-29200-scaffold-reference-display-memory-address
Issue #29200 scaffold an object with a reference displays an object memory address to user
2018-10-16 10:30:55 +09:00
bogdanvlviv 4f1295129b
Unify changelog entries related to `database` option of Rails generators [ci skip]
`migrations_paths` option was added to migration generator, with
changelog entry, in #33760.
Also `migrations_paths` option was added to model generator, with
changelog entry, in #33994.
Then `migrations_paths` was renamed to `database` and aliased as `db`
in #34021, and was added new changelog entry.
I think we should edit existed changelog entries instead adding new
about changing the name of the option from `migrations_paths` to `database`
since Rails 6.0 hasn't been released yet, and since It might confuse
readers of the changelog file in case if they've read changelog enty about
adding `migrations_paths` option but haven't read the entry about
change the name of that option to `database`.
@eileencodes, @gmcgibbon, @rafaelfranca Does it make sense?
2018-10-16 02:07:45 +03:00
Rasesh Patel ecb2850a04 Show object ids in scaffold pages when displaying referenced objects
Resolve Issue#29200

When scaffolding a model that references another model the
generated show and index html pages display the object directly
on the page. Basically, it just shows a memory address. That is
not very helpful. In this commit we show the object's id rather
than the memory address.

This updates the scaffold templates and the json builder files.
2018-10-14 15:54:53 -04:00
yuuji.yaginuma 29b1984a05 Runs the generator before assertions 2018-10-12 18:40:09 +09:00
Gannon McGibbon 2e53c2b130 Add test retries for railties 2018-10-11 10:43:29 -04:00
Gannon McGibbon 287c0de8a1 Add multi-db support to rails db:migrate:status 2018-10-09 16:40:06 -04:00
Rob Jonson d8707e0dfc enable_fragment_cache_logging
fragment caching was refactored in (I think 5.2) and by default doesn't log cache info

this is confusing in development where rails dev:cache now turns on caching, but doesn't show any different logging output

better to enable debugging by default for dev - and let people turn it off if preferred
2018-10-09 11:48:40 +01:00
yuuji.yaginuma 9195cdb7cd Use `--skip-webpack-install` by default
To remove extra `--no-skip-javascript` tests.
2018-10-09 09:30:45 +09:00
yuuji.yaginuma 7c846d9c73 Avoid `webpacker:install` if unnecessary
`webpacker:install` also includes execution of yarn, it takes time to execute,
so avoid unnecessary tests.
2018-10-09 08:09:10 +09:00
yuuji.yaginuma bd0ca39564 Add `skip-webpack-install` option
This option is useful when want to check only the files generated by
`rails new`, or if want to do something before `webpacker:install`.
2018-10-09 08:09:10 +09:00
Rafael França 0ece3911cc
Merge pull request #34084 from trustvox/master
Remove "include FileUtils" sentence in setup/update bin files
2018-10-05 17:55:37 -04:00
Gannon McGibbon b596346038 Remove bundler warnings from bin/setup output 2018-10-05 15:37:00 -04:00
Prathamesh Sonpatki 2690c41dec Fix tests related to new JavaScript path for generators
- Followup of 4838c1716a
2018-10-05 20:44:58 +05:30
Francesco Rodríguez 10408938c2 Add retry_on/discard suggestions for common cases.
This adds the same suggestions added here:
01a69e27a4/activejob/lib/rails/generators/job/templates/application_job.rb

These appear when `app/jobs/application_job.rb` doesn't exist, but not
for new applications.
2018-10-05 08:22:42 +02:00
yuuji.yaginuma 13bbdc09ec Avoid `webpacker:install` if unnecessary
Since this is a test to check the behavior of `load_defaults`,
webpacker is unnecessary.
2018-10-05 09:47:01 +09:00
schneems 235e734e1e Revert "Merge pull request #33970 from rails/eager-url-helpers"
Until #34050 can be resolved

This reverts commit 7f870a5ba2, reversing
changes made to 6556898884.
2018-10-03 16:15:47 -05:00
Gannon McGibbon c401c43850 Fix call sites 2018-10-02 15:31:29 -04:00
David Heinemeier Hansson 4838c1716a
Make Webpacker the default JavaScript compiler for Rails 6 (#33079)
* Use Webpacker by default on new apps

* Stop including coffee-rails by default

* Drop using a js_compressor by default

* Drop extra test for coffeescript inclusion by default

* Stick with skip_javascript to signify skipping webpack

* Don't install a JS runtime by default any more

* app/javascript will be the new default directory for JS

* Make it clear that this is just for configuring the default Webpack framework setup now

* Start using the Webpack tag in the default layout

* Irrelevant test

* jQuery is long gone

* Stop having asset pipeline compile default application.js

* Add rails-ujs by default to the Webpack setup

* Add Active Storage JavaScript to application.js pack by default

* Consistent quoting

* Add Turbolinks to default pack

* Add Action Cable to default pack

Need some work on how to set the global consumer that channels will
work with. @javan?

* Require all channels by default and use a separate consumer stub

* Channel generator now targets Webpack style

* Update task docs to match new generator style

* Use uniform import style

* Drop the JS assets generator

It was barely helpful as it was. It’s no longer helpful in a Webpacked
world. Sayonara!

* Add app/javascript to the stats directories

* Simpler import style

Which match the other imports.

* Address test failures from dropping JS compilation (and compression)

* webpacker-default: Modify `AssetsGeneratorTest`

Before:

```
$ bin/test test/generators/assets_generator_test.rb
Run options: --seed 46201

F

Failure:
AssetsGeneratorTest#test_assets [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:12]:
Expected file "app/assets/javascripts/posts.js" to exist, but does not

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:10

.

Finished in 0.031343s, 63.8101 runs/s, 95.7152 assertions/s.
2 runs, 3 assertions, 1 failures, 0 errors, 0 skips
```

After:

```
$ bin/test test/generators/assets_generator_test.rb
Run options: --seed 43571

..

Finished in 0.030370s, 65.8545 runs/s, 65.8545 assertions/s.
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
```

* webpacker-default: Modify `ChannelGeneratorTest`

Before:

```
$ bin/test test/generators/channel_generator_test.rb
Run options: --seed 8986

.F

Failure:
ChannelGeneratorTest#test_channel_with_multiple_actions_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:43]:
Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:34

.F

Failure:
ChannelGeneratorTest#test_channel_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:29]:
Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:22

E

Error:
ChannelGeneratorTest#test_cable_js_is_created_if_not_present_already:
Errno::ENOENT: No such file or directory @ apply2files - /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/fixtures/tmp/app/assets/javascripts/cable.js

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:60

F

Failure:
ChannelGeneratorTest#test_channel_suffix_is_not_duplicated [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:87]:
Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:80

F

Failure:
ChannelGeneratorTest#test_channel_on_revoke [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:77]:
Expected file "app/assets/javascripts/cable.js" to exist, but does not

bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:68

Finished in 0.064384s, 108.7227 runs/s, 481.4861 assertions/s.
7 runs, 31 assertions, 4 failures, 1 errors, 0 skips
```

After:

```
$ bin/test test/generators/channel_generator_test.rb
Run options: --seed 44857

.......

Finished in 0.060243s, 116.1961 runs/s, 697.1764 assertions/s.
7 runs, 42 assertions, 0 failures, 0 errors, 0 skips
```

* Fix shared generator tests.

* webpacker-default: Modify `ControllerGeneratorTest`

The JS assets generator was dropped. ref. 46215b1794

* Revert "Simpler import style". It's currently failing with an error of "TypeError: undefined is not an object (evaluating '__WEBPACK_IMPORTED_MODULE_2_activestorage___default.a.start')". Waiting for @javan to have a look.

This reverts commit 5d3ebb7105.

* require webpacker in test app

* Add webpacker without making the build hang/timeout. (#33640)

* use yarn workspaces to allow for installing unreleased packages and only generate js/bootsnap when required

* no longer need to have webpacker in env templates as webpacker moved this config to yml file

* Fix rubocop violation

* Got the test passing for the running scaffold

* update expected lines of code

* update middleware tests to account for webpacker

* disable js in plugins be default to get the tests passing (#34009)

* clear codeclimate report issues

* Anything newer than currently released is good

* Use Webpacker development version during development of Rails

* Edge should get development webpacker as well

* Add changelog entry for Webpacker change
2018-09-30 22:31:21 -07:00
Yasuo Honda aa3dcabd87 Add `Style/RedundantFreeze` to remove redudant `.freeze`
Since Rails 6.0 will support Ruby 2.4.1 or higher
`# frozen_string_literal: true` magic comment is enough to make string object frozen.
This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.

* Exclude these files not to auto correct false positive `Regexp#freeze`
 - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
 - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'

It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.

* Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required

 - 'actionpack/test/controller/test_case_test.rb'
 - 'activemodel/test/cases/type/string_test.rb'
 - 'activesupport/lib/active_support/core_ext/string/strip.rb'
 - 'activesupport/test/core_ext/string_ext_test.rb'
 - 'railties/test/generators/actions_test.rb'
2018-09-29 07:18:44 +00:00
yuuji.yaginuma 445a74e1a9 Reset `ActiveRecord::Base.configurations` to the value before 2018-09-29 09:25:59 +09:00
Eugene Kenny 0007501669 Only define attribute methods from schema cache
To define the attribute methods for a model, Active Record needs to know
the schema of the underlying table, which is usually achieved by making
a request to the database. This is undesirable behaviour while the app
is booting, for two reasons: it makes the boot process dependent on the
availability of the database, and it means every new process will make
one query for each table, which can cause issues for large applications.

However, if the application is using the schema cache dump feature, then
the schema cache already contains the necessary information, and we can
define the attribute methods without causing any extra database queries.
2018-09-28 21:16:21 +01:00
Gannon McGibbon 4775d3d051 Refactor migrations_path command option to database 2018-09-28 14:24:36 -04:00
Gannon McGibbon 77aaeced89 Add migrations_paths option to model generator 2018-09-27 10:35:52 -04:00
Aaron Patterson b42d246c5d
Merge branch 'master' into eager-url-helpers
* master:
  Remove force parent loading when counter cache child is created/destroyed
  Raise an error when loading all fixtures from nil fixture_path
  Revert "Remove `counter_cache_target` which is no longer called"
  Update counter cache in memory if parent target is existed
  If association is a hash-like object preloading fails
  Use the same option for create database statements between Raketask and travis.rb
  Fix "warning: shadowing outer local variable - config"
  Remove `counter_cache_target` which is no longer called
  Fix more offences
  Change the empty block style to have space inside of the block
  Fix a content_for test description
  Stringify database configurations
  Improve error message when assign wrong attributes to model
2018-09-26 12:35:12 -07:00
Aaron Patterson b50f7ae627
Routes from Engine Railties should not be an infinite loop 2018-09-26 11:10:25 -07:00
Aaron Patterson 6060a1d97b
Eager load supports individual files
Also we want to eager load routes before anything else.
2018-09-26 11:09:35 -07:00
Rafael Mendonça França f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
Eugene Kenny 3b954786e7 Eagerly define attribute methods in production
The attribute methods for a model are currently defined lazily the first
time that model is instantiated, even when `config.eager_load` is true.
This means the first request to use each model incurs the cost, which
usually involves a database round trip to fetch the schema definition.

By defining the attribute methods for all models while the application
is booting, we move that work out of any individual request. When using
a forking web server, this also reduces the number of times the schema
definition is queried by doing it once in the parent process instead of
from each forked process during their first request.
2018-09-24 03:20:35 +01:00
Kasper Timm Hansen 22dc2b3db8
Merge pull request #33949 from sjain1107/no-private-def
Remove private def
2018-09-23 19:39:15 +02:00
Sakshi Jain 0fe2bb816f Remove private def 2018-09-23 21:27:44 +05:30
yuuji.yaginuma 1b86d90136 Enable `Performance/UnfreezeString` cop
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.

```ruby
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "benchmark-ips"
end

Benchmark.ips do |x|
  x.report('+@') { +"" }
  x.report('dup') { "".dup }
  x.compare!
end
```

```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
                  +@   282.289k i/100ms
                 dup   187.638k i/100ms
Calculating -------------------------------------
                  +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                 dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s

Comparison:
                  +@:  6775299.3 i/s
                 dup:  3320400.7 i/s - 2.04x  slower

```
2018-09-23 08:56:55 +09:00
Rafael Mendonça França d3b952184d
Make sure this test check the issue solved in #31135
Before this change this test was passing even if we revert #31135. The
reason for that is that `app 'development'` will load the environment in
the test process and it is happening before db_create_and_drop is
called.

This was not asserting that the environment was loaded in the db:create
task itself.

To test it we enhance the db:create task with a block that writes to a
tmp file the value of the config. If the environment is loaded before
that task enhancement runs the content of the file will have "true"
insteand of "false".
2018-09-22 00:46:44 -04:00
schneems 3424bd83d6 Switch to supports_cache_versioning? check to a class method
- Moving the `supports_cache_versioning?` check to a class method. 
- Shorten the method doc. 
- Expand on the error message.
2018-09-20 20:40:31 -05:00
schneems 135d3e15b7 [close #33907] Error when using "recyclable" cache keys with a store that does not support it
If you are using the "in cache versioning" also known as "recyclable cache keys" the cache store must be aware of this scheme, otherwise you will generate cache entries that never invalidate.

This PR adds a check to the initialization process to ensure that if recyclable cache keys are being used via 

```
config.active_record.cache_versioning = true
```

Then the cache store needs to show that it supports this versioning scheme. Cache stores can let Rails know that they support this scheme by adding a method `supports_in_cache_versioning?` and returning true.
2018-09-20 15:31:38 -05:00
Wojciech Wnętrzak b4b70ef2bf
Fixed to RAILS_MASTER_KEY as a default env key for decrypting.
Fixes mistake left in https://github.com/rails/rails/pull/33521/files#diff-2a29095afcfe2c683b82a779a94c2208R59
and misunderstanding in d69b04de0f
2018-09-20 12:23:50 +02:00
yuuji.yaginuma d69b04de0f Fix env name for master key
When using environment specific credentials, `RAILS_MASTER_KEY` is not used.
2018-09-20 11:08:18 +09:00
Wojciech Wnętrzak e0d3313bac Support environment specific credentials file. (#33521)
For `production` environment look first for `config/credentials/production.yml.enc` file that can be decrypted by
`ENV["RAILS_MASTER_KEY"]` or `config/credentials/production.key` master key.
Edit given environment credentials file by command `rails credentials:edit --environment production`.
Default behavior can be overwritten by setting `config.credentials.content_path` and `config.credentials.key_path`.
2018-09-19 14:02:00 -07:00
Bruno Casali a725539de6 Remove "include FileUtils" sentence in setup/update bin files
According with rubocop style guide "Style/MixinUsage" is good to use only in
class/module not directly in file.
2018-09-17 19:22:11 -03:00
yuuji.yaginuma 70b5a7594e Add test for `config.active_storage.routes_prefix`
Follow up #33883.
2018-09-15 10:22:04 +09:00
Yasuo Honda 730b76b3ae Remove mysql2 gem version requirement "< 0.6.0"
Suggested at https://github.com/rails/rails/pull/33876#issuecomment-421176221
2018-09-14 00:19:36 +00:00
Yasuo Honda f36e285419 Bump MySQL version requirement to 5.5.8 in the template files
Follow-up #33853
2018-09-13 20:19:59 +00:00
Yasuo Honda be021a809c Validate if `utf8mb4` character set and longer index key prefix is supported
Once #33608 merged If users create a new database using MySQL 5.1.x, it will fail to create databases
since MySQL 5.1 does not know `utf8mb4` character set.

This pull request removes `encoding: utf8mb4` from `mysql.yml.tt`
to let create_database method handles default character set by MySQL server version.

`supports_longer_index_key_prefix?` method will need to validate if MySQL 5.5 and 5.6 server configured
correctly to support longer index key prefix, but not yet.
2018-09-13 12:05:25 +00:00
Rafael Mendonça França a8359d837c
Add a test that exercice better the behavior we expect in the query cache
In production the query cache was already being loaded before the first
request even without #33856, so added a test to make sure of it.

This new test is passing even if #33856 is reverted.
2018-09-12 20:57:52 -04:00
bogdanvlviv d1a14865e0
Build string set when `filter_attributes` is assigned
It would allow `filter_attributes` to be reused across multiple
calls to `#inspect` or `#pretty_print`.

- Add `require "set"`
- Remove `filter_attributes` instance reader. I think there is no need
to keep it.
2018-09-12 18:51:55 +03:00
Eileen Uchitelle 349db176d8 Fix query cache to load before first request
In a test app we observed that the query cache was not enabled on the
first request. This was because the query cache hooks are installed on
load and active record is loaded in the middle of the first request.

If we remove the `on_load` from the railtie the query cache hooks will
be installed before the first request, allowing the cache to be enabled
on that first request.

This is ok because query cache doesn't load anything else, only itself
so we're not eager loading all of active record before the first
request, just the query cache hooks.

[Eileen M. Uchitelle & Matthew Draper]
2018-09-12 10:09:59 -04:00
Rafael França abdfe2b667
Merge pull request #33819 from kevindew/yarn-path
Run yarn install relative to Rails.root
2018-09-11 22:38:42 -04:00
Rafael França 81174b35c6
Merge pull request #33483 from DylanReile/master
Disable content security policy for mailer previews
2018-09-11 20:46:25 -04:00
Rafael França 21b32bb2a8
Merge pull request #33815 from mberlanda/mberlanda/enhance-config-for
Use ActiveSupport::InheritableOptions and deep_symbolize_keys in config_for
2018-09-11 18:26:59 -04:00
Xavier Noria f589e20b0a use "minitest" consistently
The name of the minitest library is spelled that way: regular font, and
lowercase. Lowercase is used even at the beginning of sentences, see

    http://docs.seattlerb.org/minitest/

I double-checked this with @zenspider too (thanks!).
2018-09-11 23:57:25 +02:00
Mauro Berlanda b167d521ab
refacto: config_for with ActiveSupport::InheritableOptions and symbolized keys 2018-09-11 23:47:41 +02:00
Rafael França ab0eed599b
Merge pull request #33785 from bogdanvlviv/follow-up-33773-33779
Clarify changelog entry added in #33779 [ci skip]
2018-09-11 17:42:53 -04:00
Yasuo Honda d54d0c9575 Use utf8mb4 character set by default for MySQL database (#33608)
* Use utf8mb4 character set by default

`utf8mb4` character set supports supplementary characters including emoji.
`utf8` character set with 3-Byte encoding is not enough to support them.

There was a downside of 4-Byte length character set with MySQL 5.5 and 5.6:

"ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes"
for Rails string data type which is mapped to varchar(255) type.

MySQL 5.7 supports 3072 byte key prefix length by default.

* Remove `DEFAULT COLLATE` from Active Record unit test databases

There should be no "one size fits all" collation in MySQL 5.7.
Let MySQL server choose the default collation for Active Record
unit test databases.

Users can choose their best collation for their databases
by setting `options[:collation]` based on their requirements.

* InnoDB FULLTEXT indexes support since MySQL 5.6
it does not have to use MyISAM storage engine whose maximum key length is 1000 bytes.
Using MyISAM storag engine with utf8mb4 character set would cause
"Specified key was too long; max key length is 1000 bytes"

https://dev.mysql.com/doc/refman/5.6/en/innodb-fulltext-index.html

* References

"10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)"
https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html

"10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)"
https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8.html

"14.8.1.7 Limits on InnoDB Tables"
https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html
> If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes
> for InnoDB tables that use DYNAMIC or COMPRESSED row format.

* CI against MySQL 5.7

Followed this instruction and changed root password to empty string.
https://docs.travis-ci.com/user/database-setup/#MySQL-57

* The recommended minimum version of MySQL is 5.7.9
to support utf8mb4 character set and `innodb_default_row_format`

MySQL 5.7.9 introduces `innodb_default_row_format` to support 3072 byte length index by default.
Users do not have to change MySQL database configuration to support Rails string type.

https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_default_row_format

https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html
> If innodb_large_prefix is enabled (the default),
> the index key prefix limit is 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format.

* The recommended minimum version of MariaDB is 10.2.2
MariaDB 10.2.2 is the first version of MariaDB supporting `innodb_default_row_format`
Also MariaDB says "MySQL 5.7 is compatible with MariaDB 10.2".

- innodb_default_row_format
https://mariadb.com/kb/en/library/xtradbinnodb-server-system-variables/#innodb_default_row_format

- "MariaDB versus MySQL - Compatibility"
https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/
> MySQL 5.7 is compatible with MariaDB 10.2

- "Supported Character Sets and Collations"
https://mariadb.com/kb/en/library/supported-character-sets-and-collations/
2018-09-11 13:03:34 -07:00
yuuji.yaginuma 5b0b1ee8fd Use correct variable
Follow up of 3e81490717.
2018-09-11 07:06:30 +09:00
Rafael Mendonça França 3e81490717
Remove all references to slave in the codebase 2018-09-10 16:31:32 -04:00
Kevin Dew f443aac340
Run yarn install relative to Rails.root
We may not always have binstubs relative to the directory we are running
the rake task from. The particular case for this is with a mountable
Rails engine and dummy app that is created to test it. This sets all the
tasks up to run under an `app` namespace in
railties/lib/rails/tasks/engine.rake

This change resolves a problem whereby running `app🧶install` would
have no effect as it would try to run in the plugins bin directory
rather than the test/dummy/bin. This also means that it installs from
test/dummy/package.json and into test/dummy/node_modules which is
behaviour consistent with a normal Rails app.

On a rails engine:

```
➜  tmp rails plugin new rails-plugin --mountable
➜  tmp cd rails-plugin
```

Before this change:

```
➜  rails-plugin rake app🧶install
➜  rails-plugin
```

After this change:

```
➜  rails-plugin rake app🧶install
yarn install v1.9.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
  Done in 0.07s.
```

When this change is ran against a normal rails install there is not a
behavioural change:

```
➜  tmp rails new full-app
➜  tmp cd full-app
➜  full-app git:(master) ✗ rake yarn:install
yarn install v1.9.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
  Done in 0.09s.
```
2018-09-07 22:11:10 +01:00
Zhang Kang 180dcd1bfa Configuration item `config.filter_parameters` could also filter out sensitive value of database column when call `#inspect`
* Why
Some sensitive data will be exposed in log accidentally by calling `#inspect`, e.g.

```ruby
@account = Account.find params[:id]
payload = { account: @account }
logger.info "payload will be #{ payload }"
```

All the information of `@account` will be exposed in log.

* Solution
Add a class attribute filter_attributes to specify which values of columns shouldn't be exposed.
This attribute equals to `Rails.application.config.filter_parameters` by default.

```ruby
Rails.application.config.filter_parameters += [:credit_card_number]
Account.last.insepct # => #<Account id: 123, credit_card_number: [FILTERED] ...>
```
2018-09-07 09:52:13 +08:00
Ryuta Kamizono 736edb9828 Formatting CHANGELOGs [ci skip]
Fixing code block rendering, indentation, backticks, etc.
2018-09-07 07:59:19 +09:00
yuuji.yaginuma 0cbbe515d3 Use canonical name for block local
`spec` is the same variable name as gemspec generated by bundler, and its
intention is easier to understand than a one-letter variable.
00fd58eaa6/lib/bundler/templates/newgem/newgem.gemspec.tt (L11)

This is follow up on 1c59b4840c. `spec` is already in use there.
2018-09-07 07:40:03 +09:00
Rafael Mendonça França 1c59b4840c
Generate a gem that can't be pushed to Rubygems.org by default
This will avoid gems that are made to be private to be pushed to public
repositories.
2018-09-06 14:45:47 -04:00
yuuji.yaginuma fb3642b0ca Respect config setting when output deprecation notice in rake tasks
The rake tasks which became deprecate now does not load the environment.
Therefore, even if the application specifies the behavior of deprecating,
the message is output to stderr ignoring the specification.

It seems that this is not the expected behavior.
We should respect the setting even in the rake tasks.
2018-09-04 20:06:54 +09:00
bogdanvlviv ff718abcba
Clarify changelog entry added in #33779 [ci skip]
Related to #33773
2018-09-03 19:15:14 +03:00
Michael Nelson 732111b05f Update changelog with null_store default
[ci skip]
2018-09-02 15:20:19 -07:00
George Claghorn 53eea40d35
Merge pull request #33773 from mcnelson/null_cache_store_for_test_env
Make null_store the default cache store in test environment config
2018-09-02 14:38:34 -04:00
Eileen M. Uchitelle d8ac08f6bf
Merge pull request #33770 from eileencodes/multi-db-improvements-part-3
Part 3: Multi-db Improvements, identifying replica configurations
2018-09-01 09:49:01 -04:00
yuuji.yaginuma 02b4ba6461 Remove needless test order config
These were added for avoiding warnings and for testing in
e4c529ea1d and 6ea7065a18.

Now the default is `:random`, and since the tests added with it are
removed. That config is unnecessary.
2018-09-01 18:46:40 +09:00
Rafael França f3fe56c732
Merge pull request #33743 from steakknife/steakknife/improve-template-generator-actions
add github to template actions, template actions minor refactor
2018-08-31 16:56:00 -05:00
Eileen Uchitelle a572d2283b Convert configs_for to kwargs, add include_replicas
Changes the `configs_for` method from using traditional arguments to
using kwargs. This is so I can add the `include_replicas` kwarg without
having to always include `env_name` and `spec_name` in the method call.

`include_replicas` defaults to false because everywhere internally in
Rails we don't want replicas. `configs_for` is for iterating over
configurations to create / run rake tasks, so we really don't ever need
replicas in that case.
2018-08-31 16:07:09 -04:00
Yoshiyuki Kinjo ae6adf98cc Emit warning for unknown inflection rule when generating model.
For words like "abuse", Rails cannot derive its singular form from
plural form "abuses" without defining custom inflection rule.
`rails generate model` and its families now emit warning for this case.
2018-08-31 15:47:35 +09:00
Barry Allard 20e3cacbaa
add github to template actions, light DSL refactor 2018-08-30 16:22:32 -07:00
Eileen M. Uchitelle 8f2caec401
Merge pull request #33637 from eileencodes/ar-connection-management-refactoring
Refactor Active Record configurations
2018-08-30 13:07:02 -04:00
Eileen Uchitelle b551a70755 Add migrations_paths option to migration generator
Adds an option to the migration generator to allow setting the
migrations paths for that migration. This is useful for applications
that use multiple databases and put migrations per database in their own
directories.

```
bin/rails g migration CreateHouses address:string --migrations-paths=db/kingston_migrate
      invoke  active_record
      create    db/kingston_migrate/20180830151055_create_houses.rb
```
2018-08-30 11:18:40 -04:00
Eileen Uchitelle fdf3f0b930 Refactors Active Record connection management
While the three-tier config makes it easier to define databases for
multiple database applications, it quickly became clear to offer full
support for multiple databases we need to change the way the connections
hash was handled.

A three-tier config means that when Rails needed to choose a default
configuration (in the case a user doesn't ask for a specific
configuration) it wasn't clear to Rails which the default was. I
[bandaid fixed this so the rake tasks could work](#32271) but that fix
wasn't correct because it actually doubled up the configuration hashes.

Instead of attemping to manipulate the hashes @tenderlove and I decided
that it made more sense if we converted the hashes to objects so we can
easily ask those object questions. In a three tier config like this:

```
development:
  primary:
    database: "my_primary_db"
  animals:
    database; "my_animals_db"
```

We end up with an object like this:

```
  @configurations=[
    #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
      @env_name="development",@spec_name="primary",
      @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>,
    #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90
      @env_name="development",@spec_name="animals",
      @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
]>
```

The configurations setter takes the database configuration set by your
application and turns them into an
`ActiveRecord::DatabaseConfigurations` object that has one getter -
`@configurations` which is an array of all the database objects.

The configurations getter returns this object by default since it acts
like a hash in most of the cases we need. For example if you need to
access the default `development` database we can simply request it as we
did before:

```
ActiveRecord::Base.configurations["development"]
```

This will return primary development database configuration hash:

```
{ "database" => "my_primary_db" }
```

Internally all of Active Record has been converted to use the new
objects. I've built this to be backwards compatible but allow for
accessing the hash if needed for a deprecation period. To get the
original hash instead of the object you can either add `to_h` on the
configurations call or pass `legacy: true` to `configurations.

```
ActiveRecord::Base.configurations.to_h
=> { "development => { "database" => "my_primary_db" } }

ActiveRecord::Base.configurations(legacy: true)
=> { "development => { "database" => "my_primary_db" } }
```

The new configurations object allows us to iterate over the Active
Record configurations without losing the known environment or
specification name for that configuration. You can also select all the
configs for an env or env and spec. With this we can always ask
any object what environment it belongs to:

```
db_configs = ActiveRecord::Base.configurations.configurations_for("development")
=> #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800
  @configurations=[
    #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
      @env_name="development",@spec_name="primary",
      @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>,
    #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90
      @env_name="development",@spec_name="animals",
      @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
]>

db_config.env_name
=> "development"

db_config.spec_name
=> "primary"

db_config.config
=> { "adapter"=>"sqlite3", "database"=>"db/development.sqlite3" }
```

The configurations object is more flexible than the configurations hash
and will allow us to build on top of the connection management in order
to add support for primary/replica connections, sharding, and
constructing queries for associations that live in multiple databases.
2018-08-30 10:06:45 -04:00
Ryuta Kamizono cc81cd359c
Merge pull request #33744 from bogdanvlviv/fixes-27852
Prevent leaking of user's DB credentials on `rails db:create` failure
2018-08-30 02:44:58 +09:00
Eileen Uchitelle a64dba1dc5 Remove this conditional
I removed the argument so I should remove the conditional too.
2018-08-29 12:08:23 -04:00
Eileen Uchitelle c91f1482a1 Remove unused argument
The test that used this was updated and it's no longer needed.
2018-08-29 11:08:10 -04:00
Eileen M. Uchitelle 55133a0e8e
Merge pull request #33748 from eileencodes/fix-erb-loading-issue-with-db-yaml
Drop load_database_yaml and fix test
2018-08-29 11:07:01 -04:00
Eileen Uchitelle 6b5df90fb5 Drop load_database_yaml and fix test
We originally did the whole `load_database_yaml` thing because this test
wasn't cooperating and we needed to finish the namespaced rake tasks for
multiple databases.

However, it turns out that YAML can't eval ERB if you don't tell it it's
ERB so you get Pysch parse errors if you're using multi-line ERB or
ERB with conditionals. It's a hot mess.

After trying a few things and thinking it over we decided that it wasn't
worth bandaiding over, the test needed to be improved. The test was
added in #31135 to test that the env is loaded in these tasks. But it
was blowing up because we were trying to read a database name out of the
configuration - however that's not the purpose of this change. We want
to read environment files in the rake tasks, but not in the config
file.

In this PR we changed the test to test what the PR was actually fixing.
We've also deleted the `load_database_yaml` because it caused more
problems than it was worth. This should fix the issues described in
https://github.com/rails/rails/pull/32274#issuecomment-384161057. We
also had these problems at GitHub.

Co-authored-by: alimi <aibrahim2k2@gmail.com>
2018-08-29 10:26:44 -04:00
bogdanvlviv 9b455fe6f0
Prevent leaking of user's DB credentials on `rails db:create` failure
Issue #27852 reports that when `rails db:create` fails, it causes
leaking of user's DB credentials to $stderr.
We print a DB's configuration hash in order to help users more quickly
to figure out what could be wrong with his configuration.

This commit changes message from
"Couldn't create database for #{configuration.inspect}" to
"Couldn't create '#{configuration['database']}' database. Please check your configuration.".

There are two PRs that fixing it #27878, #27879, but they need a bit more work.
I decided help to finish this and added Author of those PRs credit in this commit.

Since it is a security issue, I think we should backport it to
`5-2-stable`, and `5-1-stable`.
Guided by https://edgeguides.rubyonrails.org/maintenance_policy.html#security-issues

Fixes #27852
Closes #27879
Related to #27878

[Alexander Marrs & bogdanvlviv]
2018-08-29 12:40:30 +03:00
Matthew Draper 068fe7dc90
Merge pull request #33718 from kddeisz/permit-list
Finish converting whitelist and blacklist references
2018-08-29 14:07:37 +09:30
yuuji.yaginuma 28e5085070 Generate the same value as a label of view in system test template
In the system test template, enter a value based on label.
However, since `label` method does not use `titleize` by default.
If generate a value including underscore, cannot find a label and the test
will fail.

```
$ ./bin/rails g scaffold user name:string phone_number:string
$ ./bin/rails t test/system/users_test.rb

E

Error:
UsersTest#test_creating_a_User:
Capybara::ElementNotFound: Unable to find field "Phone Number"
    test/system/users_test.rb:18:in `block in <class:UsersTest>'
```

This removes unnecessary `titleize` so that the generated file will pass
even if the attribute contains an underscore.
2018-08-29 09:58:21 +09:00
Kevin Deisz 7c9751d7fe
Permit list usage cleanup and clearer documentation 2018-08-27 09:51:46 -04:00
Kevin Deisz 1b98de8030
Convert over the rest of the blacklist references 2018-08-24 16:11:29 -04:00
George Claghorn a0b57bbb21
Merge pull request #33703 from bogdanvlviv/follow-up-33659
Follow up #33659
2018-08-23 09:34:27 -04:00
bogdanvlviv 1055d14127
Set the test adapter for the test environment by default in `config/cable.yml` 2018-08-23 12:33:02 +03:00
Kasper Timm Hansen 2a321bff40
Merge pull request #33696 from bogdanvlviv/follow-up-44007c070
Use `say`/`error` instead of `puts`/`$stderr.puts`
2018-08-23 11:02:15 +02:00
Rafael França 9963c2a008
Merge pull request #33697 from bogdanvlviv/rails-command-help-show-description
Fix `rails initializers --help` and `rails dev:cache --help`
2018-08-22 15:05:56 -05:00
bogdanvlviv cffb9bc1f6
Use `say`/`error` instead of `puts`/`$stderr.puts`
Follow up 44007c0709
2018-08-22 22:39:03 +03:00
bogdanvlviv 7bd29b506c
Fix `rails initializers --help` and `rails dev:cache --help`
- `rails initializers --help` should show description set by `desc`
  See railties/lib/rails/command/base.rb:27

- Fix `rails dev:cache --help`

 ```
 Traceback (most recent call last):
         10: from bin/rails:4:in `<main>'
          9: from bin/rails:4:in `require'
          8: from /work/rails/railties/lib/rails/commands.rb:18:in `<top (required)>'
          7: from /work/rails/railties/lib/rails/command.rb:46:in `invoke'
          6: from /work/rails/railties/lib/rails/command/base.rb:65:in `perform'
          5: from /home/vagrant/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
          4: from /home/vagrant/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
          3: from /home/vagrant/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
          2: from /work/rails/railties/lib/rails/command/base.rb:150:in `help'
          1: from /home/vagrant/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:170:in `command_help'
 /home/vagrant/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:497:in `handle_no_command_error': Could not find command "dev". (Thor::UndefinedCommandError)
  ```

Context https://github.com/rails/rails/pull/33694#issuecomment-415127304

Would be great to set a description to other commands.
2018-08-22 22:36:25 +03:00
bogdanvlviv 63b9bf7d3d
Remove `rake initializers` from rake tasks list
Context https://github.com/rails/rails/pull/33631#discussion_r210732565
2018-08-22 20:49:37 +03:00
Richard Schneeman 27934451b2
Merge pull request #33660 from y-yagi/follow_up_32121
Make `rake routes` deprecate before deleting
2018-08-21 06:57:04 -07:00
Yoshiyuki Kinjo e2d0b3b375 Fix `rails routes -c` for controller name consists of multiple word. 2018-08-20 19:17:40 +09:00
yuuji.yaginuma 41ad613e4c Make `rake routes` deprecate before deleting
`rake routes` was a public task. Therefore, I think that we should deprecate
it before deleting it.

Related to #32121.
2018-08-20 08:47:29 +09:00
Kasper Timm Hansen 44007c0709
Don't put up with not saying it.
Commands generally prefer say to puts.
2018-08-19 19:58:05 +02:00
Kasper Timm Hansen cc14bf77ca
Merge pull request #33631 from anniecodes/initializers-command
Move the initializers rake task to Rails::Command
2018-08-19 19:38:17 +02:00
Ryuta Kamizono b2c1e29c14 Enable Style/ParenthesesAroundCondition cop
To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
2018-08-19 08:16:21 +09:00
Annie-Claude Côté 0d3b5fc0f5 Update 'rake initializers' to use Rails::Command under the hood
* Invoke Rails::Command within the rake task
* Adds test for calling initializers with 'bin/rake'
* Adds deprecation warning to the rake task
2018-08-16 10:50:37 -04:00
Annie-Claude Côté 1ce2f9a55c Move 'rails initializers' command to Rails::Command 2018-08-16 10:46:11 -04:00
Annie-Claude Côté ccdb23d500 [ci skip] Add deprecration of to CHANGELOG 2018-08-16 10:11:31 -04:00
yuuji.yaginuma c710ffa37e Do not show deprecate task in the task list 2018-08-16 08:39:22 +09:00
Kasper Timm Hansen 977d77e9e2
Merge pull request #33499 from lsylvester/caller-ignore-paths
use BacktraceCleaner for ActiveRecord verbose logging
2018-08-15 20:16:43 +02:00
Kasper Timm Hansen efaa7191f2
Merge pull request #33559 from anniecodes/dev-task
Move `dev:cache` rake task to use Rails::Command
2018-08-15 20:00:34 +02:00
yuuji.yaginuma ce47479be0 Fix broken list formatting [ci skip] 2018-08-15 20:11:36 +09:00
bogdanvlviv e765bff134
Use `Array#extract!` where possible 2018-08-14 19:53:12 +03:00
Lachlan Sylvester c675783eb4 Use backtrace cleaner to clean up backtrace for verbose query logs 2018-08-14 09:15:28 +10:00
Annie-Claude Côté 35a70f8422 Have `bin:rake dev:cache` use the Dev Rails Command under the hood
* Call the Rails::Command::DevCommand in the rake task for dev:cache
* Add deprecation for using `bin/rake` in favor of `bin/rails`
2018-08-13 11:27:01 -04:00
Annie-Claude Côté 3e6d03d99e Adds Rails:Command for `dev:cache` that has the same behaviour as the rake task 2018-08-13 11:27:01 -04:00
Annie-Claude Côté 7db360acb2 Update Changelog to add deprecation to `rake dev:cache` 2018-08-13 11:26:54 -04:00
Assain 1cda4fb5df Purpose Metadata For Signed And Encrypted Cookies
Purpose metadata prevents cookie values from being
copy-pasted and ensures that the cookie is used only
for its originally intended purpose.

The Purpose and Expiry metadata are embedded inside signed/encrypted
cookies and will not be readable on previous versions of Rails.

We can switch off purpose and expiry metadata embedded in
signed and encrypted cookies using

	config.action_dispatch.use_cookies_with_metadata = false

if you want your cookies to be readable on older versions of Rails.
2018-08-12 21:50:35 +05:30
Kasper Timm Hansen 317efa5c35
Merge pull request #33587 from bogdanvlviv/follow-up-33202
`bundle binstubs bundler` should be executed after `bundle install`
2018-08-11 21:14:54 +02:00
bogdanvlviv 2c667814c8
`bundle binstubs bundler` should be executed after `bundle install`
Fixes:

`bundle binstubs bundler` doesn't generate `bin/bundle` for newly
generated Rails app.

```
...
(snip)
run  bundle binstubs bundler
The git source https://github.com/rails/web-console.git is not yet checked out.
Please run `bundle install` before trying to start your application
run  bundle install
Fetching https://github.com/rails/web-console.git
(snip)
...
```

Related to #33202
2018-08-11 18:58:20 +03:00
Vinicius Stock a486210c98 Make active job name prefix static since Rails.env will always be the same 2018-08-11 12:42:21 -03:00
Eileen M. Uchitelle 920c9195e0
Merge pull request #33202 from deivid-rodriguez/bundler_binstubs
Bundler binstubs
2018-08-11 10:36:42 -04:00
Eileen M. Uchitelle 2cb87e3b31
Merge pull request #33553 from bogdanvlviv/ensure-load_schema-does_not-output-in-parallel-tests-execution
Ensure that running tests in parallel doesn't display schema load output
2018-08-11 10:35:28 -04:00
bogdanvlviv d0edc9c7ae
Ensure that running tests in parallel doesn't display schema load output
https://github.com/rails/rails/pull/33479 changed `#load_schema` to
prevent displaying schema load on running tests in parallel.
We should test this in order to prevent any regression in the future.

Context https://github.com/rails/rails/pull/33479#discussion_r206870727
2018-08-08 16:20:38 +03:00
Kazuhiro Sera 52919f3d13 Fix the obvious typos detected by github.com/client9/misspell 2018-08-08 21:55:46 +09:00
Lachlan Sylvester e69dfa478b update BacktraceCleaner::RENDER_TEMPLATE_PATTERN to match the ActionView::Template method names 2018-08-07 16:10:00 +10:00
Lachlan Sylvester 67c58f4884 Filter backtrace in test to ensure irb counts as user code 2018-08-06 15:40:49 +10:00
Michael Nelson 7beb176283 Set cache store as null_store for test environment 2018-08-02 16:58:57 -07:00
Atul Bhosale 7e40e9585a Log the remote IP addr of clients behind a proxy
[Atul Bhosale, Victor Nawothnig]
2018-07-31 20:45:37 +05:30
Dylan Reile e8ac7af29d Disable content security policy for mailer previews 2018-07-30 22:37:34 -07:00
Bart de Water eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Richard Schneeman 91fd679710
Merge pull request #32381 from q-centrix/update-codeclimate-configs
Turn on performance based cops
2018-07-25 16:00:33 -05:00
Matthew Draper ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Paul McMahon 7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Dillon Welch d108288c2f
Turn on performance based cops
Use attr_reader/attr_writer instead of methods

method is 12% slower

Use flat_map over map.flatten(1)

flatten is 66% slower

Use hash[]= instead of hash.merge! with single arguments

merge! is 166% slower

See https://github.com/rails/rails/pull/32337 for more conversation
2018-07-23 15:37:06 -07:00
Kasper Timm Hansen 76f22e19d6
Merge pull request #33403 from bogdanvlviv/clarify-test_notes_finds_notes_in_custom_directories
Clarify `railties/test/application/rake/notes_test.rb`
2018-07-22 09:27:26 +02:00
Richard Schneeman d3ba913158
Merge pull request #32984 from chiraggshah/min-thread-env-variable
Separate min and max threads count environment variable for puma configuration
2018-07-21 19:05:37 -05:00
bogdanvlviv a6ebafc5ac
Clarify `railties/test/application/rake/notes_test.rb`
After 1996fbe2a3 `rails notes`
isn't the same as `rake notes`.
Since that, we should test `rake routes` instead of `rails notes` in
`railties/test/application/rake/notes_test.rb` file.
So I changed all occurrences of `rails routes` to `rake routes` in that file,
and added assertions about deprecation warning of using `rake notes`.
It will help to figure out that we should remove
`railties/test/application/rake/notes_test.rb` entirely in favour of
`railties/test/commands/notes_test.rb` that was added
in 1996fbe2a3.
2018-07-21 15:03:10 +03:00
Chirag Shah ddfcdffb3b Modified the changes to make it backward compatible 2018-07-21 08:53:05 +05:30
yuuji.yaginuma 1a0bcc3b49 Fix deprecation message for `SOURCE_ANNOTATION_DIRECTORIES`
Also, added a test that a deprecated message will be output.
2018-07-20 13:19:10 +09:00
Ryuta Kamizono 6f58b2cfc9 Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the future
We sometimes ask "✂️ extra blank lines" to a contributor in reviews like
https://github.com/rails/rails/pull/33337#discussion_r201509738.

It is preferable to deal automatically without depending on manpower.
2018-07-12 21:29:48 +09:00
Rafael França d4ea114bd6
Merge pull request #33308 from anniecodes/notes-command-changelog
Add rake notes and SOURCE_ANNOTATION_DIRECTORIES deprecation to Changelog
2018-07-09 11:41:33 -04:00
Annie-Claude Côté a028d3f775 Add deprecations related to `rails notes` command to Changelog
* SOURCE_ANNOTATION_DIRECTORIES deprecation
* Deprecation of `rake notes`, use `rails notes` instead
* Deprecation of `rails notes:custom ANNOTATION=custom`, `rails notes:optimize`, `rails notes:todo`, and `rails notes:fixme` in favor of passing `-annotations` or `-a` to `rails notes`
* They have all  been deprecrated in https://github.com/rails/rails/pull/33220
2018-07-09 11:20:28 -04:00
Kasper Timm Hansen 50a9ca665d
Merge pull request #28266 from Stellenticket/allow_disable_server_stdout_logging
rails server: Allow to explicitly specify whether to output Rails's log to stdout
2018-07-08 20:01:45 +02:00
bogdanvlviv c5cee6cb9b
Fix rubocop offense introduced in 161ed37
We prefer double quotes over single quotes.

Fixes:
```
railties/lib/rails/commands/server/server_command.rb:279:39:
C: Style/StringLiterals: Prefer double-quoted strings unless you need
single quotes to avoi d extra backslashes for escaping.
            original_options.concat [ '-u', using ]
```

Related to 161ed37d71
2018-07-08 18:37:10 +03:00
Markus Doits 889a7ccf08
Allow to explicitly specify whether to output Rails' log to stdout
Before Rails' logger output is mirrored to std out if:

* environment is development and
* the process is not daemonized

It was not possible to change that behaviour, e.g. to disable log output
in that case or enable it in other cases.

Now you can explicitly disable or enable output with the new command
line switch `--log-to-stdout`, regardless of any other circumstances.

```
// enable output in production
rails server -e production --log-to-stdout

// disable output in development
rails server -e development --no-log-to-stdout
```

Enabling output when daemonized still makes no sense (since tty is
detached), but this is ignored for now.

If the command line flag is not specified, old behaviour still
applies, so this change is completely backward compatible.
2018-07-08 17:28:34 +02:00
Kasper Timm Hansen 1d97b8f9e4
Don't balloon @original_options with --restart on restart.
Our restart_command would pass in `--restart` which means
that if the @original_options already contains --restart
it would keep getting another --restart appended.

Nothing here that would break the bank, but just a nicety.
2018-07-07 10:21:29 +02:00
Kasper Timm Hansen 161ed37d71
Don't show unneeded deprecation warning on server restart.
If booting a server via `rails s -u puma`, we'd convert the
option to a `using` positional.

When using `rails restart` our `restart_command` would the
option converted to the using positional and put that in
the restart command.

Thus we'd show users deprecation warnings for our own code.

Fix that by converting a passed positional to an option instead.

Also: fix initialize method signature. The local_options are an
array, not a hash. But don't even bother assigning defaults as
Thor passes them in.
2018-07-07 10:21:29 +02:00
Kasper Timm Hansen 688e48d93d
Remove restart_command leftover from switching to Thor options.
Ref:
654704247e

Before the commit we had a restart_command in Rails::Server. But after
there's another one in Rails::ServerCommand. The command version of the
method is the right one as it's used in server_options.

Give the leftover method the boot.
2018-07-07 09:41:48 +02:00
Kasper Timm Hansen b773318f5a
Use only snake cased symbols in commands.
Mixing strings and symbols seems aesthetically less than ideal.

We can also use underscores just fine. Thor converts them to dashes
for the CLI and it makes access in Ruby code nicer.

Here's the `server --help` output after this change:

```
Usage:
  rails server [thin/puma/webrick] [options]

Options:
  -p, [--port=port]                        # Runs Rails on the specified port - defaults to 3000.
  -b, [--binding=IP]                       # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.
  -c, [--config=file]                      # Uses a custom rackup configuration.
                                           # Default: config.ru
  -d, [--daemon], [--no-daemon]            # Runs server as a Daemon.
  -e, [--environment=name]                 # Specifies the environment to run this server under (development/test/production).
  -u, [--using=name]                       # Specifies the Rack server used to run the application (thin/puma/webrick).
  -P, [--pid=PID]                          # Specifies the PID file.
                                           # Default: tmp/pids/server.pid
  -C, [--dev-caching], [--no-dev-caching]  # Specifies whether to perform caching in development.
      [--early-hints], [--no-early-hints]  # Enables HTTP/2 early hints.
```

See? Quite dashing 
2018-07-07 09:33:11 +02:00
Alberto Almagro a7986aeda0 Show rails instead of bin/rails on USAGE instructions
With this commit, rails commands usage instructions display now +rails+
instead of +bin/rails+ within their recommendations.
2018-07-06 22:46:54 +02:00
Alberto Almagro 40b209db53 Recommend use of rails over bin/rails
As discussed in #33203 rails command already looks for, and runs,
bin/rails if it is present.

We were mixing recommendations within guides and USAGE guidelines,
in some files we recommended using rails, in others bin/rails and
in some cases we even had both options mixed together.
2018-07-06 22:46:35 +02:00
Kasper Timm Hansen 9ecbd64cd9
Merge pull request #32776 from Edouard-chin/ec-as-hooks
Use testing lazy-load hooks
2018-07-05 20:44:53 +02:00
Annie-Claude Côté 7e229f7430 Make NotesCommand tests more performant by getting rid of unecessary map
* Get rid of map and replace it with a multiplication of "\n" to generate document with multiple line preceding the annotation
* Reduce number from 1000 to 100 since it achieves the same goal
* Only keep one test for the multiple lines document since it's unecessary to test multiple times
* Update some language in tests names to make it clearer what we are testing
2018-07-05 10:01:46 -04:00
Kasper Timm Hansen ba38e13c82
Merge pull request #33220 from anniecodes/notes-command
Adds `Rails::Command::NotesCommand` and makes `rake notes` use it under the hood
2018-07-05 10:32:58 +02:00
Edouard CHIN 2730f10560 Use testing lazy-load hooks:
- In order to avoid loading classes prematurely, let's use lazy load hooks that are now provided with each test case
2018-07-04 16:34:59 -04:00
Annie-Claude Côté edf5da4b6c Port Annotations rake task to use Rails::NotesCommand
* Invokes the notes Rails::Command and passes the rake task ENV variables as annotations options to it
* Adds a deprecation warning for unsupported commands
* Gets rid of reference to ENV["SOURCE_ANNOTATION_DIRECTORIES"] in SourceAnnotationExtractor since its now dealt with in the NotesCommand
* Gets rid of rake desc for each rake notes task so they are not documented while using `rails -T` or `rails --help`
2018-07-04 14:30:14 -04:00
Annie-Claude Côté 21f7dadbff Adds support to register directories and extensions to NotesCommand
* Require the application and environnement in the notes command in order to load the config files
* Adds tests for both register_directories and register_extensions added to a config file
2018-07-04 14:30:11 -04:00
Annie-Claude Côté 1996fbe2a3 Adds a Rails::Command for Notes
* It is called with `rails notes`
* It defaults to displaying [OPTIMIZE, FIXME and TODO] annotations
* It accepts custom annotations by using `rails notes -a CUSTOM_ANNOTATION OTHER_ANNOTATION`
* It defaults to look for annotations in [app config db lib test] as dictated by SourceAnnotationExtractor
* It supports ENV["SOURCE_ANNOTATION_DIRECTORIES"] but adds a deprecation warning and recommends using register_directories instead
2018-07-04 14:29:35 -04:00
Annie-Claude Côté 1edc7263c8 [ci skip] Update documentation related to `rails notes`
* Get rid of references to rake notes in the documentation
* Get rid of references to environement variables used in SourceAnnotationExtractor
* Updates the command line guide to reflect the new rails notes API
2018-07-03 21:27:22 -04:00
Alberto Almagro d9868d9b61 Remove old TODO comment
This TODO comment has been here more than 7 years and doesn't seem to be
a temporary implementation anymore.
2018-07-04 00:16:12 +02:00
Rafael França cfc48d0b5f
Merge pull request #33054 from jboler/master
Fix route eager loading
2018-07-03 14:04:04 -04:00
Kasper Timm Hansen 350b7cc9f0
Merge pull request #32706 from yhirano55/fix-app-update-when-hyphenated-name-is-given
Fix app:update when hyphenated name is given
2018-07-01 19:05:01 +02:00
utilum 243c856ce9 Fix assignment of TESTOPTS in railties test task
The assignment of `ENV["TESTOPTS"]` to `ARGV`, introduced in
09f9a7a5b, did not take into account passing multiple options,
such as `--verbose --seed=1`. This patch fixes it.
2018-07-01 11:36:17 +02:00
utilum 09f9a7a5b6 Enable TESTOPTS in railties tests
Unlike the other components' test suites, railties' currently
ignores such useful options as `"--verbose"` or `"--name"`.

This patch allows us to use them.
2018-06-26 12:16:23 +02:00
George Claghorn 8888fc03d6
Merge pull request #33191 from bogdanvlviv/change-rails_welcome-image-on-localhost3000
Changes Rails Welcome image on localhost:3000
2018-06-24 15:37:06 -04:00
yuuji.yaginuma df20bf4aa2 Add an assertion that `credentials:edit` works when `RAILS_MASTER_KEY` env is specified 2018-06-24 20:57:41 +09:00
David Rodríguez ee8d7850fd Generate bundler-compatible bundler binstub 2018-06-23 16:58:25 -03:00
David Rodríguez 3b0c1ef9c4 Improve readability of some specs 2018-06-23 14:00:25 -03:00
David Rodríguez d2a91a7f90 Factor out some common bundler mocking logic 2018-06-23 13:52:11 -03:00
Xavier Noria 96d2c228e3 OS X -> macOS [Closes #30313]
[Jon Moss & Xavier Noria]
2018-06-23 08:46:40 +02:00
bogdanvlviv a8fec4fb7c
Changes Rails Welcome image on localhost:3000
Note that I used https://www.base64-image.de/ in order to
convert the image to Base64 with enabled optimization status.

Closes #33181.
Closes #33186.
Follow up #32735.
2018-06-22 15:09:53 +03:00
Jonathan Boler 869ba3ec62 Only execute route updater once on app boot 2018-06-19 16:25:39 -05:00
Rafael França 433a312269
Merge pull request #33152 from bogdanvlviv/fix-ruby-version-file
Fix Ruby version in `.ruby-version`
2018-06-18 17:01:19 -04:00
bogdanvlviv 1aace5e2cc
Fix Ruby version in `.ruby-version`
Since #30016 Rails generates `.ruby-version` file
in order to help Ruby version manager tools like `rbenv`, `rvm`
determine which Ruby version should be used for the current Rails
project.

Since #32649 Rails sets Ruby version to the file compatible with MRI/JRuby
by default.

Pull Request #31496 reports that `.ruby-version` doesn't match ruby version other
than stable version and recommends to use `ENV["RBENV_VERSION"]`, and
`ENV["rvm_ruby_string"]` in order to set correct Ruby version to the file
that `rbenv` or `rvm` can understand.
Also, there is another similar issue that reports the same case if use
JRuby https://github.com/jruby/jruby/issues/5144.

Closes #31496, https://github.com/jruby/jruby/issues/5144.
2018-06-18 19:59:21 +00:00
yuuji.yaginuma a865f621ee Remove unused require
`optparse` is unused since #26977.
2018-06-18 16:16:00 +09:00
bogdanvlviv f1de019993
Include `ActiveSupport::Testing::MethodCallAssertions` in `railties/test/isolation/abstract_unit.rb`
Related to #33102
2018-06-09 00:00:28 +03:00
Jonathan Boler 3674ccd444 Merge branch 'master' of github.com:rails/rails 2018-06-04 12:59:43 -05:00
Jonathan Boler e7758b8b68 Eager load routes on rebuild 2018-06-04 12:56:36 -05:00
yuuji.yaginuma f7fd680a6d Remove unnecessary test
Since #32289, `Spellchecker.suggest` returns only one value, multiple
suggestions not output.
2018-06-03 20:53:05 +09:00
Chirag Shah 94a5125508 Separate min and max threads count for puma
Same environment variable RAILS_MAX_THREADS was being used
for setting the minimum and maximum thread count for puma.
This change makes it obvious and easy to decide which
environment variable to change for setting the min or max.

Don't feel like this is a breaking change as the same
default is maintained.
2018-05-25 06:55:48 +05:30
Rafael Mendonça França 49df9043c6
Merge pull request #30406 from eliotsykes/reduce-spring-watch-calls
Minimize Spring.watch calls
2018-05-23 17:26:09 -04:00
utilum a48f6a5d9f Enable warnings in all test tasks
Also normalize AJ task use t, like all other Rails test tasks.
2018-05-23 23:05:03 +02:00
Rafael França 9480618f06
Merge pull request #32699 from printercu/patch-3
Respect NODE_ENV when running `rails yarn:install`
2018-05-22 17:48:57 -04:00
Guillermo Iguaran e10fd57e98 Bump minimum version of Thor to 0.19.0
Thor 0.18 is causing failures in all the generator tests.
2018-05-22 15:58:35 -05:00
Rafael França 9385a5b585
Merge pull request #32934 from aki77/fix-locale-selector
Fix locale selector to email preview
2018-05-22 15:13:29 -04:00
Ryuta Kamizono a77447f4da Enable `Lint/StringConversionInInterpolation` rubocop rule
To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008
automatically in the future.
2018-05-21 21:10:14 +09:00
yuuji.yaginuma ce4d467f7c Add test case that configure `config.action_view.finalize_compiled_template_methods`
Follow up of #32418.
2018-05-20 10:19:12 +09:00
aki d7f01a28a9 Fix locale selector 2018-05-19 17:23:03 +09:00
Tsukuru Tanimichi 7b0a316f2d Don't generate yarn's contents in `app:update` task if it's skipped 2018-05-16 20:24:57 +09:00
Yuji Yaginuma df850b8d71
Merge pull request #32837 from ttanimichi/app-update-skip-spring
Don't generate `config/spring.rb` in `app:update` task when spring isn't loaded
2018-05-14 07:29:03 +09:00
Tsukuru Tanimichi 8efa112ca6 Don't generate `config/spring.rb` in `app:update` task when spring isn't loaded 2018-05-13 21:51:10 +09:00
Ryuta Kamizono 1dc17e7b2e Fix `CustomCops/AssertNot` to allow it to have failure message
Follow up of #32605.
2018-05-13 11:32:47 +09:00
Tsukuru Tanimichi 9ed1b07b5e Remove unused `remove_file` method
In #32780, We have supported the `--skip-sprockets` option in the `app:update` task.
When `options[:api]` is truthy, `option[:skip_sprockets]` is also truthy. So we can remove this `remove_file` method.
42b9e7e50c/railties/lib/rails/generators/rails/app/app_generator.rb (L281-L283)
2018-05-08 13:56:59 +09:00
yuuji.yaginuma 9a1b99eb01 Skip `bootsnap` contents in `app:update` task if `bootsnap` is not used 2018-05-07 07:56:00 +09:00