mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add app concern and test keepfiles to generated engine plugins
This commit is contained in:
parent
6efe2b4900
commit
bf57e7ff9d
3 changed files with 73 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
* Add app concern and test keepfiles to generated engine plugins.
|
||||||
|
|
||||||
|
*Gannon McGibbon*
|
||||||
|
|
||||||
* Stop generating a license for in-app plugins.
|
* Stop generating a license for in-app plugins.
|
||||||
|
|
||||||
*Gannon McGibbon*
|
*Gannon McGibbon*
|
||||||
|
|
|
@ -26,11 +26,15 @@ module Rails
|
||||||
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
|
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
empty_directory_with_keep_file "app/models/concerns"
|
||||||
|
empty_directory_with_keep_file "app/controllers/concerns"
|
||||||
remove_dir "app/mailers" if options[:skip_action_mailer]
|
remove_dir "app/mailers" if options[:skip_action_mailer]
|
||||||
remove_dir "app/jobs" if options[:skip_active_job]
|
remove_dir "app/jobs" if options[:skip_active_job]
|
||||||
elsif full?
|
elsif full?
|
||||||
empty_directory_with_keep_file "app/models"
|
empty_directory_with_keep_file "app/models"
|
||||||
empty_directory_with_keep_file "app/controllers"
|
empty_directory_with_keep_file "app/controllers"
|
||||||
|
empty_directory_with_keep_file "app/models/concerns"
|
||||||
|
empty_directory_with_keep_file "app/controllers/concerns"
|
||||||
empty_directory_with_keep_file "app/mailers" unless options[:skip_action_mailer]
|
empty_directory_with_keep_file "app/mailers" unless options[:skip_action_mailer]
|
||||||
empty_directory_with_keep_file "app/jobs" unless options[:skip_active_job]
|
empty_directory_with_keep_file "app/jobs" unless options[:skip_active_job]
|
||||||
|
|
||||||
|
@ -90,12 +94,22 @@ module Rails
|
||||||
def test
|
def test
|
||||||
template "test/test_helper.rb"
|
template "test/test_helper.rb"
|
||||||
template "test/%namespaced_name%_test.rb"
|
template "test/%namespaced_name%_test.rb"
|
||||||
append_file "Rakefile", <<-EOF
|
append_file "Rakefile", <<~EOF
|
||||||
|
#{rakefile_test_tasks}
|
||||||
#{rakefile_test_tasks}
|
task default: :test
|
||||||
task default: :test
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if engine?
|
if engine?
|
||||||
|
empty_directory_with_keep_file "test/fixtures/files"
|
||||||
|
empty_directory_with_keep_file "test/controllers"
|
||||||
|
empty_directory_with_keep_file "test/mailers"
|
||||||
|
empty_directory_with_keep_file "test/models"
|
||||||
|
empty_directory_with_keep_file "test/integration"
|
||||||
|
|
||||||
|
unless api?
|
||||||
|
empty_directory_with_keep_file "test/helpers"
|
||||||
|
end
|
||||||
|
|
||||||
template "test/integration/navigation_test.rb"
|
template "test/integration/navigation_test.rb"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -481,6 +481,57 @@ class PluginGeneratorTest < Rails::Generators::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_creating_full_engine_mode_adds_keeps
|
||||||
|
run_generator [destination_root, "--full"]
|
||||||
|
folders_with_keep = %w(
|
||||||
|
app/models/concerns
|
||||||
|
app/controllers/concerns
|
||||||
|
test/fixtures/files
|
||||||
|
test/controllers
|
||||||
|
test/mailers
|
||||||
|
test/models
|
||||||
|
test/helpers
|
||||||
|
test/integration
|
||||||
|
)
|
||||||
|
folders_with_keep.each do |folder|
|
||||||
|
assert_file("#{folder}/.keep")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creating_full_api_engine_adds_keeps
|
||||||
|
run_generator [destination_root, "--full", "--api"]
|
||||||
|
folders_with_keep = %w(
|
||||||
|
app/models/concerns
|
||||||
|
app/controllers/concerns
|
||||||
|
test/fixtures/files
|
||||||
|
test/controllers
|
||||||
|
test/mailers
|
||||||
|
test/models
|
||||||
|
test/integration
|
||||||
|
)
|
||||||
|
folders_with_keep.each do |folder|
|
||||||
|
assert_file("#{folder}/.keep")
|
||||||
|
end
|
||||||
|
assert_no_file("test/helpers/.keep")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creating_mountable_engine_mode_adds_keeps
|
||||||
|
run_generator [destination_root, "--mountable"]
|
||||||
|
folders_with_keep = %w(
|
||||||
|
app/models/concerns
|
||||||
|
app/controllers/concerns
|
||||||
|
test/fixtures/files
|
||||||
|
test/controllers
|
||||||
|
test/mailers
|
||||||
|
test/models
|
||||||
|
test/helpers
|
||||||
|
test/integration
|
||||||
|
)
|
||||||
|
folders_with_keep.each do |folder|
|
||||||
|
assert_file("#{folder}/.keep")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_creating_gemspec
|
def test_creating_gemspec
|
||||||
run_generator
|
run_generator
|
||||||
assert_file "bukkits.gemspec", /spec\.name\s+= "bukkits"/
|
assert_file "bukkits.gemspec", /spec\.name\s+= "bukkits"/
|
||||||
|
|
Loading…
Reference in a new issue