1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix invalid css selectors in form_collections_helper_test.rb.

This commit is contained in:
Timm 2014-05-27 16:27:52 +02:00
parent bcd71b4c9a
commit 01ff0f311e

View file

@ -225,14 +225,14 @@ class FormCollectionsHelperTest < ActionView::TestCase
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
with_collection_check_boxes :user, :category_ids, collection, :id, :name, { index: 322 }
assert_select "input[type=hidden][name='user[322][category_ids][]'][value=]", count: 1
assert_select "input[type=hidden][name='user[322][category_ids][]'][value='']", count: 1
end
test 'collection check boxes does not generate a hidden field if include_hidden option is false' do
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
with_collection_check_boxes :user, :category_ids, collection, :id, :name, include_hidden: false
assert_select "input[type=hidden][name='user[category_ids][]'][value=]", :count => 0
assert_select "input[type=hidden][name='user[category_ids][]'][value='']", :count => 0
end
test 'collection check boxes accepts a collection and generate a series of checkboxes with labels for label method' do
@ -353,27 +353,27 @@ class FormCollectionsHelperTest < ActionView::TestCase
collection = (1..3).map{|i| [i, "Category #{i}"] }
with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => [1, 3]
assert_select 'input[type=checkbox][value=1][readonly=readonly]'
assert_select 'input[type=checkbox][value=3][readonly=readonly]'
assert_no_select 'input[type=checkbox][value=2][readonly=readonly]'
assert_select 'input[type=checkbox][value="1"][readonly=readonly]'
assert_select 'input[type=checkbox][value="3"][readonly=readonly]'
assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]'
end
test 'collection check boxes accepts single readonly item' do
collection = (1..3).map{|i| [i, "Category #{i}"] }
with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => 1
assert_select 'input[type=checkbox][value=1][readonly=readonly]'
assert_no_select 'input[type=checkbox][value=3][readonly=readonly]'
assert_no_select 'input[type=checkbox][value=2][readonly=readonly]'
assert_select 'input[type=checkbox][value="1"][readonly=readonly]'
assert_no_select 'input[type=checkbox][value="3"][readonly=readonly]'
assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]'
end
test 'collection check boxes accepts a proc to readonly items' do
collection = (1..3).map{|i| [i, "Category #{i}"] }
with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => proc { |i| i.first == 1 }
assert_select 'input[type=checkbox][value=1][readonly=readonly]'
assert_no_select 'input[type=checkbox][value=3][readonly=readonly]'
assert_no_select 'input[type=checkbox][value=2][readonly=readonly]'
assert_select 'input[type=checkbox][value="1"][readonly=readonly]'
assert_no_select 'input[type=checkbox][value="3"][readonly=readonly]'
assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]'
end
test 'collection check boxes accepts html options' do