A new application now comes with a layout and a stylesheet.
This commit is contained in:
parent
4eab983b95
commit
ea2c5fa804
@ -1,3 +1,5 @@
|
||||
* 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,7 +26,6 @@ module Generators
|
||||
:orm => '-o',
|
||||
:resource_controller => '-c',
|
||||
:scaffold_controller => '-c',
|
||||
:stylesheets => '-y',
|
||||
:template_engine => '-e',
|
||||
:test_framework => '-t'
|
||||
},
|
||||
@ -56,7 +55,6 @@ module Generators
|
||||
:resource_controller => :controller,
|
||||
:scaffold_controller => :scaffold_controller,
|
||||
:singleton => false,
|
||||
:stylesheets => true,
|
||||
:test_framework => nil,
|
||||
:template_engine => :erb
|
||||
},
|
||||
|
@ -25,12 +25,6 @@ def copy_view_files
|
||||
end
|
||||
end
|
||||
|
||||
def copy_layout_file
|
||||
return unless options[:layout]
|
||||
template filename_with_extensions(:layout),
|
||||
File.join("app/views/layouts", controller_class_path, filename_with_extensions(controller_file_name))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def available_views
|
||||
|
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
||||
<%%= stylesheet_link_tag 'scaffold' %>
|
||||
<%%= javascript_include_tag :defaults %>
|
||||
<%%= csrf_meta_tag %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p class="notice"><%%= notice %></p>
|
||||
<p class="alert"><%%= alert %></p>
|
||||
|
||||
<%%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -137,7 +137,7 @@ def create_public_image_files
|
||||
end
|
||||
|
||||
def create_public_stylesheets_files
|
||||
empty_directory_with_gitkeep "public/stylesheets"
|
||||
directory "public/stylesheets"
|
||||
end
|
||||
|
||||
def create_prototype_files
|
||||
|
@ -1,3 +1,4 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
layout 'application'
|
||||
end
|
||||
|
17
railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
Normal file
17
railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= controller_name.humanize %>: <%= action_name %></title>
|
||||
<%= stylesheet_link_tag 'application' %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= csrf_meta_tag %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p class="notice"><%= notice %></p>
|
||||
<p class="alert"><%= alert %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -7,7 +7,6 @@ class ScaffoldGenerator < ResourceGenerator #metagenerator
|
||||
remove_class_option :actions
|
||||
|
||||
hook_for :scaffold_controller, :required => true
|
||||
hook_for :stylesheets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +0,0 @@
|
||||
Description:
|
||||
Copies scaffold stylesheets to public/stylesheets/.
|
||||
|
||||
Examples:
|
||||
`rails generate stylesheets`
|
@ -1,9 +0,0 @@
|
||||
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
|
@ -51,6 +51,13 @@ def test_application_skeleton_is_created
|
||||
).each{ |path| assert_file path }
|
||||
end
|
||||
|
||||
def test_application_controller_and_layout_files
|
||||
run_generator
|
||||
assert_file "app/controllers/application_controller.rb", /layout 'application'/
|
||||
assert_file "app/views/layouts/application.html.erb", /stylesheet_link_tag 'application'/
|
||||
assert_file "public/stylesheets/application.css"
|
||||
end
|
||||
|
||||
def test_name_collision_raises_an_error
|
||||
content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] }
|
||||
assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content
|
||||
|
@ -66,7 +66,6 @@ def test_views_are_generated
|
||||
new
|
||||
show
|
||||
).each { |view| assert_file "app/views/users/#{view}.html.erb" }
|
||||
assert_file "app/views/layouts/users.html.erb"
|
||||
end
|
||||
|
||||
def test_functional_tests
|
||||
|
@ -70,14 +70,10 @@ def test_scaffold_on_invoke
|
||||
show
|
||||
_form
|
||||
).each { |view| assert_file "app/views/product_lines/#{view}.html.erb" }
|
||||
assert_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
|
||||
@ -101,13 +97,9 @@ 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
|
||||
|
@ -1,17 +0,0 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user