From 4dcb630c6eaf7e4d8e450b3e9f19e38ebbf41d8b Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Sun, 5 Nov 2017 13:37:21 +0900
Subject: Generate the correct path in nested scaffold generator

Currently, namespaced scaffold generator will generate an incorrect path
and the generated file will not work properly.

```
$ ./bin/rails g scaffold admin/user
$ ./bin/rails db:migrate
$  ./bin/rails t test/controllers
# Running:

E

Error:
Admin::UsersControllerTest#test_should_create_admin_user:
NameError: undefined local variable or method `admin_admin_users_url' for #<Admin::UsersControllerTest:0x000055a59f25ff68>
Did you mean?  admin_users
    test/controllers/admin/users_controller_test.rb:20:in `block (2 levels) in <class:UsersControllerTest>'
    test/controllers/admin/users_controller_test.rb:19:in `block in <class:UsersControllerTest>'

bin/rails test test/controllers/admin/users_controller_test.rb:18
```

This is because combine `controller_class_path` and `singular_table_name`
to generate route.
https://github.com/rails/rails/blob/360698aa245b45349d1d1b12e1afb34759515e69/railties/lib/rails/generators/named_base.rb#L172

Normally, if using namspaced generator, table name already contains
namespace. Therefore, adding `controller_class_path` adds extra namespace.
Since it is special only when explicitly specifying `model-name`, it is
modified to change the value only when `model-name`is specified.

Follow up of #30729
---
 railties/lib/rails/generators/named_base.rb | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 44f5ab45d3..e0285835a8 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -158,26 +158,26 @@ module Rails
 
         def model_resource_name(prefix: "") # :doc:
           resource_name = "#{prefix}#{singular_table_name}"
-          if controller_class_path.empty?
-            resource_name
-          else
+          if options[:model_name]
             "[#{controller_class_path.map { |name| ":" + name }.join(", ")}, #{resource_name}]"
+          else
+            resource_name
           end
         end
 
         def singular_route_name # :doc:
-          if controller_class_path.empty?
-            singular_table_name
-          else
+          if options[:model_name]
             "#{controller_class_path.join('_')}_#{singular_table_name}"
+          else
+            singular_table_name
           end
         end
 
         def plural_route_name # :doc:
-          if controller_class_path.empty?
-            plural_table_name
-          else
+          if options[:model_name]
             "#{controller_class_path.join('_')}_#{plural_table_name}"
+          else
+            plural_table_name
           end
         end
 
-- 
cgit v1.2.3


From bb6d369f891963f8ed6ec3eeaaba3066c438aaee Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Mon, 6 Nov 2017 16:47:46 +0900
Subject: Remove unused require

Since f182831, this file does not use methods added by `module/introspection`.
---
 railties/lib/rails/generators/named_base.rb | 1 -
 1 file changed, 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index e0285835a8..60625283ac 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -1,6 +1,5 @@
 # frozen_string_literal: true
 
-require "active_support/core_ext/module/introspection"
 require "rails/generators/base"
 require "rails/generators/generated_attribute"
 
-- 
cgit v1.2.3


From 4a835aa3236eedb135ccf8b59ed3c03e040b8b01 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Sun, 6 Aug 2017 20:41:31 +0000
Subject: Add --skip-active-storage and do so automatically when
 --skip-active-record is used

Closes #30102

Revert part 787fe90dc0a7c5b91bb5af51f2858ea8c4676268

--skip-active-storage pass throughs `rails plugin new`

Add changelog entry about default initialization of Active Storage
---
 railties/lib/rails/all.rb                          |   2 +-
 railties/lib/rails/app_updater.rb                  |  11 +-
 railties/lib/rails/generators/app_base.rb          | 123 +++++++++++++--------
 .../rails/generators/rails/app/app_generator.rb    |   8 +-
 .../rails/generators/rails/app/templates/Gemfile   |   3 +-
 .../app/assets/javascripts/application.js.tt       |   2 +
 .../rails/app/templates/config/application.rb      |   2 +-
 .../config/environments/development.rb.tt          |   2 +
 .../templates/config/environments/production.rb.tt |   2 +
 .../app/templates/config/environments/test.rb.tt   |   3 +
 .../rails/generators/rails/app/templates/gitignore |   2 +
 .../generators/rails/plugin/plugin_generator.rb    |   2 +-
 .../generators/rails/plugin/templates/gitignore    |   3 +
 .../rails/plugin/templates/rails/application.rb    |   2 +-
 .../rails/plugin/templates/rails/javascripts.js    |   3 +
 15 files changed, 109 insertions(+), 61 deletions(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb
index e55b2e2433..f5dccd2381 100644
--- a/railties/lib/rails/all.rb
+++ b/railties/lib/rails/all.rb
@@ -4,12 +4,12 @@ require "rails"
 
 %w(
   active_record/railtie
+  active_storage/engine
   action_controller/railtie
   action_view/railtie
   action_mailer/railtie
   active_job/railtie
   action_cable/engine
-  active_storage/engine
   rails/test_unit/railtie
   sprockets/railtie
 ).each do |railtie|
diff --git a/railties/lib/rails/app_updater.rb b/railties/lib/rails/app_updater.rb
index c2436a69f9..a076d082d5 100644
--- a/railties/lib/rails/app_updater.rb
+++ b/railties/lib/rails/app_updater.rb
@@ -21,11 +21,12 @@ module Rails
       private
         def generator_options
           options = { api: !!Rails.application.config.api_only, update: true }
-          options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
-          options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
-          options[:skip_action_cable]  = !defined?(ActionCable::Engine)
-          options[:skip_sprockets]     = !defined?(Sprockets::Railtie)
-          options[:skip_puma]          = !defined?(Puma)
+          options[:skip_active_record]  = !defined?(ActiveRecord::Railtie)
+          options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
+          options[:skip_action_mailer]  = !defined?(ActionMailer::Railtie)
+          options[:skip_action_cable]   = !defined?(ActionCable::Engine)
+          options[:skip_sprockets]      = !defined?(Sprockets::Railtie)
+          options[:skip_puma]           = !defined?(Puma)
           options
         end
     end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index bc00adabae..2809c433f6 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -26,75 +26,78 @@ module Rails
       end
 
       def self.add_shared_options_for(name)
-        class_option :template,           type: :string, aliases: "-m",
-                                          desc: "Path to some #{name} template (can be a filesystem path or URL)"
+        class_option :template,            type: :string, aliases: "-m",
+                                           desc: "Path to some #{name} template (can be a filesystem path or URL)"
 
-        class_option :database,           type: :string, aliases: "-d", default: "sqlite3",
-                                          desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
+        class_option :database,            type: :string, aliases: "-d", default: "sqlite3",
+                                           desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
 
-        class_option :skip_yarn,          type: :boolean, default: false,
-                                          desc: "Don't use Yarn for managing JavaScript dependencies"
+        class_option :skip_yarn,           type: :boolean, default: false,
+                                           desc: "Don't use Yarn for managing JavaScript dependencies"
 
-        class_option :skip_gemfile,       type: :boolean, default: false,
-                                          desc: "Don't create a Gemfile"
+        class_option :skip_gemfile,        type: :boolean, default: false,
+                                           desc: "Don't create a Gemfile"
 
-        class_option :skip_git,           type: :boolean, aliases: "-G", default: false,
-                                          desc: "Skip .gitignore file"
+        class_option :skip_git,            type: :boolean, aliases: "-G", default: false,
+                                           desc: "Skip .gitignore file"
 
-        class_option :skip_keeps,         type: :boolean, default: false,
-                                          desc: "Skip source control .keep files"
+        class_option :skip_keeps,          type: :boolean, default: false,
+                                           desc: "Skip source control .keep files"
 
-        class_option :skip_action_mailer, type: :boolean, aliases: "-M",
-                                          default: false,
-                                          desc: "Skip Action Mailer files"
+        class_option :skip_action_mailer,  type: :boolean, aliases: "-M",
+                                           default: false,
+                                           desc: "Skip Action Mailer files"
 
-        class_option :skip_active_record, type: :boolean, aliases: "-O", default: false,
-                                          desc: "Skip Active Record files"
+        class_option :skip_active_record,  type: :boolean, aliases: "-O", default: false,
+                                           desc: "Skip Active Record files"
 
-        class_option :skip_puma,          type: :boolean, aliases: "-P", default: false,
-                                          desc: "Skip Puma related files"
+        class_option :skip_active_storage, type: :boolean, default: false,
+                                           desc: "Skip Active Storage files"
 
-        class_option :skip_action_cable,  type: :boolean, aliases: "-C", default: false,
-                                          desc: "Skip Action Cable files"
+        class_option :skip_puma,           type: :boolean, aliases: "-P", default: false,
+                                           desc: "Skip Puma related files"
 
-        class_option :skip_sprockets,     type: :boolean, aliases: "-S", default: false,
-                                          desc: "Skip Sprockets files"
+        class_option :skip_action_cable,   type: :boolean, aliases: "-C", default: false,
+                                           desc: "Skip Action Cable files"
 
-        class_option :skip_spring,        type: :boolean, default: false,
-                                          desc: "Don't install Spring application preloader"
+        class_option :skip_sprockets,      type: :boolean, aliases: "-S", default: false,
+                                           desc: "Skip Sprockets files"
 
-        class_option :skip_listen,        type: :boolean, default: false,
-                                          desc: "Don't generate configuration that depends on the listen gem"
+        class_option :skip_spring,         type: :boolean, default: false,
+                                           desc: "Don't install Spring application preloader"
 
-        class_option :skip_coffee,        type: :boolean, default: false,
-                                          desc: "Don't use CoffeeScript"
+        class_option :skip_listen,         type: :boolean, default: false,
+                                           desc: "Don't generate configuration that depends on the listen gem"
 
-        class_option :skip_javascript,    type: :boolean, aliases: "-J", default: false,
-                                          desc: "Skip JavaScript files"
+        class_option :skip_coffee,         type: :boolean, default: false,
+                                           desc: "Don't use CoffeeScript"
 
-        class_option :skip_turbolinks,    type: :boolean, default: false,
-                                          desc: "Skip turbolinks gem"
+        class_option :skip_javascript,     type: :boolean, aliases: "-J", default: false,
+                                           desc: "Skip JavaScript files"
 
-        class_option :skip_test,          type: :boolean, aliases: "-T", default: false,
-                                          desc: "Skip test files"
+        class_option :skip_turbolinks,     type: :boolean, default: false,
+                                           desc: "Skip turbolinks gem"
 
-        class_option :skip_system_test,   type: :boolean, default: false,
-                                          desc: "Skip system test files"
+        class_option :skip_test,           type: :boolean, aliases: "-T", default: false,
+                                           desc: "Skip test files"
 
-        class_option :dev,                type: :boolean, default: false,
-                                          desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
+        class_option :skip_system_test,    type: :boolean, default: false,
+                                           desc: "Skip system test files"
 
-        class_option :edge,               type: :boolean, default: false,
-                                          desc: "Setup the #{name} with Gemfile pointing to Rails repository"
+        class_option :dev,                 type: :boolean, default: false,
+                                           desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
 
-        class_option :rc,                 type: :string, default: nil,
-                                          desc: "Path to file containing extra configuration options for rails command"
+        class_option :edge,                type: :boolean, default: false,
+                                           desc: "Setup the #{name} with Gemfile pointing to Rails repository"
 
-        class_option :no_rc,              type: :boolean, default: false,
-                                          desc: "Skip loading of extra configuration options from .railsrc file"
+        class_option :rc,                  type: :string, default: nil,
+                                           desc: "Path to file containing extra configuration options for rails command"
 
-        class_option :help,               type: :boolean, aliases: "-h", group: :rails,
-                                          desc: "Show this help message and quit"
+        class_option :no_rc,               type: :boolean, default: false,
+                                           desc: "Skip loading of extra configuration options from .railsrc file"
+
+        class_option :help,                type: :boolean, aliases: "-h", group: :rails,
+                                           desc: "Show this help message and quit"
       end
 
       def initialize(*args)
@@ -193,11 +196,29 @@ module Rails
       end
 
       def include_all_railties? # :doc:
-        options.values_at(:skip_active_record, :skip_action_mailer, :skip_test, :skip_sprockets, :skip_action_cable).none?
+        [
+          options.values_at(
+            :skip_active_record,
+            :skip_action_mailer,
+            :skip_test,
+            :skip_sprockets,
+            :skip_action_cable
+          ),
+          skip_active_storage?
+        ].flatten.none?
       end
 
       def comment_if(value) # :doc:
-        options[value] ? "# " : ""
+        question = "#{value}?"
+
+        comment =
+          if respond_to?(question, true)
+            send(question)
+          else
+            options[value]
+          end
+
+        comment ? "# " : ""
       end
 
       def keeps? # :doc:
@@ -208,6 +229,10 @@ module Rails
         !options[:skip_active_record] && options[:database] == "sqlite3"
       end
 
+      def skip_active_storage? # :doc:
+        options[:skip_active_storage] || options[:skip_active_record]
+      end
+
       class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
         def initialize(name, version, comment, options = {}, commented_out = false)
           super
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 46954f64b5..15c5b973ca 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -114,7 +114,7 @@ module Rails
         template "cable.yml" unless options[:skip_action_cable]
         template "puma.rb"   unless options[:skip_puma]
         template "spring.rb" if spring_install?
-        template "storage.yml"
+        template "storage.yml" unless skip_active_storage?
 
         directory "environments"
         directory "initializers"
@@ -139,7 +139,7 @@ module Rails
         template "config/cable.yml"
       end
 
-      if !active_storage_config_exist
+      if !skip_active_storage? && !active_storage_config_exist
         template "config/storage.yml"
       end
 
@@ -355,6 +355,10 @@ module Rails
         build(:system_test) if depends_on_system_test?
       end
 
+      def create_storage_files
+        build(:storage) unless skip_active_storage?
+      end
+
       def create_tmp_files
         build(:tmp)
       end
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile
index 95e8be96b6..ee9db83ca2 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -20,9 +20,10 @@ ruby <%= "'#{RUBY_VERSION}'" -%>
 
 # Use ActiveModel has_secure_password
 # gem 'bcrypt', '~> 3.1.7'
-
+<% unless skip_active_storage? -%>
 # Use ActiveStorage variant
 # gem 'mini_magick', '~> 4.8'
+<% end -%>
 
 # Use Capistrano for deployment
 # gem 'capistrano-rails', group: :development
diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
index 62fd04f113..5183bcd256 100644
--- a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
+++ b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
@@ -12,7 +12,9 @@
 //
 <% unless options[:skip_javascript] -%>
 //= require rails-ujs
+<% unless skip_active_storage? -%>
 //= require activestorage
+<% end -%>
 <% unless options[:skip_turbolinks] -%>
 //= require turbolinks
 <% end -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index dde09edb94..9e03e86771 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -8,10 +8,10 @@ require "rails"
 require "active_model/railtie"
 require "active_job/railtie"
 <%= comment_if :skip_active_record %>require "active_record/railtie"
+<%= comment_if :skip_active_storage %>require "active_storage/engine"
 require "action_controller/railtie"
 <%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
 require "action_view/railtie"
-require "active_storage/engine"
 <%= comment_if :skip_action_cable %>require "action_cable/engine"
 <%= comment_if :skip_sprockets %>require "sprockets/railtie"
 <%= comment_if :skip_test %>require "rails/test_unit/railtie"
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index 98689cc30d..2746aedd6f 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -27,8 +27,10 @@ Rails.application.configure do
     config.cache_store = :null_store
   end
 
+  <%- unless skip_active_storage? -%>
   # Store uploaded files on the local file system (see config/storage.yml for options)
   config.active_storage.service = :local
+  <%- end -%>
   <%- unless options.skip_action_mailer? -%>
 
   # Don't care if the mailer can't send.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
index 2e0b555f6f..4c0f36db98 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -44,9 +44,11 @@ Rails.application.configure do
   # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
   # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
 
+  <%- unless skip_active_storage? -%>
   # Store uploaded files on the local file system (see config/storage.yml for options)
   config.active_storage.service = :local
 
+  <%- end -%>
   <%- unless options[:skip_action_cable] -%>
   # Mount Action Cable outside main process or domain
   # config.action_cable.mount_path = nil
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
index a53978bc6e..a19f490d91 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -28,8 +28,11 @@ Rails.application.configure do
   # Disable request forgery protection in test environment.
   config.action_controller.allow_forgery_protection = false
 
+  <%- unless skip_active_storage? -%>
   # Store uploaded files on the local file system in a temporary directory
   config.active_storage.service = :test
+
+  <%- end -%>
   <%- unless options.skip_action_mailer? -%>
   config.action_mailer.perform_caching = false
 
diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore
index 83a7b211aa..bd6b34346a 100644
--- a/railties/lib/rails/generators/rails/app/templates/gitignore
+++ b/railties/lib/rails/generators/rails/app/templates/gitignore
@@ -21,8 +21,10 @@
 !/tmp/.keep
 <% end -%>
 
+<% unless skip_active_storage? -%>
 # Ignore uploaded files in development
 /storage/*
+<% end -%>
 
 <% unless options.skip_yarn? -%>
 /node_modules
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index d9ca4712d0..bc2dcf008e 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -87,7 +87,7 @@ task default: :test
     end
 
     PASSTHROUGH_OPTIONS = [
-      :skip_active_record, :skip_action_mailer, :skip_javascript, :skip_action_cable, :skip_sprockets, :database,
+      :skip_active_record, :skip_active_storage, :skip_action_mailer, :skip_javascript, :skip_action_cable, :skip_sprockets, :database,
       :javascript, :skip_yarn, :api, :quiet, :pretend, :skip
     ]
 
diff --git a/railties/lib/rails/generators/rails/plugin/templates/gitignore b/railties/lib/rails/generators/rails/plugin/templates/gitignore
index e15863d860..7a68da5c4b 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/gitignore
+++ b/railties/lib/rails/generators/rails/plugin/templates/gitignore
@@ -11,5 +11,8 @@ pkg/
 <%= dummy_path %>/node_modules/
 <%= dummy_path %>/yarn-error.log
 <% end -%>
+<% unless skip_active_storage? -%>
+<%= dummy_path %>/storage/
+<% end -%>
 <%= dummy_path %>/tmp/
 <% end -%>
diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
index 47b56ae3df..06ffe2f1ed 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
+++ b/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
@@ -8,10 +8,10 @@ require "rails"
 require "active_model/railtie"
 require "active_job/railtie"
 <%= comment_if :skip_active_record %>require "active_record/railtie"
+<%= comment_if :skip_active_storage %>require "active_storage/engine"
 require "action_controller/railtie"
 <%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
 require "action_view/railtie"
-require "active_storage/engine"
 <%= comment_if :skip_action_cable %>require "action_cable/engine"
 <%= comment_if :skip_sprockets %>require "sprockets/railtie"
 <%= comment_if :skip_test %>require "rails/test_unit/railtie"
diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
index e54c6461cc..f3d80c87f5 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
+++ b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
@@ -10,4 +10,7 @@
 // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
 // about supported directives.
 //
+<% unless skip_active_storage? -%>
+//= require activestorage
+<% end -%>
 //= require_tree .
-- 
cgit v1.2.3


From 0835527d6bb970cedd33633503506e41156ab780 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Mon, 7 Aug 2017 04:31:14 +0000
Subject: `rails new` runs `rails active_storage:install`

Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests

AppGeneratorTest#test_config_jdbcmysql_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_config_jdbc_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_shebang_is_added_to_rails_file

  /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError)

Prevent PendingMigrationError in tests

 * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError
 * FileUtils.rm_r("db/migrate")
 * --skip-active-storage

Fix failed tests in `railties/test/railties/engine_test.rb`

Related to #30111

Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed`

 - Explicitly skip active_storage
 - Ensure that skipped frameworks are commented
 - Ensure that default frameworks are not commented

