mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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. ref686966a186
,06ac63b4c6
This commit is contained in:
parent
25673f47b6
commit
595fa6e922
2 changed files with 25 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<% if namespaced? -%>
|
||||
require_dependency "<%= namespaced_file_path %>/application_controller"
|
||||
require_dependency "<%= namespaced_path %>/application_controller"
|
||||
|
||||
<% end -%>
|
||||
<% module_namespacing do -%>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue