aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/test_case.rb19
-rw-r--r--actionpack/test/controller/test_test.rb11
3 files changed, 28 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 98756c7582..10f4d93a82 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Ensure that test case setup is run even if overridden. #10382 [Josh Peek]
+
* Fix HTML Sanitizer to allow trailing spaces in CSS style attributes. Closes #10566 [wesley.moxam]
* Add :default option to time_zone_select. #10590 [Matt Aimonetti]
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index d81cb5dae3..84610c34c0 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -44,10 +44,23 @@ module ActionController
end
end
- def setup
+ def setup_with_controller
@controller = self.class.controller_class.new
@request = TestRequest.new
@response = TestResponse.new
end
- end
-end \ No newline at end of file
+ alias_method :setup, :setup_with_controller
+
+ def self.method_added(method)
+ if method.to_s == 'setup'
+ unless method_defined?(:setup_without_controller)
+ alias_method :setup_without_controller, :setup
+ define_method(:setup) do
+ setup_with_controller
+ setup_without_controller
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 11e48da91c..68eee4f4a3 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -614,10 +614,19 @@ class InferringClassNameTest < Test::Unit::TestCase
end
end
+class ContentControllerTest < ActionController::TestCase
+ def setup
+ # Should not override ActionController setup methods
+ end
+
+ def test_should_still_setup_controller
+ assert_kind_of(ContentController, @controller)
+ end
+end
+
class CrazyNameTest < ActionController::TestCase
tests ContentController
def test_controller_class_can_be_set_manually_not_just_inferred
assert_equal ContentController, self.class.controller_class
end
end
-