Fix error `Errno::ENOSPC: No space left on device - sendfile`

Since `rails new` runs `rails active_storage:install`
that boots an app.

Since adding Bootsnap 0312a5c67e35b960e33677b5358c539f1047e4e1
during booting an app, it creates the cache:

   264K    tmp/cache/bootsnap-load-path-cache
   27M     tmp/cache/bootsnap-compile-cache

* teardown_app must remove app
---
 railties/lib/rails/generators/app_base.rb                | 6 ++++++
 railties/lib/rails/generators/rails/app/app_generator.rb | 1 +
 2 files changed, 7 insertions(+)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 2809c433f6..4f3ecd9189 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -459,6 +459,12 @@ module Rails
         end
       end
 
+      def run_active_storage
+        unless skip_active_storage?
+          rails_command "active_storage:install"
+        end
+      end
+
       def empty_directory_with_keep_file(destination, config = {})
         empty_directory(destination, config)
         keep_file(destination)
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 15c5b973ca..1c32fad3ea 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -461,6 +461,7 @@ module Rails
 
       public_task :apply_rails_template, :run_bundle
       public_task :run_webpack, :generate_spring_binstubs
+      public_task :run_active_storage
 
       def run_after_bundle_callbacks
         @after_bundle_callbacks.each(&:call)
-- 
cgit v1.2.3


From f4af77ab5d6f5bd3b045f676978bc2a4677cee38 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Wed, 11 Oct 2017 10:08:10 +0300
Subject: Rails::Generators::Actions#execute_command allows option `capture`

---
 railties/lib/rails/generators/actions.rb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 9800e5750a..3362bf629a 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -221,6 +221,7 @@ module Rails
       #   rake("db:migrate")
       #   rake("db:migrate", env: "production")
       #   rake("gems:install", sudo: true)
+      #   rake("gems:install", capture: true)
       def rake(command, options = {})
         execute_command :rake, command, options
       end
@@ -230,6 +231,7 @@ module Rails
       #   rails_command("db:migrate")
       #   rails_command("db:migrate", env: "production")
       #   rails_command("gems:install", sudo: true)
+      #   rails_command("gems:install", capture: true)
       def rails_command(command, options = {})
         execute_command :rails, command, options
       end
@@ -292,7 +294,11 @@ module Rails
           log executor, command
           env  = options[:env] || ENV["RAILS_ENV"] || "development"
           sudo = options[:sudo] && !Gem.win_platform? ? "sudo " : ""
-          in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) }
+          config = { verbose: false }
+
+          config.merge!(capture: options[:capture]) if options[:capture]
+
+          in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", config) }
         end
 
         # Add an extension to the given name based on the platform.
