Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Deprecation: remove deprecated instance variables.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 83c8db981892820b747390d854595268afade8dd 1 parent 9c0fe36
@jeremy jeremy authored
Showing with 7 additions and 142 deletions.
  1. +2 −0  actionpack/CHANGELOG
  2. +0 −19 actionpack/lib/action_controller/base.rb
  3. +2 −2 actionpack/lib/action_view/base.rb
  4. +0 −8 actionpack/lib/action_view/template_error.rb
  5. +0 −48 actionpack/test/controller/deprecated_instance_variables_test.rb
  6. +3 −8 actionpack/test/controller/new_render_test.rb
  7. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.erb
  8. 0  actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml
  9. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.erb
  10. 0  actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml
  11. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.erb
  12. 0  actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml
  13. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_flash_method.erb
  14. 0  actionpack/test/fixtures/deprecated_instance_variables/_flash_method.rhtml
  15. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.erb
  16. 0  actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml
  17. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_headers_method.erb
  18. 0  actionpack/test/fixtures/deprecated_instance_variables/_headers_method.rhtml
  19. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.erb
  20. 0  actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml
  21. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_params_method.erb
  22. 0  actionpack/test/fixtures/deprecated_instance_variables/_params_method.rhtml
  23. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.erb
  24. 0  actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml
  25. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_request_method.erb
  26. 0  actionpack/test/fixtures/deprecated_instance_variables/_request_method.rhtml
  27. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.erb
  28. 0  actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml
  29. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_response_method.erb
  30. 0  actionpack/test/fixtures/deprecated_instance_variables/_response_method.rhtml
  31. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.erb
  32. 0  actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml
  33. +0 −1  actionpack/test/fixtures/deprecated_instance_variables/_session_method.erb
  34. 0  actionpack/test/fixtures/deprecated_instance_variables/_session_method.rhtml
  35. +0 −43 actionpack/test/template/deprecated_instance_variables_test.rb
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Deprecation: remove deprecated instance variables. [Jeremy Kemper]
+
* Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges]
* Prefer MIME constants to strings. #7707 [Dan Kubb]
View
19 actionpack/lib/action_controller/base.rb
@@ -1112,25 +1112,6 @@ def assign_shortcuts(request, response)
@assigns = @_response.template.assigns
@_headers = @_response.headers
-
- assign_deprecated_shortcuts(request, response)
- end
-
- # TODO: assigns cookies headers params request response template
- DEPRECATED_INSTANCE_VARIABLES = %w(cookies flash headers params request response session)
-
- # Gone after 1.2.
- def assign_deprecated_shortcuts(request, response)
- DEPRECATED_INSTANCE_VARIABLES.each do |method|
- var = "@#{method}"
- if instance_variables.include?(var)
- value = instance_variable_get(var)
- unless ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy === value
- raise "Deprecating #{var}, but it's already set to #{value.inspect}! Use the #{method}= writer method instead of setting #{var} directly."
- end
- end
- instance_variable_set var, ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, method)
- end
end
def initialize_current_url
View
4 actionpack/lib/action_view/base.rb
@@ -157,7 +157,7 @@ class Base
attr_accessor :controller
attr_reader :logger, :response, :headers
- attr_internal(*ActionController::Base::DEPRECATED_INSTANCE_VARIABLES)
+ attr_internal :cookies, :flash, :headers, :params, :request, :response, :session
# Specify trim mode for the ERB compiler. Defaults to '-'.
# See ERB documentation for suitable values.
@@ -555,4 +555,4 @@ def compile_template(extension, template, file_name, local_assigns)
end
end
-require 'action_view/template_error'
+require 'action_view/template_error'
View
8 actionpack/lib/action_view/template_error.rb
@@ -10,8 +10,6 @@ def initialize(base_path, file_path, assigns, source, original_exception)
@base_path, @assigns, @source, @original_exception =
base_path, assigns.dup, source, original_exception
@file_path = file_path
-
- remove_deprecated_assigns!
end
def message
@@ -82,12 +80,6 @@ def backtrace
end
private
- def remove_deprecated_assigns!
- ActionController::Base::DEPRECATED_INSTANCE_VARIABLES.each do |ivar|
- @assigns.delete(ivar)
- end
- end
-
def strip_base_path(path)
File.expand_path(path).
gsub(/^#{Regexp.escape File.expand_path(RAILS_ROOT)}/, '').
View
48 actionpack/test/controller/deprecated_instance_variables_test.rb
@@ -1,48 +0,0 @@
-require File.dirname(__FILE__) + '/../abstract_unit'
-
-class DeprecatedControllerInstanceVariablesTest < 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}.to_s end"
- class_eval "def new_#{var}; render :text => #{var}.to_s end"
- class_eval "def internal_#{var}; render :text => @_#{var}.to_s end"
- end
-
- def rescue_action(e) raise e end
- end
-
- def setup
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- @controller = Target.new
- end
-
- ActionController::Base::DEPRECATED_INSTANCE_VARIABLES.each do |var|
- class_eval <<-end_eval, __FILE__, __LINE__
- def test_old_#{var}_is_deprecated
- assert_deprecated('@#{var}') { get :old_#{var} }
- end
- def test_new_#{var}_isnt_deprecated
- assert_not_deprecated { get :new_#{var} }
- end
- 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
View
11 actionpack/test/controller/new_render_test.rb
@@ -460,14 +460,9 @@ def test_access_to_request_in_view
ActionController::Base.protected_variables_cache = nil
get :hello_world
- assert assigns.include?('request'), 'request should be in assigns'
- assert_deprecated 'request' do
- assert_kind_of ActionController::AbstractRequest, assigns['request']
- end
- assert_not_deprecated do
- assert_kind_of ActionController::AbstractRequest, @response.template.request
- assert_kind_of ActionController::AbstractRequest, assigns['_request']
- end
+ assert !assigns.include?('request'), 'request should not be in assigns'
+ assert_kind_of ActionController::AbstractRequest, assigns['_request']
+ assert_kind_of ActionController::AbstractRequest, @response.template.request
ensure
ActionController::Base.view_controller_internals = view_internals_old_value
View
1  actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.erb
@@ -1 +0,0 @@
-<%= @cookies[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.erb
@@ -1 +0,0 @@
-<%= cookies[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.erb
@@ -1 +0,0 @@
-<%= @flash[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_flash_method.erb
@@ -1 +0,0 @@
-<%= flash[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_flash_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.erb
@@ -1 +0,0 @@
-<%= @headers[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_headers_method.erb
@@ -1 +0,0 @@
-<%= headers[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_headers_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.erb
@@ -1 +0,0 @@
-<%= @params[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_params_method.erb
@@ -1 +0,0 @@
-<%= params[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_params_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.erb
@@ -1 +0,0 @@
-<%= @request.method %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_request_method.erb
@@ -1 +0,0 @@
-<%= request.method %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_request_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.erb
@@ -1 +0,0 @@
-<%= @response.body %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_response_method.erb
@@ -1 +0,0 @@
-<%= response.body %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_response_method.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.erb
@@ -1 +0,0 @@
-<%= @session[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml
No changes.
View
1  actionpack/test/fixtures/deprecated_instance_variables/_session_method.erb
@@ -1 +0,0 @@
-<%= session[:test] %>
View
0  actionpack/test/fixtures/deprecated_instance_variables/_session_method.rhtml
No changes.
View
43 actionpack/test/template/deprecated_instance_variables_test.rb
@@ -1,43 +0,0 @@
-require "#{File.dirname(__FILE__)}/../abstract_unit"
-
-class DeprecatedViewInstanceVariablesTest < Test::Unit::TestCase
- class DeprecatedInstanceVariablesController < ActionController::Base
- self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
-
- def self.controller_path; 'deprecated_instance_variables' end
-
- ActionController::Base::DEPRECATED_INSTANCE_VARIABLES.each do |var|
- class_eval <<-end_eval
- def old_#{var}_inline; render :inline => '<%= @#{var}.to_s %>' end
- def new_#{var}_inline; render :inline => '<%= #{var}.to_s %>' end
- def old_#{var}_partial; render :partial => '#{var}_ivar' end
- def new_#{var}_partial; render :partial => '#{var}_method' end
- end_eval
- end
-
- def rescue_action(e) raise e end
- end
-
- def setup
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- @controller = DeprecatedInstanceVariablesController.new
- end
-
- ActionController::Base::DEPRECATED_INSTANCE_VARIABLES.each do |var|
- class_eval <<-end_eval, __FILE__, __LINE__
- def test_old_#{var}_is_deprecated
- assert_deprecated('@#{var}') { get :old_#{var}_inline }
- end
- def test_new_#{var}_isnt_deprecated
- assert_not_deprecated { get :new_#{var}_inline }
- end
- def test_old_#{var}_partial_is_deprecated
- assert_deprecated('@#{var}') { get :old_#{var}_partial }
- end
- def test_new_#{var}_partial_isnt_deprecated
- assert_not_deprecated { get :new_#{var}_partial }
- end
- end_eval
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.