提交 4fb3a555 编写于 作者: A Andrew White

Merge pull request #19751 from y-yagi/fix_indent_of_controller

fix indent in routes when using namespaced controllers
......@@ -13,7 +13,8 @@ def create_controller_files
def add_routes
unless options[:skip_routes]
actions.reverse_each do |action|
route generate_routing_code(action)
# route prepends two spaces onto the front of the string that is passed, this corrects that.
route generate_routing_code(action)[2..-1]
end
end
end
......@@ -36,12 +37,12 @@ def generate_routing_code(action)
# namespace :foo do
# namespace :bar do
namespace_ladder = regular_class_path.each_with_index.map do |ns, i|
indent("namespace :#{ns} do\n", i * 2)
indent(" namespace :#{ns} do\n", i * 2)
end.join
# Create route
# get 'baz/index'
route = indent(%{get '#{file_name}/#{action}'\n}, depth * 2)
route = indent(%{ get '#{file_name}/#{action}'\n}, depth * 2)
# Create `end` ladder
# end
......
......@@ -96,6 +96,8 @@ def test_actions_are_turned_into_methods
def test_namespaced_routes_are_created_in_routes
run_generator ["admin/dashboard", "index"]
assert_file "config/routes.rb", /namespace :admin do\n\s+get 'dashboard\/index'\n/
assert_file "config/routes.rb" do |route|
assert_match(/^ namespace :admin do\n get 'dashboard\/index'\n end$/, route)
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册