-- 
cgit v1.2.3


From cb8553c95d345e40b448cf8e10aa033ff0ede4f2 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Wed, 11 Oct 2017 10:11:35 +0300
Subject: Execution of `active_storage:install` should respect `--quiet` during
 `rails new`

---
 railties/lib/rails/generators/app_base.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 4f3ecd9189..59ca4c849f 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -461,7 +461,7 @@ module Rails
 
       def run_active_storage
         unless skip_active_storage?
-          rails_command "active_storage:install"
+          rails_command "active_storage:install", capture: options[:quiet]
         end
       end
 
-- 
cgit v1.2.3


From 38158451103be572d6e81e971797938df7bd22ea Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Tue, 7 Nov 2017 14:23:16 +0900
Subject: Fix comment in `check_class_collision` [ci skip]

`ScaffoldBase` was changed to `ResourceHelpers` by 0efedf2.
---
 railties/lib/rails/generators/named_base.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 60625283ac..99165168fd 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -221,7 +221,7 @@ module Rails
         #
         def self.check_class_collision(options = {}) # :doc:
           define_method :check_class_collision do
-            name = if respond_to?(:controller_class_name) # for ScaffoldBase
+            name = if respond_to?(:controller_class_name) # for ResourceHelpers
               controller_class_name
             else
               class_name
