formtastic 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +13 -13
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +99 -64
- data/README.md +7 -2
- data/formtastic.gemspec +5 -3
- data/gemfiles/{rails_5.2 → rails_7.0}/Gemfile +1 -1
- data/gemfiles/rails_7.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +1 -1
- data/lib/formtastic/action_class_finder.rb +1 -0
- data/lib/formtastic/actions/base.rb +1 -0
- data/lib/formtastic/actions/button_action.rb +1 -0
- data/lib/formtastic/actions/buttonish.rb +1 -0
- data/lib/formtastic/actions/input_action.rb +1 -0
- data/lib/formtastic/actions/link_action.rb +1 -0
- data/lib/formtastic/actions.rb +1 -0
- data/lib/formtastic/deprecation.rb +2 -1
- data/lib/formtastic/engine.rb +1 -0
- data/lib/formtastic/form_builder.rb +1 -0
- data/lib/formtastic/helpers/action_helper.rb +1 -0
- data/lib/formtastic/helpers/actions_helper.rb +1 -0
- data/lib/formtastic/helpers/enum.rb +1 -0
- data/lib/formtastic/helpers/errors_helper.rb +1 -0
- data/lib/formtastic/helpers/fieldset_wrapper.rb +1 -0
- data/lib/formtastic/helpers/file_column_detection.rb +1 -0
- data/lib/formtastic/helpers/form_helper.rb +1 -0
- data/lib/formtastic/helpers/input_helper.rb +2 -4
- data/lib/formtastic/helpers/inputs_helper.rb +2 -1
- data/lib/formtastic/helpers/reflection.rb +1 -0
- data/lib/formtastic/helpers.rb +1 -1
- data/lib/formtastic/html_attributes.rb +1 -0
- data/lib/formtastic/i18n.rb +1 -0
- data/lib/formtastic/input_class_finder.rb +1 -0
- data/lib/formtastic/inputs/base/associations.rb +1 -0
- data/lib/formtastic/inputs/base/choices.rb +2 -1
- data/lib/formtastic/inputs/base/collections.rb +4 -1
- data/lib/formtastic/inputs/base/database.rb +5 -7
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
- data/lib/formtastic/inputs/base/errors.rb +3 -2
- data/lib/formtastic/inputs/base/fileish.rb +1 -0
- data/lib/formtastic/inputs/base/hints.rb +1 -0
- data/lib/formtastic/inputs/base/html.rb +2 -1
- data/lib/formtastic/inputs/base/labelling.rb +3 -2
- data/lib/formtastic/inputs/base/naming.rb +1 -0
- data/lib/formtastic/inputs/base/numeric.rb +1 -0
- data/lib/formtastic/inputs/base/options.rb +1 -0
- data/lib/formtastic/inputs/base/placeholder.rb +1 -0
- data/lib/formtastic/inputs/base/stringish.rb +1 -0
- data/lib/formtastic/inputs/base/timeish.rb +4 -3
- data/lib/formtastic/inputs/base/validations.rb +2 -1
- data/lib/formtastic/inputs/base/wrapping.rb +1 -0
- data/lib/formtastic/inputs/base.rb +3 -2
- data/lib/formtastic/inputs/boolean_input.rb +2 -1
- data/lib/formtastic/inputs/check_boxes_input.rb +2 -1
- data/lib/formtastic/inputs/color_input.rb +1 -0
- data/lib/formtastic/inputs/country_input.rb +1 -0
- data/lib/formtastic/inputs/datalist_input.rb +1 -0
- data/lib/formtastic/inputs/date_picker_input.rb +1 -0
- data/lib/formtastic/inputs/date_select_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
- data/lib/formtastic/inputs/email_input.rb +1 -0
- data/lib/formtastic/inputs/file_input.rb +1 -0
- data/lib/formtastic/inputs/hidden_input.rb +3 -2
- data/lib/formtastic/inputs/number_input.rb +1 -0
- data/lib/formtastic/inputs/password_input.rb +1 -0
- data/lib/formtastic/inputs/phone_input.rb +1 -0
- data/lib/formtastic/inputs/radio_input.rb +1 -0
- data/lib/formtastic/inputs/range_input.rb +1 -0
- data/lib/formtastic/inputs/search_input.rb +1 -0
- data/lib/formtastic/inputs/select_input.rb +1 -0
- data/lib/formtastic/inputs/string_input.rb +1 -0
- data/lib/formtastic/inputs/text_input.rb +1 -0
- data/lib/formtastic/inputs/time_picker_input.rb +1 -0
- data/lib/formtastic/inputs/time_select_input.rb +1 -0
- data/lib/formtastic/inputs/time_zone_input.rb +1 -0
- data/lib/formtastic/inputs/url_input.rb +1 -0
- data/lib/formtastic/inputs.rb +1 -0
- data/lib/formtastic/localized_string.rb +1 -0
- data/lib/formtastic/localizer.rb +1 -0
- data/lib/formtastic/namespaced_class_finder.rb +7 -8
- data/lib/formtastic/version.rb +2 -1
- data/lib/formtastic.rb +1 -0
- data/lib/generators/formtastic/form/form_generator.rb +1 -0
- data/lib/generators/formtastic/input/input_generator.rb +1 -0
- data/lib/generators/formtastic/install/install_generator.rb +1 -0
- data/lib/generators/templates/formtastic.rb +1 -0
- data/script/integration-template.rb +2 -3
- data/spec/action_class_finder_spec.rb +1 -0
- data/spec/actions/button_action_spec.rb +17 -16
- data/spec/actions/generic_action_spec.rb +130 -129
- data/spec/actions/input_action_spec.rb +16 -15
- data/spec/actions/link_action_spec.rb +25 -24
- data/spec/builder/custom_builder_spec.rb +5 -4
- data/spec/builder/error_proc_spec.rb +2 -1
- data/spec/builder/semantic_fields_for_spec.rb +26 -25
- data/spec/fast_spec_helper.rb +1 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +8 -7
- data/spec/generators/formtastic/input/input_generator_spec.rb +1 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +1 -0
- data/spec/helpers/action_helper_spec.rb +15 -14
- data/spec/helpers/actions_helper_spec.rb +42 -41
- data/spec/helpers/form_helper_spec.rb +26 -19
- data/spec/helpers/input_helper_spec.rb +70 -69
- data/spec/helpers/inputs_helper_spec.rb +179 -179
- data/spec/helpers/reflection_helper_spec.rb +4 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +4 -3
- data/spec/i18n_spec.rb +13 -12
- data/spec/input_class_finder_spec.rb +1 -0
- data/spec/inputs/base/collections_spec.rb +2 -0
- data/spec/inputs/base/validations_spec.rb +1 -0
- data/spec/inputs/boolean_input_spec.rb +66 -65
- data/spec/inputs/check_boxes_input_spec.rb +89 -88
- data/spec/inputs/color_input_spec.rb +7 -6
- data/spec/inputs/country_input_spec.rb +10 -9
- data/spec/inputs/custom_input_spec.rb +1 -0
- data/spec/inputs/datalist_input_spec.rb +2 -1
- data/spec/inputs/date_picker_input_spec.rb +109 -108
- data/spec/inputs/date_select_input_spec.rb +63 -62
- data/spec/inputs/datetime_picker_input_spec.rb +118 -117
- data/spec/inputs/datetime_select_input_spec.rb +72 -71
- data/spec/inputs/email_input_spec.rb +16 -15
- data/spec/inputs/file_input_spec.rb +17 -16
- data/spec/inputs/hidden_input_spec.rb +29 -28
- data/spec/inputs/include_blank_spec.rb +7 -6
- data/spec/inputs/label_spec.rb +25 -24
- data/spec/inputs/number_input_spec.rb +159 -158
- data/spec/inputs/password_input_spec.rb +16 -15
- data/spec/inputs/phone_input_spec.rb +16 -15
- data/spec/inputs/placeholder_spec.rb +17 -16
- data/spec/inputs/radio_input_spec.rb +58 -57
- data/spec/inputs/range_input_spec.rb +108 -107
- data/spec/inputs/readonly_spec.rb +5 -4
- data/spec/inputs/search_input_spec.rb +15 -14
- data/spec/inputs/select_input_spec.rb +144 -93
- data/spec/inputs/string_input_spec.rb +36 -35
- data/spec/inputs/text_input_spec.rb +32 -31
- data/spec/inputs/time_picker_input_spec.rb +110 -109
- data/spec/inputs/time_select_input_spec.rb +71 -70
- data/spec/inputs/time_zone_input_spec.rb +21 -20
- data/spec/inputs/url_input_spec.rb +16 -15
- data/spec/inputs/with_options_spec.rb +8 -7
- data/spec/localizer_spec.rb +1 -0
- data/spec/namespaced_class_finder_spec.rb +17 -5
- data/spec/schema.rb +1 -0
- data/spec/spec_helper.rb +8 -8
- data/spec/support/custom_macros.rb +64 -63
- data/spec/support/deprecation.rb +2 -1
- data/spec/support/shared_examples.rb +2 -1
- data/spec/support/specialized_class_finder_shared_example.rb +1 -0
- data/spec/support/test_environment.rb +1 -0
- metadata +29 -14
data/spec/inputs/label_spec.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'spec_helper'
|
|
3
4
|
|
|
4
5
|
RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
@@ -6,7 +7,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
6
7
|
include FormtasticSpecHelper
|
|
7
8
|
|
|
8
9
|
before do
|
|
9
|
-
@output_buffer = ''
|
|
10
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
11
|
mock_everything
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
20
21
|
concat(semantic_form_for(@new_post) do |builder|
|
|
21
22
|
builder.input(:title, :required => true, :label => true)
|
|
22
23
|
end)
|
|
23
|
-
output_buffer.
|
|
24
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
24
25
|
concat(semantic_form_for(@new_post) do |builder|
|
|
25
26
|
builder.input(:title, :required => true, :label => true)
|
|
26
27
|
end)
|
|
@@ -28,7 +29,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
28
29
|
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
|
|
29
30
|
Formtastic::FormBuilder.required_string = default_required_str
|
|
30
31
|
|
|
31
|
-
expect(output_buffer.scan(required_string).count).to eq(1)
|
|
32
|
+
expect(output_buffer.to_s.scan(required_string).count).to eq(1)
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -36,9 +37,9 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
36
37
|
concat(semantic_form_for(@new_post) do |builder|
|
|
37
38
|
builder.input(:title)
|
|
38
39
|
end)
|
|
39
|
-
expect(output_buffer).to have_tag('label', :text => /Title/)
|
|
40
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /Title/)
|
|
40
41
|
end
|
|
41
|
-
|
|
42
|
+
|
|
42
43
|
it 'should use i18n instead of the method name when method given as a String' do
|
|
43
44
|
with_config :i18n_cache_lookups, true do
|
|
44
45
|
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => "I18n title" } } } }
|
|
@@ -46,7 +47,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
46
47
|
builder.input("title")
|
|
47
48
|
end)
|
|
48
49
|
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
|
|
49
|
-
expect(output_buffer).to have_tag('label', :text => /I18n title/)
|
|
50
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /I18n title/)
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
|
|
@@ -54,7 +55,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
54
55
|
concat(semantic_form_for(@new_post) do |builder|
|
|
55
56
|
builder.input(:publish_at)
|
|
56
57
|
end)
|
|
57
|
-
expect(output_buffer).to have_tag('label', :text => /Publish at/)
|
|
58
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /Publish at/)
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
describe 'when required is given' do
|
|
@@ -62,7 +63,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
62
63
|
concat(semantic_form_for(@new_post) do |builder|
|
|
63
64
|
builder.input(:title, :required => true)
|
|
64
65
|
end)
|
|
65
|
-
expect(output_buffer).to have_tag('label abbr', '*')
|
|
66
|
+
expect(output_buffer.to_str).to have_tag('label abbr', '*')
|
|
66
67
|
end
|
|
67
68
|
end
|
|
68
69
|
|
|
@@ -73,7 +74,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
73
74
|
concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => :to_s, :member_label => proc {|f| ('Label_%s' % [f])}))
|
|
74
75
|
end)
|
|
75
76
|
end
|
|
76
|
-
expect(output_buffer).to have_tag('form li fieldset ol li label', :text => /Label_[abc]/, :count => 3)
|
|
77
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label', :text => /Label_[abc]/, :count => 3)
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
it 'should use a supplied value_method for simple collections' do
|
|
@@ -82,9 +83,9 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
82
83
|
concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => proc {|f| ('Value_%s' % [f.to_s])}))
|
|
83
84
|
end)
|
|
84
85
|
end
|
|
85
|
-
expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_a"]')
|
|
86
|
-
expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_b"]')
|
|
87
|
-
expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_c"]')
|
|
86
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_a"]')
|
|
87
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_b"]')
|
|
88
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_c"]')
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
|
|
@@ -93,38 +94,38 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
93
94
|
concat(semantic_form_for(@new_post) do |builder|
|
|
94
95
|
builder.input(:title, :label => 'My label')
|
|
95
96
|
end)
|
|
96
|
-
expect(output_buffer).to have_tag('label', :text => /My label/)
|
|
97
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /My label/)
|
|
97
98
|
end
|
|
98
|
-
|
|
99
|
+
|
|
99
100
|
it 'should allow the text to be given as label option for date fields' do
|
|
100
101
|
concat(semantic_form_for(@new_post) do |builder|
|
|
101
102
|
builder.input(:publish_at, :label => 'My other label')
|
|
102
103
|
end)
|
|
103
|
-
expect(output_buffer).to have_tag('label', :text => /My other label/)
|
|
104
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /My other label/)
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
it 'should return nil if label is false' do
|
|
107
108
|
concat(semantic_form_for(@new_post) do |builder|
|
|
108
109
|
builder.input(:title, :label => false)
|
|
109
110
|
end)
|
|
110
|
-
expect(output_buffer).not_to have_tag('label')
|
|
111
|
-
expect(output_buffer).not_to include(">")
|
|
111
|
+
expect(output_buffer.to_str).not_to have_tag('label')
|
|
112
|
+
expect(output_buffer.to_str).not_to include(">")
|
|
112
113
|
end
|
|
113
|
-
|
|
114
|
+
|
|
114
115
|
it 'should return nil if label is false for timeish fragments' do
|
|
115
116
|
concat(semantic_form_for(@new_post) do |builder|
|
|
116
117
|
builder.input(:title, :as => :time_select, :label => false)
|
|
117
118
|
end)
|
|
118
|
-
expect(output_buffer).not_to have_tag('li.time > label')
|
|
119
|
-
expect(output_buffer).not_to include(">")
|
|
119
|
+
expect(output_buffer.to_str).not_to have_tag('li.time > label')
|
|
120
|
+
expect(output_buffer.to_str).not_to include(">")
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
it 'should html escape the label string by default' do
|
|
123
124
|
concat(semantic_form_for(@new_post) do |builder|
|
|
124
125
|
builder.input(:title, :label => '<b>My label</b>')
|
|
125
126
|
end)
|
|
126
|
-
expect(output_buffer).to include('<b>')
|
|
127
|
-
expect(output_buffer).not_to include('<b>')
|
|
127
|
+
expect(output_buffer.to_str).to include('<b>')
|
|
128
|
+
expect(output_buffer.to_str).not_to include('<b>')
|
|
128
129
|
end
|
|
129
130
|
|
|
130
131
|
it 'should not html escape the label if configured that way' do
|
|
@@ -132,7 +133,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
132
133
|
concat(semantic_form_for(@new_post) do |builder|
|
|
133
134
|
builder.input(:title, :label => '<b>My label</b>')
|
|
134
135
|
end)
|
|
135
|
-
expect(output_buffer).to have_tag("label b", :text => "My label")
|
|
136
|
+
expect(output_buffer.to_str).to have_tag("label b", :text => "My label")
|
|
136
137
|
end
|
|
137
138
|
|
|
138
139
|
it 'should not html escape the label string for html_safe strings' do
|
|
@@ -140,7 +141,7 @@ RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
|
140
141
|
concat(semantic_form_for(@new_post) do |builder|
|
|
141
142
|
builder.input(:title, :label => '<b>My label</b>'.html_safe)
|
|
142
143
|
end)
|
|
143
|
-
expect(output_buffer).to have_tag('label b')
|
|
144
|
+
expect(output_buffer.to_str).to have_tag('label b')
|
|
144
145
|
end
|
|
145
146
|
|
|
146
147
|
end
|