diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2015-11-08 10:06:56 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2015-11-08 10:06:56 -0800 |
commit | 280654ef884f4e9310db89ccff99b7775013ed85 (patch) | |
tree | 09f719bb3aa88f5fd83af6d1ab328d41e4ac2d2d /railties/test/generators/namespaced_generators_test.rb | |
parent | 54c87a1676b626b62b628320f57442ae6d9c59f7 (diff) | |
parent | 595fa6e9225a7a33806efa74fcbe54decdc37510 (diff) | |
download | rails-280654ef884f4e9310db89ccff99b7775013ed85.tar.gz rails-280654ef884f4e9310db89ccff99b7775013ed85.tar.bz2 rails-280654ef884f4e9310db89ccff99b7775013ed85.zip |
Merge pull request #22222 from y-yagi/fix_application_controller_require_dependency_path_in_api
fix application_controller require_dependency path generated by api scaffold generator
Diffstat (limited to 'railties/test/generators/namespaced_generators_test.rb')
-rw-r--r-- | railties/test/generators/namespaced_generators_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index c4ee6602c5..590f06e19a 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -396,4 +396,28 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase # Stylesheets (should not be removed) assert_file "app/assets/stylesheets/scaffold.css" end + + def test_api_scaffold_with_namespace_on_invoke + run_generator [ "admin/role", "name:string", "description:string", "--api" ] + + # Model + assert_file "app/models/test_app/admin.rb", /module TestApp\n module Admin/ + assert_file "app/models/test_app/admin/role.rb", /module TestApp\n class Admin::Role < ActiveRecord::Base/ + assert_file "test/models/test_app/admin/role_test.rb", /module TestApp\n class Admin::RoleTest < ActiveSupport::TestCase/ + assert_file "test/fixtures/test_app/admin/roles.yml" + assert_migration "db/migrate/create_test_app_admin_roles.rb" + + # Route + assert_file "config/routes.rb" do |route| + assert_match(/^ namespace :admin do\n resources :roles\n end$/, route) + end + + # Controller + assert_file "app/controllers/test_app/admin/roles_controller.rb" do |content| + assert_match(/module TestApp\n class Admin::RolesController < ApplicationController/, content) + assert_match(%r(require_dependency "test_app/application_controller"), content) + end + assert_file "test/controllers/test_app/admin/roles_controller_test.rb", + /module TestApp\n class Admin::RolesControllerTest < ActionController::TestCase/ + end end |