-- 
cgit v1.2.3


From 67db41aa7f17c2d34eb5a914ac7a6b2574930ff4 Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Wed, 8 Nov 2017 12:15:27 +0900
Subject: Do not run `active_storage:install` when bundle install is skipped

In order to execute the `rails` command, need to run bundle install in
advance.
Therefore, if skipped bundle install, `rails` command may fail and
should not do it.
---
 railties/lib/rails/generators/app_base.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 59ca4c849f..60e54cc365 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -461,7 +461,11 @@ module Rails
 
       def run_active_storage
         unless skip_active_storage?
-          rails_command "active_storage:install", capture: options[:quiet]
+          if bundle_install?
+            rails_command "active_storage:install", capture: options[:quiet]
+          else
+            log("Active Storage installation was skipped. Please run 'bin/rails active_storage:install' to install Active Storage files.")
+          end
         end
       end
 
-- 
cgit v1.2.3


From 6f123341d9e8807bb83c6a8214ec54d3b52c82a3 Mon Sep 17 00:00:00 2001
From: bogdanvlviv <bogdanvlviv@gmail.com>
Date: Wed, 8 Nov 2017 22:07:12 +0000
Subject: Change output log about skipping instalation of Active Storage

Using of "`" is preferable over "'" to express console command in output log
---
 railties/lib/rails/generators/app_base.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 60e54cc365..bdeddff645 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -464,7 +464,7 @@ module Rails
           if bundle_install?
             rails_command "active_storage:install", capture: options[:quiet]
           else
-            log("Active Storage installation was skipped. Please run 'bin/rails active_storage:install' to install Active Storage files.")
+            log("Active Storage installation was skipped. Please run `bin/rails active_storage:install` to install Active Storage files.")
           end
         end
       end
-- 
cgit v1.2.3


From d1e0bc7c17b1be2766e9fca228b4c61e01988b34 Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Thu, 9 Nov 2017 20:54:24 +0900
Subject: Do not show credentials in generators help

Since credentials generator is executed via the credentials command and
does not need to be executed directly, so it is not necessary to show it in
help.
---
 railties/lib/rails/generators.rb | 1 +
 1 file changed, 1 insertion(+)

(limited to 'railties/lib')

diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 2d265818f7..5592e8d78e 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -218,6 +218,7 @@ module Rails
         rails.delete("app")
         rails.delete("plugin")
         rails.delete("encrypted_secrets")
+        rails.delete("credentials")
 
         hidden_namespaces.each { |n| groups.delete(n.to_s) }
 
-- 
cgit v1.2.3