aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/generators/erb/controller/controller_generator.rb2
-rw-r--r--railties/lib/generators/erb/mailer/mailer_generator.rb4
-rw-r--r--railties/lib/generators/erb/scaffold/scaffold_generator.rb5
-rw-r--r--railties/lib/generators/test_unit/controller/controller_generator.rb3
-rw-r--r--railties/lib/generators/test_unit/mailer/mailer_generator.rb4
-rw-r--r--railties/lib/generators/test_unit/observer/observer_generator.rb2
-rw-r--r--railties/lib/generators/test_unit/scaffold/scaffold_generator.rb15
-rw-r--r--railties/lib/generators/test_unit/scaffold/templates/functional_test.rb45
8 files changed, 71 insertions, 9 deletions
diff --git a/railties/lib/generators/erb/controller/controller_generator.rb b/railties/lib/generators/erb/controller/controller_generator.rb
index 706c92cb91..ab7b273662 100644
--- a/railties/lib/generators/erb/controller/controller_generator.rb
+++ b/railties/lib/generators/erb/controller/controller_generator.rb
@@ -6,7 +6,7 @@ module Erb
argument :actions, :type => :array, :default => [], :banner => "action action"
def create_view_files
- base_path = File.join('app', 'views', class_path, file_name)
+ base_path = File.join("app/views", class_path, file_name)
empty_directory base_path
actions.each do |action|
diff --git a/railties/lib/generators/erb/mailer/mailer_generator.rb b/railties/lib/generators/erb/mailer/mailer_generator.rb
index 398ab46dd8..4ec2f4c9f4 100644
--- a/railties/lib/generators/erb/mailer/mailer_generator.rb
+++ b/railties/lib/generators/erb/mailer/mailer_generator.rb
@@ -6,13 +6,13 @@ module Erb
argument :actions, :type => :array, :default => [], :banner => "method method"
def create_view_folder
- empty_directory File.join("app", "views", file_path)
+ empty_directory File.join("app/views", file_path)
end
def create_view_files
actions.each do |action|
@action, @path = action, File.join(file_path, action)
- template "view.erb", File.join("app", "views", "#{@path}.erb")
+ template "view.erb", File.join("app/views", "#{@path}.erb")
end
end
end
diff --git a/railties/lib/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/generators/erb/scaffold/scaffold_generator.rb
index c89af042b7..c8723785f4 100644
--- a/railties/lib/generators/erb/scaffold/scaffold_generator.rb
+++ b/railties/lib/generators/erb/scaffold/scaffold_generator.rb
@@ -28,13 +28,14 @@ module Erb
# TODO invoke_if?
def copy_layout_file
- template "layout.html.erb", File.join("app", "views", "layouts", controller_class_path, "#{controller_file_name}.html.erb")
+ template "layout.html.erb",
+ File.join("app/views/layouts", controller_class_path, "#{controller_file_name}.html.erb")
end
protected
def copy_view(view)
- template "#{view}.html.erb", File.join("app", "views", controller_file_path, "#{view}.html.erb")
+ template "#{view}.html.erb", File.join("app/views", controller_file_path, "#{view}.html.erb")
end
end
diff --git a/railties/lib/generators/test_unit/controller/controller_generator.rb b/railties/lib/generators/test_unit/controller/controller_generator.rb
index a8cb5cbdbb..b57a6e794f 100644
--- a/railties/lib/generators/test_unit/controller/controller_generator.rb
+++ b/railties/lib/generators/test_unit/controller/controller_generator.rb
@@ -6,7 +6,8 @@ module TestUnit
check_class_collision :suffix => "ControllerTest"
def create_test_files
- template 'functional_test.rb', File.join('test/functional', class_path, "#{file_name}_controller_test.rb")
+ template 'functional_test.rb',
+ File.join('test/functional', class_path, "#{file_name}_controller_test.rb")
end
end
end
diff --git a/railties/lib/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/generators/test_unit/mailer/mailer_generator.rb
index 559668d504..ef350a6224 100644
--- a/railties/lib/generators/test_unit/mailer/mailer_generator.rb
+++ b/railties/lib/generators/test_unit/mailer/mailer_generator.rb
@@ -7,13 +7,13 @@ module TestUnit
check_class_collision :suffix => "Test"
def create_test_files
- template "unit_test.rb", File.join('test', 'unit', class_path, "#{file_name}_test.rb")
+ template "unit_test.rb", File.join('test/unit', class_path, "#{file_name}_test.rb")
end
def create_fixtures_files
actions.each do |action|
@action, @path = action, File.join(file_path, action)
- template "fixture", File.join("test", "fixtures", @path)
+ template "fixture", File.join("test/fixtures", @path)
end
end
end
diff --git a/railties/lib/generators/test_unit/observer/observer_generator.rb b/railties/lib/generators/test_unit/observer/observer_generator.rb
index a2ed812e58..14181f4e49 100644
--- a/railties/lib/generators/test_unit/observer/observer_generator.rb
+++ b/railties/lib/generators/test_unit/observer/observer_generator.rb
@@ -6,7 +6,7 @@ module TestUnit
check_class_collision :suffix => "ObserverTest"
def create_test_files
- template 'unit_test.rb', File.join('test', 'unit', class_path, "#{file_name}_observer_test.rb")
+ template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
end
end
end
diff --git a/railties/lib/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/generators/test_unit/scaffold/scaffold_generator.rb
new file mode 100644
index 0000000000..7c73a23267
--- /dev/null
+++ b/railties/lib/generators/test_unit/scaffold/scaffold_generator.rb
@@ -0,0 +1,15 @@
+require 'generators/test_unit'
+
+module TestUnit
+ module Generators
+ class ScaffoldGenerator < Base
+ include Rails::Generators::ControllerNamedBase
+ check_class_collision :suffix => "ControllerTest"
+
+ def create_test_files
+ template 'functional_test.rb',
+ File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")
+ end
+ end
+ end
+end
diff --git a/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb
new file mode 100644
index 0000000000..cd2fc578bf
--- /dev/null
+++ b/railties/lib/generators/test_unit/scaffold/templates/functional_test.rb
@@ -0,0 +1,45 @@
+require 'test_helper'
+
+class <%= controller_class_name %>ControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:<%= table_name %>)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create <%= file_name %>" do
+ assert_difference('<%= class_name %>.count') do
+ post :create, :<%= file_name %> => { }
+ end
+
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
+ end
+
+ test "should show <%= file_name %>" do
+ get :show, :id => <%= table_name %>(:one).to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => <%= table_name %>(:one).to_param
+ assert_response :success
+ end
+
+ test "should update <%= file_name %>" do
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
+ end
+
+ test "should destroy <%= file_name %>" do
+ assert_difference('<%= class_name %>.count', -1) do
+ delete :destroy, :id => <%= table_name %>(:one).to_param
+ end
+
+ assert_redirected_to <%= table_name %>_path
+ end
+end