提交 83b7bf4d 编写于 作者: M masarakki

add option to avoid generating scaffold.css

上级 a69e0a5f
......@@ -33,6 +33,7 @@ module Generators
scaffold_controller: '-c',
stylesheets: '-y',
stylesheet_engine: '-se',
scaffold_stylesheet: '-ss',
template_engine: '-e',
test_framework: '-t'
},
......@@ -56,6 +57,7 @@ module Generators
scaffold_controller: :scaffold_controller,
stylesheets: true,
stylesheet_engine: :css,
scaffold_stylesheet: true,
test_framework: false,
template_engine: :erb
}
......
......@@ -10,10 +10,11 @@ class ScaffoldGenerator < ResourceGenerator # :nodoc:
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
class_option :assets, type: :boolean
class_option :resource_route, type: :boolean
class_option :scaffold_stylesheet, type: :boolean
def handle_skip
@options = @options.merge(stylesheets: false) unless options[:assets]
@options = @options.merge(stylesheet_engine: false) unless options[:stylesheets]
@options = @options.merge(stylesheet_engine: false) unless options[:stylesheets] && options[:scaffold_stylesheet]
end
hook_for :scaffold_controller, required: true
......
......@@ -282,6 +282,20 @@ def test_scaffold_generator_no_assets_with_switch_assets_false
assert_no_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_no_scaffold_stylesheet_with_switch_no_scaffold_stylesheet
run_generator [ "posts", "--no-scaffold-stylesheet" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_file "app/assets/javascripts/posts.js"
assert_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_no_scaffold_stylesheet_with_switch_scaffold_stylesheet_false
run_generator [ "posts", "--scaffold-stylesheet=false" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_file "app/assets/javascripts/posts.js"
assert_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_with_switch_resource_route_false
run_generator [ "posts", "--resource-route=false" ]
assert_file "config/routes.rb" do |route|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册