aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/form_collections_helper_test.rb
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2015-06-08 23:55:10 +0300
committerSean Griffin <sean@seantheprogrammer.com>2015-10-20 16:39:05 -0600
commitc2ad51a2d037b709f4475cf115d89432ec56caac (patch)
treede9f93686100c37d4a9f5dd57cc195a177edf203 /actionview/test/template/form_collections_helper_test.rb
parent7e434d6d2d3e8056e3024f6a3ec2db9e0365d10a (diff)
downloadrails-c2ad51a2d037b709f4475cf115d89432ec56caac.tar.gz
rails-c2ad51a2d037b709f4475cf115d89432ec56caac.tar.bz2
rails-c2ad51a2d037b709f4475cf115d89432ec56caac.zip
Collection check boxes propagates input's id to the label's for attribute.
Diffstat (limited to 'actionview/test/template/form_collections_helper_test.rb')
-rw-r--r--actionview/test/template/form_collections_helper_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/actionview/test/template/form_collections_helper_test.rb b/actionview/test/template/form_collections_helper_test.rb
index 41932d15ee..b59be8e36c 100644
--- a/actionview/test/template/form_collections_helper_test.rb
+++ b/actionview/test/template/form_collections_helper_test.rb
@@ -306,6 +306,17 @@ class FormCollectionsHelperTest < ActionView::TestCase
assert_select 'input[type=checkbox][value="2"].bar'
end
+ test 'collection check boxes propagates input id to the label for attribute' do
+ collection = [[1, 'Category 1', {id: 'foo'}], [2, 'Category 2', {id: 'bar'}]]
+ with_collection_check_boxes :user, :active, collection, :first, :second
+
+ assert_select 'input[type=checkbox][value="1"]#foo'
+ assert_select 'input[type=checkbox][value="2"]#bar'
+
+ assert_select 'label[for=foo]'
+ assert_select 'label[for=bar]'
+ end
+
test 'collection check boxes sets the label class defined inside the block' do
collection = [[1, 'Category 1', {class: 'foo'}], [2, 'Category 2', {class: 'bar'}]]
with_collection_check_boxes :user, :active, collection, :second, :first do |b|