提交 2dfe8f1f 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #28486 from y-yagi/add_app_update_for_rails_engine

Add `app:update` task to engines
* Add `app:update` task to engines.
*Yuji Yaginuma*
* Avoid running system tests by default with the `bin/rails test`
and `bin/rake test` commands since they may be expensive.
......
require "rails/generators"
require "rails/generators/rails/plugin/plugin_generator"
module Rails
class Engine
class Updater
class << self
def generator
@generator ||= Rails::Generators::PluginGenerator.new ["plugin"],
{ engine: true }, destination_root: ENGINE_ROOT
end
def run(action)
generator.send(action)
end
end
end
end
end
......@@ -301,7 +301,7 @@ def create_dummy_app(path = nil)
end
def engine?
full? || mountable?
full? || mountable? || options[:engine]
end
def full?
......
task "load_app" do
namespace :app do
load APP_RAKEFILE
desc "Update some initially generated files"
task update: [ "update:bin" ]
namespace :update do
require "rails/engine/updater"
# desc "Adds new executables to the engine bin/ directory"
task :bin do
Rails::Engine::Updater.run(:create_bin_files)
end
end
end
task environment: "app:environment"
......
require "generators/generators_test_helper"
require "rails/generators/rails/plugin/plugin_generator"
require "generators/shared_generator_tests"
require "rails/engine/updater"
DEFAULT_PLUGIN_FILES = %w(
.gitignore
......@@ -731,6 +732,21 @@ def test_generate_application_job_when_does_not_exist_in_mountable_engine
end
end
def test_app_update_generates_bin_file
run_generator [destination_root, "--mountable"]
Object.const_set("ENGINE_ROOT", destination_root)
FileUtils.rm("#{destination_root}/bin/rails")
quietly { Rails::Engine::Updater.run(:create_bin_files) }
assert_file "#{destination_root}/bin/rails" do |content|
assert_match(%r|APP_PATH = File\.expand_path\('\.\./\.\./test/dummy/config/application', __FILE__\)|, content)
end
ensure
Object.send(:remove_const, "ENGINE_ROOT")
end
private
def action(*args, &block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册