Commit Graph

12918 Commits

Author SHA1 Message Date
Xavier Noria 57c7cbb162 depend on Zeitwerk 2 2019-04-07 13:05:26 +02:00
Fumiaki MATSUSHIMA 61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
Ryuta Kamizono 464d625324 Remove redundant begin block
We have `Style/RedundantBegin` cop (#34764) but it could not correct in
this case.
2019-04-04 09:44:51 +09:00
Ryuta Kamizono 0908184e4c Use `execute_batch2` rather than `execute_batch` to fix performance regression for fixture loading
d8d6bd5 makes fixture loading to bulk statements by using
`execute_batch` for sqlite3 adapter. But `execute_batch` is slower and
it caused the performance regression for fixture loading.

In sqlite3 1.4.0, it have new batch method `execute_batch2`. I've
confirmed `execute_batch2` is extremely faster than `execute_batch`.
So I think it is worth to upgrade sqlite3 to 1.4.0 to use that method.

Before:

```
% ARCONN=sqlite3 bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_loading_too_may_ids
Using sqlite3
Run options: -n test_eager_loading_too_may_ids --seed 35790

# Running:

.

Finished in 202.437406s, 0.0049 runs/s, 0.0049 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
ARCONN=sqlite3 bundle exec ruby -w -Itest  -n test_eager_loading_too_may_ids  142.57s user 60.83s system 98% cpu 3:27.08 total
```

After:

```
% ARCONN=sqlite3 bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_loading_too_may_ids
Using sqlite3
Run options: -n test_eager_loading_too_may_ids --seed 16649

# Running:

.

Finished in 8.471032s, 0.1180 runs/s, 0.1180 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
ARCONN=sqlite3 bundle exec ruby -w -Itest  -n test_eager_loading_too_may_ids  10.71s user 1.36s system 95% cpu 12.672 total
```
2019-04-04 03:27:46 +09:00
Benoit Daloze f069ac2156 Add test that the listen gem is included when RUBY_ENGINE is not 'ruby'
* The fix is already in master since https://github.com/rails/rails/pull/34243
* See https://github.com/rails/rails/pull/35482 for the fix in Rails 5.2
2019-04-03 15:45:27 +02:00
Ryuta Kamizono fe006083ea Don't normalize `original_app_name`
`original_app_name` is used to show error message if giving app name is
invalid, it should be shown raw app name.
2019-04-03 17:56:04 +09:00
Ryuta Kamizono b2209ca59d Auto-correct rubocop offences 2019-04-03 08:40:15 +09:00
Rafael França 6c6c579a9b
Merge pull request #35805 from excid3/attachments-field-generators
Add attachment and attachments field generators
2019-04-02 19:13:25 -04:00
Eileen M. Uchitelle 2c4dab11d1
Merge pull request #35768 from robertomiranda/r/rake-db-prepare
Add db:prepare rake task.
2019-04-02 15:33:57 -04:00
Roberto Miranda 1c7dcffb64 Add migration in case of db:drop assertion 2019-04-02 17:50:28 +01:00
Roberto Miranda 900e566a6b 💇 2019-04-02 17:04:32 +01:00
Roberto Miranda 098e4d25f1 Add test cases for rake db:prepare 2019-04-02 16:25:48 +01:00
Yuji Yaginuma ef5ebd93d6
Merge pull request #35703 from y-yagi/add_database_option_to_dbconsole_command
Rename `connection` option to `database` in `dbconsole` command
2019-04-02 16:30:46 +09:00
Abhay Nikam 2bfad29d0e [ci skip] Fix typo for recieve -> receive 2019-04-02 10:31:06 +05:30
yuuji.yaginuma 29b16d3ff8 Rename `connection` option to `database` in `dbconsole` command
We introduced `connection` option for specifying spec with 1acd9a6464.
But now we are using the `database` to specify the same value in other commands.

* 0a0f115031/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb (L11)
* 0a0f115031/activerecord/lib/rails/generators/active_record/model/model_generator.rb (L17)

The options provided to the users should be uniform. Since the term
"database" is used in rake task etc, So I want to be able to use it in
`dbconsole` command.

Also I deprecated the `connection` option because I think that it
would be confusing if there are multiple options to specify a same value.
2019-04-02 13:15:55 +09:00
Connor Shea 0c0a69b5fa
Add Changelog entry for #35732. 2019-04-01 18:57:13 -06:00
Ryuta Kamizono e4e1218583
Merge pull request #35820 from sharang-d/url-to-URL-except-actionpack
url -> URL where apt except inside actionpack/
2019-04-02 03:26:31 +09:00
Sharang Dashputre 771973c13d url -> URL where apt except inside actionpack/ 2019-04-01 22:56:35 +05:30
Orhan Toy db4c6f5ecb Include final newline in generated .ruby-version 2019-04-01 18:39:15 +02:00
Ryuta Kamizono b89a3e7e63 Tweaks CHANGELOGs and docs [ci skip]
* add leading `#` before `=>` since hash rocket is valid Ruby code
* add backticks
* remove trailing spaces
* and more
2019-03-31 08:38:37 +09:00
Chris Oliver ecdcf06cb2 Add attachment and attachments field generators 2019-03-30 12:15:17 -05:00
Abhay Nikam 759c4ff0ed [ci skip] Fix typo directores -> directories 2019-03-30 17:50:37 +05:30
Xavier Noria a3e061def1 optimizes eager loading in :zeitwerk mode
During initialization, the eager load paths of engines are unshifted
into AS::Dependencies.autoload_paths. After that, the collection is
frozen. (See the initializers in railties/lib/rails/engine.rb.)

Hence, there is no eager load path that is not an autoload path too, and
so the array difference in the deleted code is always an empty array.

Just do nothing.
2019-03-30 13:01:42 +01:00
Xavier Noria 278f0dfeac fixes eager loading edge case in :zeitwerk mode 2019-03-30 09:33:48 +01:00
Chris Oliver 19a29c6556 Add rich_text field to model generators 2019-03-28 23:58:33 -05:00
Xavier Noria 379d7e8bfa bumps Zeitwerk and Bootsnap 2019-03-26 20:30:18 +01:00
Sharang Dashputre 51171413bb Reword test names in credentials_test.rb 2019-03-25 12:44:51 +05:30
Vipul A M 6a5c8b9199
Cleanup guide for configuring config.disable_sandbox and related changelog [ci skip] (#35733) 2019-03-25 03:14:51 +05:30
Guillermo Iguaran df51b75f12
Merge pull request #35732 from rails/webdrivers
Replace chromedriver-helper with webdrivers
2019-03-24 16:33:24 -05:00
Guillermo Iguaran b4ca05ea43
Merge pull request #35723 from sikachu/disable-sandbox-flag
Add config.disable_sandbox option to Rails console
2019-03-24 16:22:21 -05:00
Guillermo Iguaran 895edbcf40 Use webdrivers instead of chromedriver-helper in new apps 2019-03-24 16:08:09 -05:00
Yuji Yaginuma 122853dc54
Merge pull request #35718 from y-yagi/add_secret_key_base_when_creating_new_credentials
Add `secret_key_base` when creating new credential file
2019-03-24 09:44:13 +09:00
Prem Sichanugrist b27105252b Add config.disable_sandbox option to Rails console
A long-running `rails console --sandbox` could cause a database server
to become out-of-memory as it's holding on to changes that happen on the
database.

Given that it's common for Ruby on Rails application with huge
traffic to have separate write database and read database, we should
allow the developers to disable this sandbox option to prevent someone
from accidentally causing the Denial-of-Service on their server.
2019-03-23 19:31:03 +09:00
John Hawthorn d0334b8f01 Update comment for how secret key is calculated
This updates the comment to reflect how the secret key is generated
since 4c743587ad

Fixes #35717
2019-03-22 17:59:41 -07:00
yuuji.yaginuma 0e9e59953f Add `secret_key_base` when creating new credential file
Since `secret_key_base` is expected to be included in credential file,
`secret_key_base` should be included even if re-create the file. This is
the same behavior as creating a new app.
When env is specified, it may be unnecessary, so I added it only when not
specifying env.
2019-03-23 09:07:57 +09:00
John Hawthorn 5c2d695993 Update CHANGELOGs for 6.0.0.beta3 release 2019-03-22 13:13:01 -07:00
yuuji.yaginuma efb706daad Fix server restart test on Puma 3.12.1
Since https://github.com/puma/puma/pull/1700, the default host is
correctly used. So `localhost` is used instead of `0.0.0.0`.

As a result, the log output on restart is changed, and the restart test
fails on Puma 3.12.1.
https://travis-ci.org/rails/rails/jobs/509239592#L2303-L2305

Specify binding explicitly to avoid being affected by Puma changes.
2019-03-22 07:49:38 +09:00
Eileen M. Uchitelle d369911478
Merge pull request #35661 from jhawthorn/lookup_context_validation
Validate types assigned to LookupContext#formats=
2019-03-20 11:52:55 -04:00
yuuji.yaginuma e5d7b98fbd Make aliases of `database` option in generators work
Thor automatically adds `-` if aliases do not start with `-`.
0879c1773d/lib/thor/parser/options.rb (L53)

But Thor follows a convention of one-dash-one-letter options.
So, even if `-` is added to `db`, it does not work.
0879c1773d/lib/thor/parser/options.rb (L4)

Follow up #34021.
2019-03-20 14:52:01 +09:00
Nicholas La Roux 49f4625b70
Revert "Revert "Remove `javascripts` and `javascript_engine` options for generators"" 2019-03-20 09:48:51 +09:00
Rafael França f88ea5fd74
Merge pull request #35656 from larouxn/revert-34277-remove-javascripts-javascripts_engine-options-for-generators
Revert "Remove `javascripts` and `javascript_engine` options for generators"
2019-03-19 16:37:14 -04:00
Nicholas La Roux d82839b0ee
Revert "Remove `javascripts` and `javascript_engine` options for generators" 2019-03-19 08:22:07 +09:00
John Hawthorn 663548845b Use symbol for mail preview format, not string 2019-03-18 16:06:31 -07:00
eileencodes 8f3066fccc Fix database configuration when adding another config level
This is kind of hard to explain but if you have a database config with
another level like this:

```
development:
  primary:
    database: "my db"
    variables:
      statement_timeout: 1000
```

the database configurations code would chooke on the `variables` level
because it didn't know what to do with it.

We'd see the following error:

```
lib/active_record/database_configurations.rb:72:in
`block in find_db_config': undefined method `env_name' for [nil]:Array
(NoMethodError)
```

The problem here is that Rails does correctly identify this as not a
real configuration but returns `[nil]` along with the others. We need to
make sure to flatten the array and remove all the `nil`'s before
returning the `configurations` objects.

Fixes #35646
2019-03-18 16:23:00 -04:00
प्रथमेश Sonpatki 0e94a513fe
Added release notes for changes in Railties [ci skip] (#35622)
[Alex Kitchens, Prathamesh Sonpatki]
2019-03-18 22:41:53 +05:30
yuuji.yaginuma 6f94260ac6 Add -e/--environment option to `rails initializers`
This allows specifying the environment as would any other rails commands.
2019-03-16 10:02:06 +09:00
Xavier Noria a47c84d584 Engines are reloaded in Zeitwerk mode [closes #35618] 2019-03-15 22:59:03 +01:00
yuuji.yaginuma c801b232bc Properly expand the environment's name in all commands
Since 3777701f13, the environment's name is
automatically expanded in console and dbconsole commands.
In order to match the behavior between the commands, fixes it to have the
same behavior of all the commands.

This behavior is defined in `EnvironmentArgument`. Since
`EnvironmentArgument` also defines the environment option, it is reused.

However, since desc was not content that can be used in all comments,
fixed desc to be defined for each command.
2019-03-15 07:43:10 +09:00
yuuji.yaginuma 0187053109 Make application work without tmp directory
The tmp directory is added to version control in the newly created
application. This was added in Rails 5.0.0(f06ce4c12a).

However, applications created before that are not guaranteed to have the
tmp directory. If the tmp directory does not exist, writing to the key file
raise error.

This is a bit incompatible. So I fixed that create the directory before
writing a key.
2019-03-14 16:14:15 +09:00
eileencodes e0c6bce203 Fix secret_key_base for Railties
This was missed in the security fix for local dev. CI doesn't have a tmp
directory in the apps built for testing so these end up failing. This
adds the secret_key_base so we don't need to generate one.
2019-03-13 16:41:29 -04:00