Ensure uuid fields are generated with type=text

This commit is contained in:
Carlos Antonio da Silva 2014-07-15 10:42:52 -03:00
parent 88e96db1d7
commit 5943e07fc4
3 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,6 @@
### bug fix
* Fix `uuid` input to generate proper input[type=text].
## 3.1.0.rc2
### enhancements

View File

@ -6,7 +6,7 @@ module SimpleForm
def input(wrapper_options = nil)
unless string?
input_html_classes.unshift("string")
input_html_options[:type] ||= input_type if html5?
input_html_options[:type] ||= input_type if html5? && !postgresql_type?
end
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@ -16,6 +16,10 @@ module SimpleForm
private
def postgresql_type?
input_type == :uuid
end
def string?
input_type == :string
end

View File

@ -126,9 +126,9 @@ class FormBuilderTest < ActionView::TestCase
assert_select 'form input#user_credit_limit.numeric.decimal'
end
test 'builder generates uuid fields for uuid columns' do
test 'builder generates text fields for uuid columns' do
with_form_for @user, :uuid
assert_select 'form input#user_uuid.string.uuid'
assert_select 'form input[type=text]#user_uuid.string.uuid'
end
test 'builder generates password fields for columns that matches password' do