2011-09-03 12:49:54 -04:00
|
|
|
# encoding: UTF-8
|
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class HiddenInputTest < ActionView::TestCase
|
2014-05-14 13:19:06 -04:00
|
|
|
test 'input generates a hidden field' do
|
2011-09-03 12:49:54 -04:00
|
|
|
with_input_for @user, :name, :hidden
|
|
|
|
assert_no_select 'input[type=text]'
|
|
|
|
assert_select 'input#user_name[type=hidden]'
|
|
|
|
end
|
|
|
|
|
2014-05-14 13:19:06 -04:00
|
|
|
test 'hint does not be generated for hidden fields' do
|
2013-01-28 16:02:59 -05:00
|
|
|
store_translations(:en, simple_form: { hints: { user: { name: "text" } } }) do
|
2011-12-04 07:29:59 -05:00
|
|
|
with_input_for @user, :name, :hidden
|
|
|
|
assert_no_select 'span.hint'
|
|
|
|
end
|
2011-09-03 12:49:54 -04:00
|
|
|
end
|
|
|
|
|
2014-05-14 13:19:06 -04:00
|
|
|
test 'label does not be generated for hidden inputs' do
|
2011-09-03 12:49:54 -04:00
|
|
|
with_input_for @user, :name, :hidden
|
|
|
|
assert_no_select 'label'
|
|
|
|
end
|
|
|
|
|
2014-05-14 13:19:06 -04:00
|
|
|
test 'required/aria-required/optional options does not be generated for hidden inputs' do
|
2011-09-03 12:49:54 -04:00
|
|
|
with_input_for @user, :name, :hidden
|
|
|
|
assert_no_select 'input.required'
|
|
|
|
assert_no_select 'input[required]'
|
2013-04-07 14:00:58 -04:00
|
|
|
assert_no_select 'input[aria-required]'
|
2011-09-03 12:49:54 -04:00
|
|
|
assert_no_select 'input.optional'
|
|
|
|
assert_select 'input.hidden#user_name'
|
|
|
|
end
|
|
|
|
end
|