Commit Graph

6462 Commits

Author SHA1 Message Date
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
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
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
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
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
Yuji Yaginuma
42b9e7e50c
Merge pull request #32780 from ttanimichi/tmp
Don't generate assets' initializer in `app:update` task if sprockets is skipped
2018-05-05 14:02:08 +09:00
Tsukuru Tanimichi
59c3d539ab Don't generate assets' initializer in app:update task if sprockets is skipped
Execute `rails new myapp -S` and then upgrade the app by using the `app:update` task, `bin/rails c` results in `NoMethodError`.

```
$ bin/rails app:update

$ bin/rails c
Traceback (most recent call last):
    44: from bin/rails:4:in `<main>'
(snip)
     1: from /Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/config/initializers/assets.rb:4:in `<top (required)>'
/Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie/configuration.rb:97:in `method_missing': undefined method `assets' for #<Rails::Application::Configuration:0x00007fcb8d3697e0> (NoMethodError)
Did you mean?  asset_host
```
2018-05-05 13:27:55 +09:00
utilum
52a41974c2 Partly revert #32289 to provide Rails' custom fallback in case
`DidYouMean::SpellChecker` is not defined.
`did_you_mean` is bundled in Ruby but can be uninstalled, and is not always
available, sometimes even on our CI:

https://travis-ci.org/rails/rails/jobs/372638523#L2405
https://travis-ci.org/rails/rails/jobs/372638523#L2416
https://travis-ci.org/rails/rails/jobs/372638523#L2427
...
2018-05-01 18:09:05 +02:00
George Claghorn
ef5902a2f1
Merge pull request #32471 from janko-m/use-image_processing-gem
Use ImageProcessing gem for ActiveStorage variants
2018-04-23 16:01:16 -05:00
printercu
8e9186d241 Respect NODE_ENV when running rails yarn:install
`yarn install --prod` removes dev deps,
so it's impossible to run `assets:precompile` with dev npm dependencies.
This change makes rake task pass NODE_ENV to yarn when explicitly set.
2018-04-23 20:37:26 +03:00
Guillermo Iguaran
7316f3696a
Merge pull request #31554 from fatkodima/controller_generator_suffix
Gracefully handle extra "controller" when generating controller
2018-04-22 03:23:46 -05:00
Ryuta Kamizono
e4a0a04883 Strip duplicated suffixes more strictly
In the previous code incorrectly removes intermediate words.
2018-04-22 14:30:07 +09:00
Yoshiyuki Hirano
8e2c91df4a Fix duplicated suffix for JobGenerator 2018-04-22 12:09:04 +09:00
Guillermo Iguaran
b10f371366 Don't include bootsnap by default in apps generated under JRuby 2018-04-20 12:17:15 -05:00
Alberto Almagro
cc1ae52cfb [ci skip] Prefix class name with Rails:: in docs
After renaming and deprecation of SourceAnnotationExtractor
documentation has been updated to reflect the new name Rails::SourceAnnotationExtractor
2018-04-20 18:45:43 +02:00
Alberto Almagro
36f710f6b5 [ci skip] Improve #find_in documentation.
The previous documentation version listed only the default
registered extensions. This was misleading because if more extensions
get registered with
<tt>SourceAnnotationExtractor::Annotation.register_extensions</tt>,
they would be also taken into account. By saying that we consider
all registered extensions we document what happens in reality.
2018-04-20 18:45:19 +02:00
Guillermo Iguaran
2bf11187ee Create a .ruby-version compatible with MRI/JRuby by default 2018-04-19 16:13:41 -05:00
Jose Luis Duran
4c6c3575c6
Make the master.key readable only by the owner
This change may only apply to POSIX-compliant systems.

Previously:

    $ ls -l config/master.key
    -rw-r--r--   1 owner  group      32 Jan 1 00:00 master.key

Now:

    $ ls -l config/master.key
    -rw-------   1 owner  group      32 Jan 1 00:00 master.key
2018-04-19 08:44:08 -03:00
Janko Marohnić
ca12968587
Use ImageProcessing gem for ActiveStorage variants
ImageProcessing gem is a wrapper around MiniMagick and ruby-vips, and
implements an interface for common image resizing and processing. This
is the canonical image processing gem recommended in [Shrine], and
that's where it developed from. The initial implementation was extracted
from Refile, which also implements on-the-fly transformations.

Some features that ImageProcessing gem adds on top of MiniMagick:

  * resizing macros
    - #resize_to_limit
    - #resize_to_fit
    - #resize_to_fill
    - #resize_and_pad
  * automatic orientation
  * automatic thumbnail sharpening
  * avoids the complex and inefficient MiniMagick::Image class
  * will use "magick" instead of "convert" on ImageMagick 7

However, the biggest feature of the ImageProcessing gem is that it has
an alternative implementation that uses libvips. Libvips is an
alternative to ImageMagick that can process images very rapidly (we've
seen up 10x faster than ImageMagick).

What's great is that the ImageProcessing gem provides the same interface
for both implementations. The macros are named the same, and the libvips
implementation does auto orientation and thumbnail sharpening as well;
only the operations/options specific to ImageMagick/libvips differ. The
integration provided by this PR should work for both implementations.

The plan is to introduce the ImageProcessing backend in Rails 6.0 as the
default backend and deprecate the MiniMagick backend, then in Rails 6.1
remove the MiniMagick backend.
2018-04-18 17:46:25 +02:00
Yuji Yaginuma
37b373a8d2
Deprecate support for using HOST environment to specify server IP (#32540)
At SuSE, `$HOST` is set by default and is equal to `$HOSTNAME`.
https://www.suse.com/documentation/sled11/book_sle_admin/data/sec_adm_variables.html

Therefore, by default, it binds to hostname instead of `localhost`.
This seems not to be appropriate as default behavior.

In order to avoid the name of the environment variable being used,
I changed the environment variable from `HOST` to `BINDING`.

Fixes #29516.
2018-04-16 14:35:13 +09:00
Paul
b17cdfe8e0
Add .keep exception for storage folder
Fixes https://github.com/rails/rails/issues/32546 by including the `.keep` file in the .gitignore, bringing the `storage` folder in line with the `tmp` and `log` folders.
2018-04-13 09:40:48 -04:00
yuuji.yaginuma
686f4f3a94 Allow use of minitest-rails gem with Rails test runner
Add explicit global namespace to `Rails::TestUnit::Runner` to resolve a
namespace conflict between `minitest-rails` and Rails test runner.

Fixes #31324
2018-04-11 07:20:53 +09:00
eileencodes
72f17d59e4 Remove upper bound on Capybara
There's no reason to block future versions of Capybara since we don't
_know_ they are going to break. How will we know if we have a
conservative option set? This change prevents us from blocking users who
want to upgrade in the future.
2018-04-10 16:40:14 -04:00
Rafael Mendonça França
826b17cd8a
Merge pull request #32444 from matrinox/fix-return-response-mutation-rack-logger
Stop mutating body response
2018-04-04 18:17:16 -04:00
Geoff Lee
0ac64470ea
Stop mutating body response
If @app.call returns an object that is saved (for e.g., in a constant), the mutation results in a continuing cycle of wrapping the body in Rack::BodyProxy, eventually leading to SystemStackError
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On branch fix-return-response-mutation-rack-logger - Tue  3 Apr 2018 19:54:28 PDT by Geoff Lee <geoff.lee@lendesk.com>
2018-04-03 19:54:27 -07:00
bogdanvlviv
74e91263cb
Add missing dots at the end of comments in environment file templates
Add dots in order to keep consistency between other comments in these files.
2018-04-03 16:52:53 +03:00
Simon Coffey
eede8d8130 Add action_view.finalize_compiled_template_methods config option
ActionView::Template instances compile their source to methods on the
ActionView::CompiledTemplates module. To prevent leaks in development
mode, where templates can frequently change, a finalizer is added that
undefines these methods[1] when the templates are garbage-collected.

This is undesirable in the test environment, however, as templates don't
change during the life of the test. Moreover, the cost of undefining a
method is proportional to the number of descendants a class or module
has, since the method cache must be cleared for all descendant classes.

As ActionView::CompiledTemplates is mixed into every
ActionView::TestCase (or in RSpec suites, every view spec example
group), it can end up with a very large number of descendants, and
undefining its methods can become very expensive.

In large test suites, this results in a long delay at the end of the
test suite as all template finalizers are run, only for the process to
then exit.

To avoid this unnecessary cost, this change adds a config option,
`action_view.finalize_compiled_template_methods`, defaulting to true,
and sets it to false in the test environment only.

[1] 09b2348f7f/actionview/lib/action_view/template.rb (L118-L126)
2018-04-02 20:50:33 +01:00
Kasper Timm Hansen
0ec23effa7
Merge pull request #32065 from sikachu/move-SourceAnnotationExtractor-under-rails-namespec
Move SourceAnnotationExtractor under Rails module
2018-04-02 16:15:52 +02:00
Yoshiyuki Kinjo
7419a4f911 Deriving secret_key_base breaks key_generator defined in 5.1.
If one created Rails 5.1 app and then updated to 5.2,
`secret_key_base` defined in `config/secrets.yml` is ignored for
`development` and `test` environment.
A change in `secret_key_base` in turn breaks
`Rails.application.key_generator`.

If one encrypt data in Rails 5.1, she cannot decrypt it in Rails 5.2
for `development` and `test` environment.
2018-03-31 23:12:16 +09:00
yuuji.yaginuma
06332d5867 Remove unnecessary line break and quotes 2018-03-30 07:58:50 +09:00
Guillermo Iguaran
f9ec3e5cc3
Fix "--frozen-lockfile" argument used in yarn install rake task
--frozen-lockfile is the right name of the argument
2018-03-29 11:53:25 -05:00
Guillermo Iguaran
480595e491
Merge pull request #32289 from gsamokovarov/did-you-mean-suggestions
Use `did_you_mean` spell checker for option suggestions
2018-03-29 11:05:47 -05:00
Guillermo Iguaran
1765f09b10
Merge pull request #32243 from maschwenk/patch-2
[Webpack] Raise an error when lockfile diff is generated
2018-03-29 11:02:49 -05:00
Shia
0014790b2a
Compare ruby version with correct way 2018-03-29 16:26:19 +09:00
Eileen M. Uchitelle
93e6b5c27b
Merge pull request #32274 from eileencodes/part-1-add-rake-tasks-for-multi-db
Part 1 Easy Multi db in Rails: Add basic rake tasks for multi db setup
2018-03-26 16:37:21 -04:00
fatkodima
6df0bd156a Gracefully handle extra "controller" when generating controller 2018-03-23 19:09:59 +02:00
Genadi Samokovarov
cb25f2c989 Use did_you_mean spell checker for option suggestions
Now that we require Ruby over `2.3`, we can replace the current
suggestion methods we have with tooling from the `did_you_mean` gem.

There is a small user visible change and this is that we now offer a
single suggestion for misspelled options. We are suggesting fixes during
generator invocation and during a mistyped rails server rack handler. In
both cases, if we don't make a proper prediction on the first match, we
won't do so in the second or third one, so in my mind, this is okay.
2018-03-23 11:36:03 +02:00
Prem Sichanugrist
92dac547fd Add deprecation note for SourceAnnotationExtractor 2018-03-22 17:06:15 +00:00
Prem Sichanugrist
1638d3c075 Make Annotation into a proper class
This cleans up the documentation for SourceAnnotationExtractor because
RDoc does not seems to know how to parse `Struct.new() do` block.
2018-03-22 17:06:14 +00:00
Prem Sichanugrist
67cc450086 Move SourceAnnotationExtractor under Rails module
This class should be under Rails module as it belongs to Rails.
2018-03-22 17:06:14 +00:00
eileencodes
4e663c1e8d Refactor configs_for and friends
Moves the configs_for and DatabaseConfig struct into it's own file. I
was considering doing this in a future refactoring but our set up forced
me to move it now. You see there are `mattr_accessor`'s on the Core
module that have default settings. For example the `schema_format`
defaults to Ruby. So if I call `configs_for` or any methods in the Core
module it will reset the `schema_format` to `:ruby`. By moving it to
it's own class we can keep the logic contained and avoid this
unfortunate issue.

The second change here does a double loop over the yaml files. Bear with
me...

Our tests dictate that we need to load an environment before our rake
tasks because we could have something in an environment that the
database.yml depends on. There are side-effects to this and I think
there's a deeper bug that needs to be fixed but that's for another
issue. The gist of the problem is when I was creating the dynamic rake
tasks if the yaml that that rake task is calling evaluates code (like
erb) that calls the environment configs the code will blow up because
the environment is not loaded yet.

To avoid this issue we added a new method that simply loads the yaml and
does not evaluate the erb or anything in it. We then use that yaml to
create the task name. Inside the task name we can then call
`load_config` and load the real config to actually call the code
internal to the task. I admit, this is gross, but refactoring can't all
be pretty all the time and I'm working hard with `@tenderlove` to
refactor much more of this code to get to a better place re connection
management and rake tasks.
2018-03-21 16:54:24 -04:00
Aaron Stone
9f5477af93 Support mysql2 0.4.x and 0.5.x 2018-03-20 23:38:00 -07:00
Eileen M. Uchitelle
9700dacffe
Merge pull request #32271 from eileencodes/fix-three-tier-default-connection
Fix default connection handling with three-tier config
2018-03-16 15:18:26 -04:00
eileencodes
4027643f7f Switch dbconsole config loader check
In a three-tier config environment
`configurations[environment].presence` will return `{ :primary => {
:key => value, :key => value }, :secondary => { :key => value, :key =>
value} }, which means it's not given a single config to connect to.

If we flip these however it will connect to primary because that's the
default connection, and on a two tier it will be `nil` so the code will
select the connection from the configurations rather than the
connection.
2018-03-16 12:40:34 -04:00