aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2018-08-22 23:39:07 +0930
committerMatthew Draper <matthew@trebex.net>2018-08-23 00:08:35 +0930
commit047a893da7a43b8e115b854c73735b9e6475838e (patch)
tree66cef1a720dfa5cf9f1f4f35f117da9ae7c6e66d /actionview/test
parent9eee4c1ed92050edbee08f16be78d355fb19c2f5 (diff)
parent0853cdffa2f09f02e854baed35c3323b6b35006f (diff)
downloadrails-047a893da7a43b8e115b854c73735b9e6475838e.tar.gz
rails-047a893da7a43b8e115b854c73735b9e6475838e.tar.bz2
rails-047a893da7a43b8e115b854c73735b9e6475838e.zip
Merge pull request #33547 from Ana06/patch-1
Use public_send in value_for_collection
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_options_helper_test.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index 8f796bdb83..8a0a706fef 100644
--- a/actionview/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -21,7 +21,12 @@ class FormOptionsHelperTest < ActionView::TestCase
tests ActionView::Helpers::FormOptionsHelper
silence_warnings do
- Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :category, :origin, :allow_comments)
+ Post = Struct.new("Post", :title, :author_name, :body, :written_on, :category, :origin, :allow_comments) do
+ private
+ def secret
+ "This is super secret: #{author_name} is not the real author of #{title}"
+ end
+ end
Continent = Struct.new("Continent", :continent_name, :countries)
Country = Struct.new("Country", :country_id, :country_name)
Firm = Struct.new("Firm", :time_zone)
@@ -68,6 +73,14 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_collection_options_with_private_value_method
+ assert_deprecated("Using private methods from view helpers is deprecated (calling private Struct::Post#secret)") { options_from_collection_for_select(dummy_posts, "secret", "title") }
+ end
+
+ def test_collection_options_with_private_text_method
+ assert_deprecated("Using private methods from view helpers is deprecated (calling private Struct::Post#secret)") { options_from_collection_for_select(dummy_posts, "author_name", "secret") }
+ end
+
def test_collection_options_with_preselected_value
assert_dom_equal(
"<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>",