Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to avoid generating scaffold.css #20479

Merged
merged 1 commit into from Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions railties/lib/rails/generators.rb
Expand Up @@ -33,6 +33,7 @@ module Generators
scaffold_controller: '-c',
stylesheets: '-y',
stylesheet_engine: '-se',
scaffold_stylesheet: '-ss',
template_engine: '-e',
test_framework: '-t'
},
Expand All @@ -56,6 +57,7 @@ module Generators
scaffold_controller: :scaffold_controller,
stylesheets: true,
stylesheet_engine: :css,
scaffold_stylesheet: true,
test_framework: false,
template_engine: :erb
}
Expand Down
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions railties/test/generators/scaffold_generator_test.rb
Expand Up @@ -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|
Expand Down