diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2017-01-04 23:55:15 +0900 |
---|---|---|
committer | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2017-01-07 22:32:53 +0900 |
commit | 4459a18db6fc9294d1f2553e45f59c859602dbad (patch) | |
tree | 1028c3f98dac9c12f881bc44459c7766be192d5a /railties/test | |
parent | 7b13236818ffb26e94d72885e75966efffd71659 (diff) | |
download | rails-4459a18db6fc9294d1f2553e45f59c859602dbad.tar.gz rails-4459a18db6fc9294d1f2553e45f59c859602dbad.tar.bz2 rails-4459a18db6fc9294d1f2553e45f59c859602dbad.zip |
Fix generator command for nested (namespaced) rails engine (take 2)
Rewrite https://github.com/rails/rails/pull/27550
085546df45 was reverted (b6ffb5efcb) because it change the return of `namespaced_path` from String to Array.
----------------
If we create nested (namespaced) rails engine such like bukkits-admin,
`bin/rails g scaffold User name:string age:integer`
will create
`bukkits-admin/app/controllers/bukkits/users_controller.rb`
but it should create
`bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`.
In #6643, we changed `namespaced_path` as root path
because we supposed application_controller is always in root
but nested rails engine's application_controller will not.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 6b7e2c91d7..e2b2acab0f 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -492,6 +492,26 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end + def test_scaffold_tests_pass_by_default_inside_namespaced_mountable_engine + Dir.chdir(destination_root) { `bundle exec rails plugin new bukkits-admin --mountable` } + + engine_path = File.join(destination_root, "bukkits-admin") + + Dir.chdir(engine_path) do + quietly do + `bin/rails g scaffold User name:string age:integer; + bin/rails db:migrate` + end + + assert_file "bukkits-admin/app/controllers/bukkits/admin/users_controller.rb" do |content| + assert_match(/module Bukkits::Admin/, content) + assert_match(/class UsersController < ApplicationController/, content) + end + + assert_match(/8 runs, 10 assertions, 0 failures, 0 errors/, `bin/rails test 2>&1`) + end + end + def test_scaffold_tests_pass_by_default_inside_full_engine Dir.chdir(destination_root) { `bundle exec rails plugin new bukkits --full` } |