Use swap helper method in html5 tests
This commit is contained in:
parent
da649740c9
commit
326dcdfe19
|
@ -98,10 +98,10 @@ class InputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "when not using HTML5, it does not generate autofocus attribute" do
|
test "when not using HTML5, it does not generate autofocus attribute" do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @user, :name, :string, :autofocus => true
|
with_input_for @user, :name, :string, :autofocus => true
|
||||||
assert_no_select 'input.string[autofocus]'
|
assert_no_select 'input.string[autofocus]'
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'input should render components according to an optional :components option' do
|
test 'input should render components according to an optional :components option' do
|
||||||
|
@ -167,10 +167,10 @@ class InputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'when not using HTML5, does not show maxlength attribute' do
|
test 'when not using HTML5, does not show maxlength attribute' do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @user, :password, :password
|
with_input_for @user, :password, :password
|
||||||
assert_no_select 'input[type=password][maxlength]'
|
assert_no_select 'input[type=password][maxlength]'
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'input should not generate placeholder by default' do
|
test 'input should not generate placeholder by default' do
|
||||||
|
@ -205,10 +205,10 @@ class InputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "input should not allow type #{type} if HTML5 compatibility is disabled" do
|
test "input should not allow type #{type} if HTML5 compatibility is disabled" do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @user, :name, type
|
with_input_for @user, :name, type
|
||||||
assert_no_select "input[type=#{type}]"
|
assert_no_select "input[type=#{type}]"
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -347,20 +347,20 @@ class InputTest < ActionView::TestCase
|
||||||
|
|
||||||
# Numeric input but HTML5 disabled
|
# Numeric input but HTML5 disabled
|
||||||
test ' when not using HTML5 input should not generate field with type number and use text instead' do
|
test ' when not using HTML5 input should not generate field with type number and use text instead' do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @user, :age, :integer
|
with_input_for @user, :age, :integer
|
||||||
assert_no_select "input[type=number]"
|
assert_no_select "input[type=number]"
|
||||||
assert_no_select "input#user_age[text]"
|
assert_no_select "input#user_age[text]"
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'when not using HTML5 input should not use min or max or step attributes' do
|
test 'when not using HTML5 input should not use min or max or step attributes' do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @validating_user, :age, :integer
|
with_input_for @validating_user, :age, :integer
|
||||||
assert_no_select "input[min]"
|
assert_no_select "input[min]"
|
||||||
assert_no_select "input[max]"
|
assert_no_select "input[max]"
|
||||||
assert_no_select "input[step]"
|
assert_no_select "input[step]"
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[:integer, :float, :decimal].each do |type|
|
[:integer, :float, :decimal].each do |type|
|
||||||
|
@ -773,11 +773,11 @@ class InputTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'when not using HTML5, collection input with radio type should not generate required html attribute' do
|
test 'when not using HTML5, collection input with radio type should not generate required html attribute' do
|
||||||
SimpleForm.html5 = false
|
swap SimpleForm, :html5 => false do
|
||||||
with_input_for @user, :name, :radio, :collection => ['Jose' , 'Carlos']
|
with_input_for @user, :name, :radio, :collection => ['Jose' , 'Carlos']
|
||||||
assert_select 'input[type=radio].required'
|
assert_select 'input[type=radio].required'
|
||||||
assert_no_select 'input[type=radio][required]'
|
assert_no_select 'input[type=radio][required]'
|
||||||
SimpleForm.html5 = true
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'collection input with select type should not generate invalid required html attribute' do
|
test 'collection input with select type should not generate invalid required html attribute' do
|
||||||
|
|
Loading…
Reference in New Issue