diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-22 14:39:03 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-22 14:39:03 +0000 |
commit | 38ee39a4a5e719694dca553ef739dbf99645c2b2 (patch) | |
tree | a2c9f129be5fd19dd4130b43be5c2786431cd142 /railties/generators/scaffold | |
parent | bbd3e3966876ff76f33fee5b633004a1c636688c (diff) | |
download | rails-38ee39a4a5e719694dca553ef739dbf99645c2b2.tar.gz rails-38ee39a4a5e719694dca553ef739dbf99645c2b2.tar.bz2 rails-38ee39a4a5e719694dca553ef739dbf99645c2b2.zip |
Fixed that generate scaffold would produce bad functional tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@474 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/generators/scaffold')
-rw-r--r-- | railties/generators/scaffold/scaffold_generator.rb | 16 | ||||
-rw-r--r-- | railties/generators/scaffold/templates/functional_test.rb | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/railties/generators/scaffold/scaffold_generator.rb b/railties/generators/scaffold/scaffold_generator.rb index 00dd27c5ed..3901d6b2bc 100644 --- a/railties/generators/scaffold/scaffold_generator.rb +++ b/railties/generators/scaffold/scaffold_generator.rb @@ -9,16 +9,16 @@ class ScaffoldGenerator < Rails::Generator::Base template "fixtures.yml", "test/fixtures/#{table_name}.yml" @controller_class_name = args.empty? ? Inflector.pluralize(class_name) : args.shift.sub(/^[a-z]?/) { |m| m.capitalize } - controller_name = Inflector.underscore(@controller_class_name) + @controller_name = Inflector.underscore(@controller_class_name) # Controller class, functional test, helper, and views. - template "controller.rb", "app/controllers/#{controller_name}_controller.rb" - template "functional_test.rb", "test/functional/#{controller_name}_controller_test.rb" - template "controller/helper.rb", "app/helpers/#{controller_name}_helper.rb" + template "controller.rb", "app/controllers/#{@controller_name}_controller.rb" + template "functional_test.rb", "test/functional/#{@controller_name}_controller_test.rb" + template "controller/helper.rb", "app/helpers/#{@controller_name}_helper.rb" # Layout and stylesheet. - unless File.file?("app/views/layouts/#{controller_name}.rhtml") - template "layout.rhtml", "app/views/layouts/#{controller_name}.rhtml" + unless File.file?("app/views/layouts/#{@controller_name}.rhtml") + template "layout.rhtml", "app/views/layouts/#{@controller_name}.rhtml" end unless File.file?("public/stylesheets/scaffold.css") template "style.css", "public/stylesheets/scaffold.css" @@ -26,13 +26,13 @@ class ScaffoldGenerator < Rails::Generator::Base # Scaffolded views. scaffold_views.each do |action| - template "view_#{action}.rhtml", "app/views/#{controller_name}/#{action}.rhtml" + template "view_#{action}.rhtml", "app/views/#{@controller_name}/#{action}.rhtml" end # Unscaffolded views. unscaffolded_actions.each do |action| template "controller/view.rhtml", - "app/views/#{controller_name}/#{action}.rhtml", + "app/views/#{@controller_name}/#{action}.rhtml", binding end end diff --git a/railties/generators/scaffold/templates/functional_test.rb b/railties/generators/scaffold/templates/functional_test.rb index 1bf7d83694..004af030be 100644 --- a/railties/generators/scaffold/templates/functional_test.rb +++ b/railties/generators/scaffold/templates/functional_test.rb @@ -1,14 +1,14 @@ require File.dirname(__FILE__) + '/../test_helper' -require '<%= file_name %>_controller' +require '<%= @controller_name %>_controller' # Re-raise errors caught by the controller. -class <%= class_name %>Controller; def rescue_action(e) raise e end; end +class <%= @controller_class_name %>Controller; def rescue_action(e) raise e end; end -class <%= class_name %>ControllerTest < Test::Unit::TestCase +class <%= @controller_class_name %>ControllerTest < Test::Unit::TestCase fixtures :<%= table_name %> def setup - @controller = <%= class_name %>Controller.new + @controller = <%= @controller_class_name %>Controller.new @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new end |