diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-11-08 11:47:32 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-11-08 14:03:59 +0900 |
commit | 595fa6e9225a7a33806efa74fcbe54decdc37510 (patch) | |
tree | 6ba97655f47241a20788c1af4a6d6721b09833c4 /railties/test | |
parent | 25673f47b607528d12b0f4d1bace30b2c41a97fa (diff) | |
download | rails-595fa6e9225a7a33806efa74fcbe54decdc37510.tar.gz rails-595fa6e9225a7a33806efa74fcbe54decdc37510.tar.bz2 rails-595fa6e9225a7a33806efa74fcbe54decdc37510.zip |
fix application_controller require_dependency path generated by api scaffold generator
In the app generator, regardless of the namespace, it is adapted to read the same `application_controller.rb`,
modified to api generator also be the same behavior.
ref 686966a1861e6761021d45f6795de753e8a62216, 06ac63b4c602e4b26cb3bfbf0dfd2bed8b00e786
Diffstat (limited to 'railties/test')
-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 |