Test aria-required on collection select input.

[#780]
This commit is contained in:
Cameron Cundiff 2013-04-07 13:57:07 -04:00
parent a15b4700ff
commit 52f52660d9
1 changed files with 25 additions and 0 deletions

View File

@ -176,6 +176,7 @@ class CollectionSelectInputTest < ActionView::TestCase
with_input_for @user, :name, :select, include_blank: false, collection: ['Jose' , 'Carlos']
assert_select 'select.required'
assert_no_select 'select[required]'
assert_no_select 'select[aria-required=true]'
end
test 'collection input with select type with multiple attribute should generate required html attribute without blank option' do
@ -190,6 +191,30 @@ class CollectionSelectInputTest < ActionView::TestCase
assert_select 'select[required]'
end
test 'with a blank option, a collection input of type select has an aria-required html attribute' do
with_input_for @user, :name, :select, include_blank: true, collection: ['Jose' , 'Carlos']
assert_select 'select.required'
assert_select 'select[aria-required=true]'
end
test 'without a blank option, a collection input of type select does not have an aria-required html attribute' do
with_input_for @user, :name, :select, include_blank: false, collection: ['Jose' , 'Carlos']
assert_select 'select.required'
assert_no_select 'select[aria-required]'
end
test 'without a blank option and with a multiple option, a collection input of type select has an aria-required html attribute' do
with_input_for @user, :name, :select, include_blank: false, input_html: {multiple: true}, collection: ['Jose' , 'Carlos']
assert_select 'select.required'
assert_select 'select[aria-required=true]'
end
test 'with a blank option and a multiple option, a collection input of type select has an aria-required html attribute' do
with_input_for @user, :name, :select, include_blank: true, input_html: {multiple: true}, collection: ['Jose' , 'Carlos']
assert_select 'select.required'
assert_select 'select[aria-required]'
end
test 'input should allow disabled options with a lambda for collection select' do
with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
disabled: lambda { |x| x == "Carlos" }