mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 02:39:37 +02:00
Add money form field
This commit is contained in:
parent
bbabaf75f6
commit
42ee4fe804
3 changed files with 22 additions and 0 deletions
|
@ -3,4 +3,8 @@ class DefaultFormBuilder < ActionView::Helpers::FormBuilder
|
|||
self.multipart = true
|
||||
@template.legal_document_field(@object_name, method, objectify_options(options))
|
||||
end
|
||||
|
||||
def money_field(method, options = {})
|
||||
@template.money_field(@object_name, method, objectify_options(options))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,4 +5,11 @@ module FormHelper
|
|||
|
||||
file_field(object_name, method, options)
|
||||
end
|
||||
|
||||
def money_field(object_name, method, options = {})
|
||||
options[:pattern] = '^[0-9.]+$' unless options[:pattern]
|
||||
options[:maxlength] = 255 unless options[:maxlength]
|
||||
|
||||
text_field(object_name, method, options)
|
||||
end
|
||||
end
|
||||
|
|
11
spec/views/shared_examples/money_form_field.rb
Normal file
11
spec/views/shared_examples/money_form_field.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
RSpec.shared_examples 'money form field' do
|
||||
it 'has max length' do
|
||||
render
|
||||
expect(field[:maxlength]).to eq('255')
|
||||
end
|
||||
|
||||
it 'has money pattern' do
|
||||
render
|
||||
expect(field[:pattern]).to eq('^[0-9.]+$')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue