From c2ad51a2d037b709f4475cf115d89432ec56caac Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Mon, 8 Jun 2015 23:55:10 +0300 Subject: Collection check boxes propagates input's id to the label's for attribute. --- actionview/test/template/form_collections_helper_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'actionview/test') 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| -- cgit v1.2.3