From c3cdd3b6595ad59129d7652f6f3274f26509a4dc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 7 Aug 2006 21:58:31 +0000 Subject: Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/controller/deprecated_instance_variables_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/deprecated_instance_variables_test.rb b/actionpack/test/controller/deprecated_instance_variables_test.rb index 81e7ba1324..edfd8b7d02 100644 --- a/actionpack/test/controller/deprecated_instance_variables_test.rb +++ b/actionpack/test/controller/deprecated_instance_variables_test.rb @@ -2,6 +2,15 @@ require File.dirname(__FILE__) + '/../abstract_unit' class DeprecatedInstanceVariablesTest < Test::Unit::TestCase class Target < ActionController::Base + def initialize(run = nil) + instance_eval(run) if run + super() + end + + def noop + render :nothing => true + end + ActionController::Base::DEPRECATED_INSTANCE_VARIABLES.each do |var| class_eval "def old_#{var}; render :text => @#{var}.inspect end" class_eval "def new_#{var}; render :text => #{var}.inspect end" @@ -28,6 +37,12 @@ class DeprecatedInstanceVariablesTest < Test::Unit::TestCase def test_internal_#{var}_isnt_deprecated assert_not_deprecated { get :internal_#{var} } end + def test_#{var}_raises_if_already_set + assert_raise(RuntimeError) do + @controller = Target.new '@#{var} = Object.new' + get :noop + end + end end_eval end end -- cgit v1.2.3