Use classic datetime selects unless HTML5 is explicitly enabled.

This commit is contained in:
Volmer Soares 2013-11-16 02:25:24 -02:00
parent b88ae876d2
commit 5590f85ee1
6 changed files with 28 additions and 28 deletions

View File

@ -28,7 +28,7 @@ module SimpleForm
if input_options.key?(:html5)
input_options[:html5]
else
html5?
false
end
end
end

View File

@ -158,22 +158,22 @@ class FormBuilderTest < ActionView::TestCase
test 'builder should generate date select for date columns' do
with_form_for @user, :born_at
assert_select 'form input#user_born_at.date'
assert_select 'form select#user_born_at_1i.date'
end
test 'builder should generate time select for time columns' do
with_form_for @user, :delivery_time
assert_select 'form input#user_delivery_time.time'
assert_select 'form select#user_delivery_time_4i.time'
end
test 'builder should generate datetime select for datetime columns' do
with_form_for @user, :created_at
assert_select 'form input#user_created_at.datetime'
assert_select 'form select#user_created_at_1i.datetime'
end
test 'builder should generate datetime select for timestamp columns' do
with_form_for @user, :updated_at
assert_select 'form input#user_updated_at.datetime'
assert_select 'form select#user_updated_at_1i.datetime'
end
test 'builder should generate file for file columns' do
@ -406,7 +406,7 @@ class FormBuilderTest < ActionView::TestCase
test 'builder should allow overriding input type when object is not present' do
with_form_for :project, :created_at, as: :datetime
assert_select 'form input.datetime#project_created_at'
assert_select 'form select.datetime#project_created_at_1i'
with_form_for :project, :budget, as: :decimal
assert_select 'form input.decimal#project_budget'
end

View File

@ -3,50 +3,50 @@ require 'test_helper'
# Tests for datetime, date and time inputs when HTML5 compatibility is enabled in the wrapper.
class DateTimeInputWithHtml5Test < ActionView::TestCase
test 'input should generate a datetime input for datetime attributes' do
with_input_for @user, :created_at, :datetime
test 'input should generate a datetime input for datetime attributes if HTML5 compatibility is explicitly enbled' do
with_input_for @user, :created_at, :datetime, html5: true
assert_select 'input[type="datetime"]'
end
test 'input should generate a datetime select for datetime attributes if HTML5 compatibility is explicitly disabled' do
with_input_for @user, :created_at, :datetime, html5: false
test 'input should generate a datetime select for datetime attributes' do
with_input_for @user, :created_at, :datetime
assert_select 'select.datetime'
end
test 'input should generate a date input for date attributes' do
with_input_for @user, :born_at, :date
test 'input should generate a date input for date attributes if HTML5 compatibility is explicitly enbled' do
with_input_for @user, :born_at, :date, html5: true
assert_select 'input[type="date"]'
end
test 'input should generate a date select for date attributes if HTML5 compatibility is explicitly disabled' do
with_input_for @user, :born_at, :date, html5: false
test 'input should generate a date select for date attributes' do
with_input_for @user, :born_at, :date
assert_select 'select.date'
end
test 'input should generate a time input for time attributes' do
with_input_for @user, :delivery_time, :time
test 'input should generate a time input for time attributes if HTML5 compatibility is explicitly enbled' do
with_input_for @user, :delivery_time, :time, html5: true
assert_select 'input[type="time"]'
end
test 'input should generate a time select for time attributes if HTML5 compatibility is explicitly disabled' do
with_input_for @user, :delivery_time, :time, html5: false
test 'input should generate a time select for time attributes' do
with_input_for @user, :delivery_time, :time
assert_select 'select.time'
end
test 'input should generate required html attribute' do
with_input_for @user, :delivery_time, :time, required: true
with_input_for @user, :delivery_time, :time, required: true, html5: true
assert_select 'input.required'
assert_select 'input[required]'
end
test 'input should have an aria-required html attribute' do
with_input_for @user, :delivery_time, :time, required: true
with_input_for @user, :delivery_time, :time, required: true, html5: true
assert_select 'input[aria-required=true]'
end
end

View File

@ -18,12 +18,12 @@ class DisabledTest < ActionView::TestCase
test 'date input should be disabled when disabled option is true' do
with_input_for @user, :born_at, :date, disabled: true
assert_select 'input.date.disabled[disabled]'
assert_select 'select.date.disabled[disabled]'
end
test 'datetime input should be disabled when disabled option is true' do
with_input_for @user, :created_at, :datetime, disabled: true
assert_select 'input.datetime.disabled[disabled]'
assert_select 'select.datetime.disabled[disabled]'
end
test 'string input should not be disabled when disabled option is false' do

View File

@ -10,9 +10,9 @@ class InputTest < ActionView::TestCase
with_input_for @user, :age, :integer
assert_select 'input.integer'
with_input_for @user, :born_at, :date
assert_select 'input.date'
assert_select 'select.date'
with_input_for @user, :created_at, :datetime
assert_select 'input.datetime'
assert_select 'select.datetime'
end
test 'string input should generate autofocus attribute when autofocus option is true' do
@ -48,12 +48,12 @@ class InputTest < ActionView::TestCase
test 'date input should generate autofocus attribute when autofocus option is true' do
with_input_for @user, :born_at, :date, autofocus: true
assert_select 'input.date[autofocus]'
assert_select 'select.date[autofocus]'
end
test 'datetime input should generate autofocus attribute when autofocus option is true' do
with_input_for @user, :created_at, :datetime, autofocus: true
assert_select 'input.datetime[autofocus]'
assert_select 'select.datetime[autofocus]'
end
test 'string input should generate autofocus attribute when autofocus option is false' do

View File

@ -18,12 +18,12 @@ class ReadonlyTest < ActionView::TestCase
test 'date input should generate readonly elements when readonly option is true' do
with_input_for @user, :born_at, :date, readonly: true
assert_select 'input.date.readonly[readonly]'
assert_select 'select.date.readonly[readonly]'
end
test 'datetime input should generate readonly elements when readonly option is true' do
with_input_for @user, :created_at, :datetime, readonly: true
assert_select 'input.datetime.readonly[readonly]'
assert_select 'select.datetime.readonly[readonly]'
end
test 'string input should generate readonly elements when readonly option is false' do