Skip to content

Commit

Permalink
--skip-action-mailer and --skip-active_job option doesn't work for `r…
Browse files Browse the repository at this point in the history
…ails plugin new project_name --full` or `rails plugin new project_name --mountable`
  • Loading branch information
piecehealth committed Aug 4, 2020
1 parent b6081f3 commit 1f2d012
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Expand Up @@ -24,10 +24,14 @@ def app
directory "app"
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
end

remove_dir "app/mailers" if options[:skip_action_mailer]
remove_dir "app/jobs" if options[:skip_active_job]
elsif full?
empty_directory_with_keep_file "app/models"
empty_directory_with_keep_file "app/controllers"
empty_directory_with_keep_file "app/mailers"
empty_directory_with_keep_file "app/mailers" unless options[:skip_action_mailer]
empty_directory_with_keep_file "app/jobs" unless options[:skip_active_job]

unless api?
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
Expand Down
21 changes: 21 additions & 0 deletions railties/test/generators/plugin_generator_test.rb
Expand Up @@ -226,6 +226,24 @@ def test_skip_javascript
end
end

def test_skip_action_mailer_and_skip_active_job_with_mountable
run_generator [destination_root, "--mountable", "--skip-action-mailer", "--skip-active-job"]
assert_no_directory "app/mailers"
assert_no_directory "app/jobs"
end

def test_skip_action_mailer_and_skip_active_job_with_api_and_mountable
run_generator [destination_root, "--api", "--mountable", "--skip-action-mailer", "--skip-active-job"]
assert_no_directory "app/mailers"
assert_no_directory "app/jobs"
end

def test_skip_action_mailer_and_skip_active_job_with_full
run_generator [destination_root, "--full", "--skip-action-mailer", "--skip-active-job"]
assert_no_directory "app/mailers"
assert_no_directory "app/jobs"
end

def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]))
Expand Down Expand Up @@ -262,6 +280,7 @@ def test_creating_engine_in_full_mode
assert_file "app/views"
assert_file "app/helpers"
assert_file "app/mailers"
assert_file "app/jobs"
assert_file "bin/rails", /\s+require\s+["']rails\/all["']/
assert_file "config/routes.rb", /Rails.application.routes.draw do/
assert_file "lib/bukkits/engine.rb", /module Bukkits\n class Engine < ::Rails::Engine\n end\nend/
Expand All @@ -278,6 +297,7 @@ def test_creating_engine_with_hyphenated_name_in_full_mode
assert_file "hyphenated-name/app/views"
assert_file "hyphenated-name/app/helpers"
assert_file "hyphenated-name/app/mailers"
assert_file "hyphenated-name/app/jobs"
assert_file "hyphenated-name/bin/rails"
assert_file "hyphenated-name/config/routes.rb", /Rails.application.routes.draw do/
assert_file "hyphenated-name/lib/hyphenated/name/engine.rb", /module Hyphenated\n module Name\n class Engine < ::Rails::Engine\n end\n end\nend/
Expand All @@ -295,6 +315,7 @@ def test_creating_engine_with_hyphenated_and_underscored_name_in_full_mode
assert_file "my_hyphenated-name/app/views"
assert_file "my_hyphenated-name/app/helpers"
assert_file "my_hyphenated-name/app/mailers"
assert_file "my_hyphenated-name/app/jobs"
assert_file "my_hyphenated-name/bin/rails"
assert_file "my_hyphenated-name/config/routes.rb", /Rails\.application\.routes\.draw do/
assert_file "my_hyphenated-name/lib/my_hyphenated/name/engine.rb", /module MyHyphenated\n module Name\n class Engine < ::Rails::Engine\n end\n end\nend/
Expand Down

0 comments on commit 1f2d012

Please sign in to comment.