aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator/generators/components
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails_generator/generators/components')
-rw-r--r--railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/fixtures.yml3
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb6
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb4
4 files changed, 8 insertions, 9 deletions
diff --git a/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
index 76e2b33ba5..fcc3efd485 100644
--- a/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require '<%= file_name %>_controller'
+require File.dirname(__FILE__) + <%= '/..' * class_nesting_depth %> + '/../test_helper'
+require '<%= file_path %>_controller'
# Re-raise errors caught by the controller.
class <%= class_name %>Controller; def rescue_action(e) raise e end; end
diff --git a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
index 6285727968..d29fcff2ff 100644
--- a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
+++ b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
@@ -1,8 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-# Set the $base_id variable in the setup method of your tests.
-# It's used to ensure that ids don't clash in some databases.
first_<%= singular_name %>:
id: 1
-
another_<%= singular_name %>:
id: 2
diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
index abf9d79ffe..883bae7d3d 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
@@ -30,7 +30,9 @@ end
class ScaffoldGenerator < Rails::Generator::NamedBase
attr_reader :controller_name,
:controller_class_path,
+ :controller_file_path,
:controller_class_nesting,
+ :controller_class_nesting_depth,
:controller_class_name,
:controller_singular_name,
:controller_plural_name
@@ -40,7 +42,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
def initialize(runtime_args, runtime_options = {})
super
@controller_name = args.shift || @name.pluralize
- base_name, @controller_class_path, @controller_class_nesting = extract_modules(@controller_name)
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
if @controller_class_nesting.empty?
@controller_class_name = @controller_class_name_without_nesting
@@ -75,7 +77,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
controller_class_path,
"#{controller_file_name}_controller_test.rb")
- m.template 'controller:helper.rb',
+ m.template 'helper.rb',
File.join('app/helpers',
controller_class_path,
"#{controller_file_name}_helper.rb")
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
index 32185fb715..1d45f23958 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require '<%= controller_file_name %>_controller'
+require File.dirname(__FILE__) + <%= '/..' * controller_class_nesting_depth %> + '/../test_helper'
+require '<%= controller_file_path %>_controller'
# Re-raise errors caught by the controller.
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end