aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorNikolay Shebanov <nikolay.shebanov@gmail.com>2013-02-22 02:22:27 +0400
committerNikolay Shebanov <nikolay.shebanov@gmail.com>2013-02-25 20:03:37 +0400
commit371a5f2d73f73243ec2440305fdfab64088f35a3 (patch)
treec3742e788758fe147180351eceb5aeafde94ba03 /actionpack
parentb4051edf841c8a6780df9af7afa9892bfd811c79 (diff)
downloadrails-371a5f2d73f73243ec2440305fdfab64088f35a3.tar.gz
rails-371a5f2d73f73243ec2440305fdfab64088f35a3.tar.bz2
rails-371a5f2d73f73243ec2440305fdfab64088f35a3.zip
Fix #9360 regression in content_for
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md2
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb2
-rw-r--r--actionpack/test/template/capture_helper_test.rb4
3 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 94eb876db5..5f68fbc608 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -999,4 +999,6 @@
* `ActionView::Helpers::TextHelper#highlight` now defaults to the
HTML5 `mark` element. *Brian Cardarella*
+* Fixed `ActionView::Helpers::CaptureHelper#content_for` regression (described in #9360). *Nikolay Shebanov*
+
Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/actionpack/CHANGELOG.md) for previous changes.
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index 4ec860d69a..1bad82159a 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -156,7 +156,7 @@ module ActionView
end
nil
else
- @view_flow.get(name)
+ @view_flow.get(name).presence
end
end
diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb
index 234ac3252d..938f1c3e54 100644
--- a/actionpack/test/template/capture_helper_test.rb
+++ b/actionpack/test/template/capture_helper_test.rb
@@ -137,6 +137,10 @@ class CaptureHelperTest < ActionView::TestCase
assert_equal 'bar', content_for(:title)
end
+ def test_content_for_returns_nil_when_content_missing
+ assert_equal nil, content_for(:some_missing_key)
+ end
+
def test_content_for_question_mark
assert ! content_for?(:title)
content_for :title, 'title'