From 02499892a20c14073f59ea1929caf8f1bd4a8c21 Mon Sep 17 00:00:00 2001
From: Yoshiyuki Hirano <yhirano@me.com>
Date: Sun, 6 Aug 2017 15:07:46 +0900
Subject: Fix engine command

---
 railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt | 2 ++
 railties/test/generators/plugin_generator_test.rb                 | 4 ++++
 2 files changed, 6 insertions(+)

(limited to 'railties')

diff --git a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt
index ffa277e334..aed5adf8ee 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt
+++ b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt
@@ -3,7 +3,9 @@
 
 ENGINE_ROOT = File.expand_path('..', __dir__)
 ENGINE_PATH = File.expand_path('../lib/<%= namespaced_name -%>/engine', __dir__)
+<% if with_dummy_app? -%>
 APP_PATH = File.expand_path('../<%= dummy_path -%>/config/application', __dir__)
+<% end -%>
 
 # Set up gems listed in the Gemfile.
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index 1dfff38543..df7256db50 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -101,6 +101,9 @@ class PluginGeneratorTest < Rails::Generators::TestCase
     assert_file "Rakefile" do |contents|
       assert_no_match(/APP_RAKEFILE/, contents)
     end
+    assert_file "bin/rails" do |contents|
+      assert_no_match(/APP_PATH/, contents)
+    end
   end
 
   def test_generating_adds_dummy_app_in_full_mode_without_sprockets
@@ -114,6 +117,7 @@ class PluginGeneratorTest < Rails::Generators::TestCase
   def test_generating_adds_dummy_app_rake_tasks_without_unit_test_files
     run_generator [destination_root, "-T", "--mountable", "--dummy-path", "my_dummy_app"]
     assert_file "Rakefile", /APP_RAKEFILE/
+    assert_file "bin/rails", /APP_PATH/
   end
 
   def test_generating_adds_dummy_app_without_javascript_and_assets_deps
-- 
cgit v1.2.3