aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-28 13:28:50 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-28 13:28:50 -0800
commitfae2e4d05d122e2d711a90c0a46dfb4b42dbadc3 (patch)
treed1e66590ae67a5ca306613609bad4c513edfcfbb
parentdc53fe92404910a83cfc056d126f45772dfa58fe (diff)
parent371a5f2d73f73243ec2440305fdfab64088f35a3 (diff)
downloadrails-fae2e4d05d122e2d711a90c0a46dfb4b42dbadc3.tar.gz
rails-fae2e4d05d122e2d711a90c0a46dfb4b42dbadc3.tar.bz2
rails-fae2e4d05d122e2d711a90c0a46dfb4b42dbadc3.zip
Merge pull request #9366 from killthekitten/fix-content_for-regression
Fix for #9360 content_for regression
-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 180d802dbe..c45e14abf7 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1041,4 +1041,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'