aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb6
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb3
-rw-r--r--railties/test/generators/plugin_generator_test.rb15
3 files changed, 24 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
index 509bd60564..7106096b60 100644
--- a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
@@ -2,6 +2,12 @@ require 'test_helper'
<% module_namespacing do -%>
class <%= class_name %>ControllerTest < ActionController::TestCase
+<% if defined?(ENGINE_ROOT) -%>
+ setup do
+ @routes = Engine.routes
+ end
+
+<% end -%>
<% if actions.empty? -%>
# test "the truth" do
# assert true
diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
index 76313575e9..d2799994f1 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
@@ -4,6 +4,9 @@ require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= singular_table_name %> = <%= table_name %>(:one)
+<% if defined?(ENGINE_ROOT) -%>
+ @routes = Engine.routes
+<% end -%>
end
test "should get index" do
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index d6e5f4bd89..0716783d42 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -508,6 +508,21 @@ class PluginGeneratorTest < Rails::Generators::TestCase
assert_match(/namespace :admin/, contents)
assert_no_match(/namespace :bukkit/, contents)
end
+ assert_file "test/controllers/bukkits/admin/dashboard_controller_test.rb" do |contents|
+ assert_match(/@routes = Engine.routes/, contents)
+ end
+ end
+
+ def test_generating_scaffold_controller_inside_mountable_engine
+ run_generator [destination_root, "--mountable"]
+
+ capture(:stdout) do
+ `#{destination_root}/bin/rails g scaffold User name:string age:integer`
+ end
+
+ assert_file "test/controllers/bukkits/users_controller_test.rb" do |contents|
+ assert_match(/@routes = Engine.routes/, contents)
+ end
end
def test_git_name_and_email_in_gemspec_file