aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorAna María Martínez Gómez <ammartinez@suse.de>2018-08-08 17:46:53 +0200
committerAna María Martínez Gómez <ammartinez@suse.de>2018-08-08 18:04:50 +0200
commit0853cdffa2f09f02e854baed35c3323b6b35006f (patch)
treee9b39e2af399acca545f2b48c448cf1ce857d965 /actionview
parent4ca9fa11f9a9b5604371f260515c28a0f29cd921 (diff)
downloadrails-0853cdffa2f09f02e854baed35c3323b6b35006f.tar.gz
rails-0853cdffa2f09f02e854baed35c3323b6b35006f.tar.bz2
rails-0853cdffa2f09f02e854baed35c3323b6b35006f.zip
Add tests for privates methods in view's helpers
Test that using private methods in `options_from_collection_for_select` is deprecated. Make the unused `secret` paramether in the `Post` Struct private to use it in the test.
Diffstat (limited to 'actionview')
-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..7bce946d3b 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 in view's helpers is deprecated/) { options_from_collection_for_select(dummy_posts, "secret", "title") }
+ end
+
+ def test_collection_options_with_private_text_method
+ assert_deprecated(/Using private methods in view's helpers is deprecated/) { 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>",