diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-05-31 21:28:51 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-05-31 21:28:51 +0900 |
commit | c861ef283fb94576a4025e4eb8d62808034ab2ee (patch) | |
tree | e9cc5643697ef0022793add73ff0529d5bcff1c4 /railties | |
parent | 6a8d91897bae19f5d30f51a2731d9bbf7f41ac2e (diff) | |
download | rails-c861ef283fb94576a4025e4eb8d62808034ab2ee.tar.gz rails-c861ef283fb94576a4025e4eb8d62808034ab2ee.tar.bz2 rails-c861ef283fb94576a4025e4eb8d62808034ab2ee.zip |
add engine's namespace to fixture name
Diffstat (limited to 'railties')
3 files changed, 11 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index 2e1f55f2a6..a3beebbfd5 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -15,6 +15,15 @@ module TestUnit # :nodoc: File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb") end + def fixture_name + @fixture_name ||= + if defined?(ENGINE_ROOT) + namespaced_path + "_" + table_name + else + table_name + end + end + private def attributes_hash 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 d2799994f1..d12a5ba733 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 @@ -3,7 +3,7 @@ require 'test_helper' <% module_namespacing do -%> class <%= controller_class_name %>ControllerTest < ActionController::TestCase setup do - @<%= singular_table_name %> = <%= table_name %>(:one) + @<%= singular_table_name %> = <%= fixture_name %>(:one) <% if defined?(ENGINE_ROOT) -%> @routes = Engine.routes <% end -%> diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 0716783d42..57da8ab268 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -521,6 +521,7 @@ class PluginGeneratorTest < Rails::Generators::TestCase end assert_file "test/controllers/bukkits/users_controller_test.rb" do |contents| + assert_match(/@user = bukkits_users\(:one\)/, contents) assert_match(/@routes = Engine.routes/, contents) end end |