diff options
Diffstat (limited to 'railties')
3 files changed, 14 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 658d883883..efbf51ddfb 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -161,6 +161,10 @@ module Rails @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name end + def url_helper_prefix + @url_helper_prefix ||= (class_path + [file_name]).join('_') + end + # Tries to retrieve the application name or simply return application. def application_name if defined?(Rails) && Rails.application 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 4f2ceb8589..ff41fef9e9 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 @@ -13,7 +13,7 @@ class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest <% else -%> <% actions.each do |action| -%> test "should get <%= action %>" do - get <%= file_name %>_<%= action %>_url + get <%= url_helper_prefix %>_<%= action %>_url assert_response :success end diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 92a9b99fd8..868153762d 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -234,6 +234,11 @@ module ApplicationTests assert_match "0 failures, 0 errors, 0 skips", run_test_command('') end + def test_generated_controller_works_with_rails_test + create_controller + assert_match "0 failures, 0 errors, 0 skips", run_test_command('') + end + def test_run_multiple_folders create_test_file :models, 'account' create_test_file :controllers, 'accounts_controller' @@ -449,6 +454,10 @@ module ApplicationTests run_migration end + def create_controller + script 'generate controller admin/dashboard index' + end + def run_migration Dir.chdir(app_path) { `bin/rake db:migrate` } end |