From e821020394a658ae979d55046c7f0138ea9cc659 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 2 Dec 2012 18:07:35 +0000 Subject: [PATCH] Make the tests pass when config.threadsafe! is enabled (#12097). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10910 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/routes.rb | 2 +- test/test_helper.rb | 11 +++++++++++ test/unit/helpers/application_helper_test.rb | 1 + test/unit/lib/redmine/helpers/gantt_test.rb | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index ca9d77590..eada47681 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -312,7 +312,7 @@ RedmineApp::Application.routes.draw do resources :auth_sources do member do - get 'test_connection' + get 'test_connection', :as => 'try_connection' end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 91e0d8cc6..5c166687e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -492,3 +492,14 @@ end # Simple module to "namespace" all of the API tests module ApiTest end + +# URL helpers do not work with config.threadsafe! +# https://github.com/rspec/rspec-rails/issues/476#issuecomment-4705454 +ActionView::TestCase::TestController.instance_eval do + helper Rails.application.routes.url_helpers +end +ActionView::TestCase::TestController.class_eval do + def _routes + Rails.application.routes + end +end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index d44dba8a2..40a85473e 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -21,6 +21,7 @@ require File.expand_path('../../../test_helper', __FILE__) class ApplicationHelperTest < ActionView::TestCase include ERB::Util + include Rails.application.routes.url_helpers fixtures :projects, :roles, :enabled_modules, :users, :repositories, :changesets, diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index 819b506e3..291662d67 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -34,6 +34,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase include ProjectsHelper include IssuesHelper include ERB::Util + include Rails.application.routes.url_helpers def setup setup_with_controller