Permalink
Browse files

Partially revert "A new application now comes with a layout and a sty…

…lesheet."

This reverts commit ea2c5fa.

Conflicts:

	railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
	railties/test/generators/app_generator_test.rb
  • Loading branch information...
1 parent c44cacb commit ec8e747960da9c0413cb5da7834f458bc5dd8ce1 @jeremy jeremy committed Apr 9, 2010
View
@@ -1,5 +1,3 @@
-* A new application now comes with a layout and a stylesheet. [JV]
-
* Renamed config.cookie_secret to config.secret_token and pass it as env key. [JV]
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
@@ -26,6 +26,7 @@ module Generators
:orm => '-o',
:resource_controller => '-c',
:scaffold_controller => '-c',
+ :stylesheets => '-y',
:template_engine => '-e',
:test_framework => '-t'
},
@@ -50,6 +51,7 @@ module Generators
:resource_controller => :controller,
:scaffold_controller => :scaffold_controller,
:singleton => false,
+ :stylesheets => true,
:test_framework => nil,
:template_engine => :erb
},
@@ -142,7 +142,7 @@ def create_public_image_files
end
def create_public_stylesheets_files
- directory "public/stylesheets"
+ empty_directory_with_gitkeep "public/stylesheets"
end
def create_prototype_files
@@ -7,6 +7,7 @@ class ScaffoldGenerator < ResourceGenerator #metagenerator
remove_class_option :actions
hook_for :scaffold_controller, :required => true
+ hook_for :stylesheets
end
end
end
@@ -0,0 +1,5 @@
+Description:
+ Copies scaffold stylesheets to public/stylesheets/.
+
+Examples:
+ `rails generate stylesheets`
@@ -0,0 +1,9 @@
+module Rails
+ module Generators
+ class StylesheetsGenerator < Base
+ def copy_stylesheets_file
+ template "scaffold.css", "public/stylesheets/scaffold.css" if behavior == :invoke
+ end
+ end
+ end
+end
@@ -66,6 +66,7 @@ def test_views_are_generated
new
show
).each { |view| assert_file "app/views/users/#{view}.html.erb" }
+ assert_no_file "app/views/layouts/users.html.erb"
end
def test_functional_tests
@@ -70,10 +70,14 @@ def test_scaffold_on_invoke
show
_form
).each { |view| assert_file "app/views/product_lines/#{view}.html.erb" }
+ assert_no_file "app/views/layouts/product_lines.html.erb"
# Helpers
assert_file "app/helpers/product_lines_helper.rb"
assert_file "test/unit/helpers/product_lines_helper_test.rb"
+
+ # Stylesheets
+ assert_file "public/stylesheets/scaffold.css"
end
def test_scaffold_on_revoke
@@ -97,9 +101,13 @@ def test_scaffold_on_revoke
# Views
assert_no_file "app/views/product_lines"
+ assert_no_file "app/views/layouts/product_lines.html.erb"
# Helpers
assert_no_file "app/helpers/product_lines_helper.rb"
assert_no_file "test/unit/helpers/product_lines_helper_test.rb"
+
+ # Stylesheets (should not be removed)
+ assert_file "public/stylesheets/scaffold.css"
end
end
@@ -0,0 +1,17 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/rails/stylesheets/stylesheets_generator'
+
+class StylesheetsGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+
+ def test_copy_stylesheets
+ run_generator
+ assert_file "public/stylesheets/scaffold.css"
+ end
+
+ def test_stylesheets_are_not_deleted_on_revoke
+ run_generator
+ run_generator [], :behavior => :revoke
+ assert_file "public/stylesheets/scaffold.css"
+ end
+end

0 comments on commit ec8e747

Please sign in to comment.