Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix custom field form builder specs

Benjamin Bädorf8d9cf86115da
diff --git a/lib/custom_field_form_builder.rb b/lib/custom_field_form_builder.rb
index eb91fda7b6a..df9292e6fb2 100644
--- a/lib/custom_field_form_builder.rb
+++ b/lib/custom_field_form_builder.rb
@@ -68,13 +68,7 @@ class CustomFieldFormBuilder < TabularFormBuilder
case field_format.try(:edit_as)
when 'date'
- angular_component_tag 'op-single-date-picker',
- class: input_options.class,
- inputs: {
- value: input_options.value,
- id: input_options.id,
- name: input_options.name
- }
+ date_picker(field, input_options)
when 'text'
text_area(field, input_options.merge(with_text_formatting: true, macros: false, editor_type: 'constrained'))
when 'bool'
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index 06ecbc89f2d..62a97120723 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -84,6 +84,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
end
def date_picker(field, options = {})
+ options[:class] = Array(options[:class])
merge_required_attributes(options[:required], options)
options[:visible_overflow] = true;
diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rb
index 6f27f44eada..c7126bff451 100644
--- a/spec/lib/custom_field_form_builder_spec.rb
+++ b/spec/lib/custom_field_form_builder_spec.rb
@@ -93,17 +93,14 @@ describe CustomFieldFormBuilder do
custom_field.field_format = 'date'
end
- it_behaves_like 'wrapped in container', 'text-field-container' do
+ it_behaves_like 'wrapped in container', 'field-container' do
let(:container_count) { 2 }
end
it 'outputs element' do
expect(output).to be_html_eql(%{
- <input class="custom-class -augmented-datepicker form--text-field"
- id="user#{custom_field.id}"
- name="user[#{custom_field.id}]"
- type="text" />
- }).at_path('input')
+<op-single-date-picker class="custom-class" data-value="null" data-id='"user_custom_field_#{custom_field.id}"' data-name='"user[custom_field_#{custom_field.id}]"'></op-single-date-picker>
+ }).at_path('op-single-date-picker')
end
end