aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-08-28 11:47:06 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-08-28 11:47:06 -0700
commitce4d13861dc54a1ac7fbe411327b9a2427f95366 (patch)
tree54863b03010dbbc4f729bc600b8e83f54e460c71
parent293f99700d6f2388ea5c504d706651ff3044d733 (diff)
parentacbf2b74aa3001fb6064bba96cd0033495774357 (diff)
downloadrails-ce4d13861dc54a1ac7fbe411327b9a2427f95366.tar.gz
rails-ce4d13861dc54a1ac7fbe411327b9a2427f95366.tar.bz2
rails-ce4d13861dc54a1ac7fbe411327b9a2427f95366.zip
Merge branch 'master' of git@github.com:rails/rails
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/renderable_partial.rb10
-rw-r--r--actionpack/test/controller/new_render_test.rb6
-rw-r--r--activesupport/lib/active_support/deprecation.rb16
-rw-r--r--railties/test/secret_key_generation_test.rb4
5 files changed, 33 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index f6942b43f1..6717162d1e 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Deprecated implicit local assignments when rendering partials [Josh Peek]
+
* Introduce current_cycle helper method to return the current value without bumping the cycle. #417 [Ken Collins]
* Allow polymorphic_url helper to take url options. #880 [Tarmo Tänav]
diff --git a/actionpack/lib/action_view/renderable_partial.rb b/actionpack/lib/action_view/renderable_partial.rb
index 5203e57ead..123a9aebbc 100644
--- a/actionpack/lib/action_view/renderable_partial.rb
+++ b/actionpack/lib/action_view/renderable_partial.rb
@@ -27,8 +27,14 @@ module ActionView
def render_partial(view, object = nil, local_assigns = {}, as = nil)
object ||= local_assigns[:object] ||
- local_assigns[variable_name] ||
- view.controller.instance_variable_get("@#{variable_name}") if view.respond_to?(:controller)
+ local_assigns[variable_name]
+
+ if view.respond_to?(:controller)
+ object ||= ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
+ view.controller.instance_variable_get("@#{variable_name}"),
+ "@#{variable_name} will no longer be implicitly assigned to #{variable_name}"
+ )
+ end
# Ensure correct object is reassigned to other accessors
local_assigns[:object] = local_assigns[variable_name] = object
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 82919b7777..698c46f78c 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -832,8 +832,10 @@ EOS
end
def test_partial_with_implicit_local_assignment
- get :partial_with_implicit_local_assignment
- assert_equal "Hello: Marcel", @response.body
+ assert_deprecated do
+ get :partial_with_implicit_local_assignment
+ assert_equal "Hello: Marcel", @response.body
+ end
end
def test_render_missing_partial_template
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index 01eb5df593..e543163bd5 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -162,6 +162,22 @@ module ActiveSupport
end
end
+ class DeprecatedObjectProxy < DeprecationProxy
+ def initialize(object, message)
+ @object = object
+ @message = message
+ end
+
+ private
+ def target
+ @object
+ end
+
+ def warn(callstack, called, args)
+ ActiveSupport::Deprecation.warn(@message, callstack)
+ end
+ end
+
# Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
# which emits deprecation warnings on any method call (except +inspect+).
class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc:
diff --git a/railties/test/secret_key_generation_test.rb b/railties/test/secret_key_generation_test.rb
index 2a04cff856..7269f98ce5 100644
--- a/railties/test/secret_key_generation_test.rb
+++ b/railties/test/secret_key_generation_test.rb
@@ -31,6 +31,8 @@ class SecretKeyGenerationTest < Test::Unit::TestCase
end
def test_secret_key_generation
- assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH
+ assert_deprecated /ActiveSupport::SecureRandom\.hex\(64\)/ do
+ assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH
+ end
end
end