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
|
@@ -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 'FormHelper' do
|
|
@@ -6,7 +7,7 @@ RSpec.describe 'FormHelper' 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
|
|
|
@@ -21,14 +22,14 @@ RSpec.describe 'FormHelper' do
|
|
|
21
22
|
it 'adds a class of "formtastic" to the generated form' do
|
|
22
23
|
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
23
24
|
end)
|
|
24
|
-
expect(output_buffer).to have_tag("form.formtastic")
|
|
25
|
+
expect(output_buffer.to_str).to have_tag("form.formtastic")
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it 'does not add "novalidate" attribute to the generated form when configured to do so' do
|
|
28
29
|
with_config :perform_browser_validations, true do
|
|
29
30
|
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
30
31
|
end)
|
|
31
|
-
expect(output_buffer).not_to have_tag("form[@novalidate]")
|
|
32
|
+
expect(output_buffer.to_str).not_to have_tag("form[@novalidate]")
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -36,7 +37,7 @@ RSpec.describe 'FormHelper' do
|
|
|
36
37
|
with_config :perform_browser_validations, false do
|
|
37
38
|
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
38
39
|
end)
|
|
39
|
-
expect(output_buffer).to have_tag("form[@novalidate]")
|
|
40
|
+
expect(output_buffer.to_str).to have_tag("form[@novalidate]")
|
|
40
41
|
end
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -44,7 +45,7 @@ RSpec.describe 'FormHelper' do
|
|
|
44
45
|
with_config :perform_browser_validations, false do
|
|
45
46
|
concat(semantic_form_for(@new_post, :url => '/hello', :html => { :novalidate => true }) do |builder|
|
|
46
47
|
end)
|
|
47
|
-
expect(output_buffer).to have_tag("form[@novalidate]")
|
|
48
|
+
expect(output_buffer.to_str).to have_tag("form[@novalidate]")
|
|
48
49
|
end
|
|
49
50
|
end
|
|
50
51
|
|
|
@@ -52,7 +53,7 @@ RSpec.describe 'FormHelper' do
|
|
|
52
53
|
with_config :perform_browser_validations, true do
|
|
53
54
|
concat(semantic_form_for(@new_post, :url => '/hello', :html => { :novalidate => false }) do |builder|
|
|
54
55
|
end)
|
|
55
|
-
expect(output_buffer).not_to have_tag("form[@novalidate]")
|
|
56
|
+
expect(output_buffer.to_str).not_to have_tag("form[@novalidate]")
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
|
|
@@ -60,57 +61,57 @@ RSpec.describe 'FormHelper' do
|
|
|
60
61
|
Formtastic::Helpers::FormHelper.default_form_class = 'xyz'
|
|
61
62
|
concat(semantic_form_for(::Post.new, :as => :post, :url => '/hello') do |builder|
|
|
62
63
|
end)
|
|
63
|
-
expect(output_buffer).to have_tag("form.xyz")
|
|
64
|
+
expect(output_buffer.to_str).to have_tag("form.xyz")
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
it 'omits the leading spaces from the classes in the generated form when the default class is nil' do
|
|
67
68
|
Formtastic::Helpers::FormHelper.default_form_class = nil
|
|
68
69
|
concat(semantic_form_for(::Post.new, :as => :post, :url => '/hello') do |builder|
|
|
69
70
|
end)
|
|
70
|
-
expect(output_buffer).to have_tag("form[class='post']")
|
|
71
|
+
expect(output_buffer.to_str).to have_tag("form[class='post']")
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
it 'adds class matching the object name to the generated form when a symbol is provided' do
|
|
74
75
|
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
75
76
|
end)
|
|
76
|
-
expect(output_buffer).to have_tag("form.post")
|
|
77
|
+
expect(output_buffer.to_str).to have_tag("form.post")
|
|
77
78
|
|
|
78
79
|
concat(semantic_form_for(:project, :url => '/hello') do |builder|
|
|
79
80
|
end)
|
|
80
|
-
expect(output_buffer).to have_tag("form.project")
|
|
81
|
+
expect(output_buffer.to_str).to have_tag("form.project")
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
it 'adds class matching the :as option when provided' do
|
|
84
85
|
concat(semantic_form_for(@new_post, :as => :message, :url => '/hello') do |builder|
|
|
85
86
|
end)
|
|
86
|
-
expect(output_buffer).to have_tag("form.message")
|
|
87
|
+
expect(output_buffer.to_str).to have_tag("form.message")
|
|
87
88
|
|
|
88
89
|
concat(semantic_form_for([:admins, @new_post], :as => :message, :url => '/hello') do |builder|
|
|
89
90
|
end)
|
|
90
|
-
expect(output_buffer).to have_tag("form.message")
|
|
91
|
+
expect(output_buffer.to_str).to have_tag("form.message")
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
it 'adds class matching the object\'s class to the generated form when an object is provided' do
|
|
94
95
|
concat(semantic_form_for(@new_post) do |builder|
|
|
95
96
|
end)
|
|
96
|
-
expect(output_buffer).to have_tag("form.post")
|
|
97
|
+
expect(output_buffer.to_str).to have_tag("form.post")
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
it 'adds a namespaced class to the generated form' do
|
|
100
101
|
concat(semantic_form_for(::Namespaced::Post.new, :url => '/hello') do |builder|
|
|
101
102
|
end)
|
|
102
|
-
expect(output_buffer).to have_tag("form.namespaced_post")
|
|
103
|
+
expect(output_buffer.to_str).to have_tag("form.namespaced_post")
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
it 'adds a customized class to the generated form' do
|
|
106
107
|
Formtastic::Helpers::FormHelper.default_form_model_class_proc = lambda { |model_class_name| "#{model_class_name}_form" }
|
|
107
108
|
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
108
109
|
end)
|
|
109
|
-
expect(output_buffer).to have_tag("form.post_form")
|
|
110
|
+
expect(output_buffer.to_str).to have_tag("form.post_form")
|
|
110
111
|
|
|
111
112
|
concat(semantic_form_for(:project, :url => '/hello') do |builder|
|
|
112
113
|
end)
|
|
113
|
-
expect(output_buffer).to have_tag("form.project_form")
|
|
114
|
+
expect(output_buffer.to_str).to have_tag("form.project_form")
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
describe 'allows :html options' do
|
|
@@ -120,15 +121,15 @@ RSpec.describe 'FormHelper' do
|
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
it 'to add a id of "something-special" to generated form' do
|
|
123
|
-
expect(output_buffer).to have_tag("form#something-special")
|
|
124
|
+
expect(output_buffer.to_str).to have_tag("form#something-special")
|
|
124
125
|
end
|
|
125
126
|
|
|
126
127
|
it 'to add a class of "something-extra" to generated form' do
|
|
127
|
-
expect(output_buffer).to have_tag("form.something-extra")
|
|
128
|
+
expect(output_buffer.to_str).to have_tag("form.something-extra")
|
|
128
129
|
end
|
|
129
130
|
|
|
130
131
|
it 'to add enctype="multipart/form-data"' do
|
|
131
|
-
expect(output_buffer).to have_tag('form[@enctype="multipart/form-data"]')
|
|
132
|
+
expect(output_buffer.to_str).to have_tag('form[@enctype="multipart/form-data"]')
|
|
132
133
|
end
|
|
133
134
|
end
|
|
134
135
|
|
|
@@ -154,6 +155,12 @@ RSpec.describe 'FormHelper' do
|
|
|
154
155
|
end
|
|
155
156
|
|
|
156
157
|
describe 'ActionView::Base.field_error_proc' do
|
|
158
|
+
around do |ex|
|
|
159
|
+
error_proc = Formtastic::Helpers::FormHelper.formtastic_field_error_proc
|
|
160
|
+
ex.run
|
|
161
|
+
Formtastic::Helpers::FormHelper.formtastic_field_error_proc = error_proc
|
|
162
|
+
end
|
|
163
|
+
|
|
157
164
|
it 'is set to no-op wrapper by default' do
|
|
158
165
|
semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
159
166
|
expect(::ActionView::Base.field_error_proc.call("html", nil)).to eq("html")
|
|
@@ -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 'with input class finder' do
|
|
@@ -29,8 +30,8 @@ RSpec.describe 'with input class finder' do
|
|
|
29
30
|
concat(semantic_form_for(@new_post) do |builder|
|
|
30
31
|
concat(builder.input(:title, :required => true))
|
|
31
32
|
end)
|
|
32
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
33
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
33
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
34
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
|
|
@@ -39,7 +40,7 @@ RSpec.describe 'with input class finder' do
|
|
|
39
40
|
concat(semantic_form_for(@new_post) do |builder|
|
|
40
41
|
concat(builder.input(:title, :required => true))
|
|
41
42
|
end)
|
|
42
|
-
expect(output_buffer).to have_tag('form li.required label', :text => /required yo/)
|
|
43
|
+
expect(output_buffer.to_str).to have_tag('form li.required label', :text => /required yo/)
|
|
43
44
|
end
|
|
44
45
|
end
|
|
45
46
|
end
|
|
@@ -59,8 +60,8 @@ RSpec.describe 'with input class finder' do
|
|
|
59
60
|
concat(semantic_form_for(@new_post) do |builder|
|
|
60
61
|
concat(builder.input(:title, :required => false))
|
|
61
62
|
end)
|
|
62
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
63
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
63
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
64
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
it 'should set and "optional" class also when there is presence validator' do
|
|
@@ -70,15 +71,15 @@ RSpec.describe 'with input class finder' do
|
|
|
70
71
|
concat(semantic_form_for(@new_post) do |builder|
|
|
71
72
|
concat(builder.input(:title, :required => false))
|
|
72
73
|
end)
|
|
73
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
74
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
74
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
75
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
it 'should append the "optional" string to the label' do
|
|
78
79
|
concat(semantic_form_for(@new_post) do |builder|
|
|
79
80
|
concat(builder.input(:title, :required => false))
|
|
80
81
|
end)
|
|
81
|
-
expect(output_buffer).to have_tag('form li.optional label', :text => /#{@string}$/)
|
|
82
|
+
expect(output_buffer.to_str).to have_tag('form li.optional label', :text => /#{@string}$/)
|
|
82
83
|
end
|
|
83
84
|
|
|
84
85
|
end
|
|
@@ -94,8 +95,8 @@ RSpec.describe 'with input class finder' do
|
|
|
94
95
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
|
95
96
|
concat(builder.input(:title))
|
|
96
97
|
end)
|
|
97
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
98
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
98
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
99
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
99
100
|
|
|
100
101
|
Formtastic::FormBuilder.all_fields_required_by_default = true
|
|
101
102
|
end
|
|
@@ -125,8 +126,8 @@ RSpec.describe 'with input class finder' do
|
|
|
125
126
|
concat(builder.input(:title))
|
|
126
127
|
concat(builder.input(:body))
|
|
127
128
|
end)
|
|
128
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
129
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
129
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
130
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
130
131
|
end
|
|
131
132
|
|
|
132
133
|
it 'should be required when there is :on => :create option on create' do
|
|
@@ -137,8 +138,8 @@ RSpec.describe 'with input class finder' do
|
|
|
137
138
|
concat(semantic_form_for(@new_post) do |builder|
|
|
138
139
|
concat(builder.input(:title))
|
|
139
140
|
end)
|
|
140
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
141
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
141
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
142
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
142
143
|
end
|
|
143
144
|
end
|
|
144
145
|
|
|
@@ -150,8 +151,8 @@ RSpec.describe 'with input class finder' do
|
|
|
150
151
|
concat(semantic_form_for(@new_post) do |builder|
|
|
151
152
|
concat(builder.input(:title))
|
|
152
153
|
end)
|
|
153
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
154
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
154
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
155
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
155
156
|
end
|
|
156
157
|
end
|
|
157
158
|
|
|
@@ -163,8 +164,8 @@ RSpec.describe 'with input class finder' do
|
|
|
163
164
|
concat(semantic_form_for(@new_post) do |builder|
|
|
164
165
|
concat(builder.input(:title))
|
|
165
166
|
end)
|
|
166
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
167
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
167
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
168
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
168
169
|
end
|
|
169
170
|
end
|
|
170
171
|
|
|
@@ -176,8 +177,8 @@ RSpec.describe 'with input class finder' do
|
|
|
176
177
|
concat(semantic_form_for(@new_post) do |builder|
|
|
177
178
|
concat(builder.input(:title))
|
|
178
179
|
end)
|
|
179
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
180
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
180
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
181
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
181
182
|
end
|
|
182
183
|
end
|
|
183
184
|
|
|
@@ -189,8 +190,8 @@ RSpec.describe 'with input class finder' do
|
|
|
189
190
|
concat(semantic_form_for(@fred) do |builder|
|
|
190
191
|
concat(builder.input(:login))
|
|
191
192
|
end)
|
|
192
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
193
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
193
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
194
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
194
195
|
end
|
|
195
196
|
end
|
|
196
197
|
|
|
@@ -202,8 +203,8 @@ RSpec.describe 'with input class finder' do
|
|
|
202
203
|
concat(semantic_form_for(@fred) do |builder|
|
|
203
204
|
concat(builder.input(:login))
|
|
204
205
|
end)
|
|
205
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
206
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
206
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
207
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
207
208
|
end
|
|
208
209
|
end
|
|
209
210
|
|
|
@@ -214,8 +215,8 @@ RSpec.describe 'with input class finder' do
|
|
|
214
215
|
concat(semantic_form_for(@fred) do |builder|
|
|
215
216
|
concat(builder.input(:login))
|
|
216
217
|
end)
|
|
217
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
218
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
218
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
219
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
219
220
|
end
|
|
220
221
|
|
|
221
222
|
it 'should not be required when there is :create option in validation contexts array on update' do
|
|
@@ -225,8 +226,8 @@ RSpec.describe 'with input class finder' do
|
|
|
225
226
|
concat(semantic_form_for(@fred) do |builder|
|
|
226
227
|
concat(builder.input(:login))
|
|
227
228
|
end)
|
|
228
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
229
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
229
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
230
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
230
231
|
end
|
|
231
232
|
|
|
232
233
|
it 'should not be required when there is :on => :update option on create' do
|
|
@@ -236,8 +237,8 @@ RSpec.describe 'with input class finder' do
|
|
|
236
237
|
concat(semantic_form_for(@new_post) do |builder|
|
|
237
238
|
concat(builder.input(:title))
|
|
238
239
|
end)
|
|
239
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
240
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
240
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
241
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
241
242
|
end
|
|
242
243
|
|
|
243
244
|
it 'should not be required when there is :update option in validation contexts array on create' do
|
|
@@ -247,8 +248,8 @@ RSpec.describe 'with input class finder' do
|
|
|
247
248
|
concat(semantic_form_for(@new_post) do |builder|
|
|
248
249
|
concat(builder.input(:title))
|
|
249
250
|
end)
|
|
250
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
251
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
251
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
252
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
252
253
|
end
|
|
253
254
|
|
|
254
255
|
it 'should be not be required if the optional :if condition is not satisifed' do
|
|
@@ -353,11 +354,11 @@ RSpec.describe 'with input class finder' do
|
|
|
353
354
|
end)
|
|
354
355
|
|
|
355
356
|
if options[:required]
|
|
356
|
-
expect(output_buffer).not_to have_tag('form li.optional')
|
|
357
|
-
expect(output_buffer).to have_tag('form li.required')
|
|
357
|
+
expect(output_buffer.to_str).not_to have_tag('form li.optional')
|
|
358
|
+
expect(output_buffer.to_str).to have_tag('form li.required')
|
|
358
359
|
else
|
|
359
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
360
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
360
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
361
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
361
362
|
end
|
|
362
363
|
end
|
|
363
364
|
|
|
@@ -381,8 +382,8 @@ RSpec.describe 'with input class finder' do
|
|
|
381
382
|
concat(semantic_form_for(@new_post) do |builder|
|
|
382
383
|
concat(builder.input(:title))
|
|
383
384
|
end)
|
|
384
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
385
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
385
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
386
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
386
387
|
end
|
|
387
388
|
end
|
|
388
389
|
|
|
@@ -397,8 +398,8 @@ RSpec.describe 'with input class finder' do
|
|
|
397
398
|
concat(semantic_form_for(@new_post) do |builder|
|
|
398
399
|
concat(builder.input(:title))
|
|
399
400
|
end)
|
|
400
|
-
expect(output_buffer).not_to have_tag('form li.required')
|
|
401
|
-
expect(output_buffer).to have_tag('form li.optional')
|
|
401
|
+
expect(output_buffer.to_str).not_to have_tag('form li.required')
|
|
402
|
+
expect(output_buffer.to_str).to have_tag('form li.optional')
|
|
402
403
|
|
|
403
404
|
Formtastic::FormBuilder.all_fields_required_by_default = true
|
|
404
405
|
end
|
|
@@ -417,7 +418,7 @@ RSpec.describe 'with input class finder' do
|
|
|
417
418
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
|
418
419
|
concat(builder.input(:anything))
|
|
419
420
|
end)
|
|
420
|
-
expect(output_buffer).to have_tag('form li.string')
|
|
421
|
+
expect(output_buffer.to_str).to have_tag('form li.string')
|
|
421
422
|
end
|
|
422
423
|
|
|
423
424
|
it 'should default to password for forms without objects if column is password' do
|
|
@@ -426,7 +427,7 @@ RSpec.describe 'with input class finder' do
|
|
|
426
427
|
concat(builder.input(:password_confirmation))
|
|
427
428
|
concat(builder.input(:confirm_password))
|
|
428
429
|
end)
|
|
429
|
-
expect(output_buffer).to have_tag('form li.password', :count => 3)
|
|
430
|
+
expect(output_buffer.to_str).to have_tag('form li.password', :count => 3)
|
|
430
431
|
end
|
|
431
432
|
|
|
432
433
|
it 'should default to a string for methods on objects that don\'t respond to "column_for_attribute"' do
|
|
@@ -598,21 +599,21 @@ RSpec.describe 'with input class finder' do
|
|
|
598
599
|
concat(semantic_form_for(@new_post) do |builder|
|
|
599
600
|
concat(builder.input(:title, :label => "Kustom"))
|
|
600
601
|
end)
|
|
601
|
-
expect(output_buffer).to have_tag("form li label", :text => /Kustom/)
|
|
602
|
+
expect(output_buffer.to_str).to have_tag("form li label", :text => /Kustom/)
|
|
602
603
|
end
|
|
603
604
|
|
|
604
605
|
it 'should not generate a label if false' do
|
|
605
606
|
concat(semantic_form_for(@new_post) do |builder|
|
|
606
607
|
concat(builder.input(:title, :label => false))
|
|
607
608
|
end)
|
|
608
|
-
expect(output_buffer).not_to have_tag("form li label")
|
|
609
|
+
expect(output_buffer.to_str).not_to have_tag("form li label")
|
|
609
610
|
end
|
|
610
611
|
|
|
611
612
|
it 'should be dupped if frozen' do
|
|
612
613
|
concat(semantic_form_for(@new_post) do |builder|
|
|
613
614
|
concat(builder.input(:title, :label => "Kustom".freeze))
|
|
614
615
|
end)
|
|
615
|
-
expect(output_buffer).to have_tag("form li label", :text => /Kustom/)
|
|
616
|
+
expect(output_buffer.to_str).to have_tag("form li label", :text => /Kustom/)
|
|
616
617
|
end
|
|
617
618
|
end
|
|
618
619
|
|
|
@@ -634,7 +635,7 @@ RSpec.describe 'with input class finder' do
|
|
|
634
635
|
concat(semantic_form_for(@new_post) do |builder|
|
|
635
636
|
concat(builder.input(:meta_description))
|
|
636
637
|
end)
|
|
637
|
-
expect(output_buffer).to have_tag('form li label', :text => /Localized title/)
|
|
638
|
+
expect(output_buffer.to_str).to have_tag('form li label', :text => /Localized title/)
|
|
638
639
|
end
|
|
639
640
|
end
|
|
640
641
|
end
|
|
@@ -649,7 +650,7 @@ RSpec.describe 'with input class finder' do
|
|
|
649
650
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
|
650
651
|
concat(builder.input(:meta_description))
|
|
651
652
|
end)
|
|
652
|
-
expect(output_buffer).to have_tag("form li label", :text => /#{'meta_description'.humanize}/)
|
|
653
|
+
expect(output_buffer.to_str).to have_tag("form li label", :text => /#{'meta_description'.humanize}/)
|
|
653
654
|
end
|
|
654
655
|
end
|
|
655
656
|
end
|
|
@@ -662,7 +663,7 @@ RSpec.describe 'with input class finder' do
|
|
|
662
663
|
concat(semantic_form_for(@new_post) do |builder|
|
|
663
664
|
concat(builder.input(:meta_description))
|
|
664
665
|
end)
|
|
665
|
-
expect(output_buffer).to have_tag("form li label", :text => /#{'meta_description'.humanize}/)
|
|
666
|
+
expect(output_buffer.to_str).to have_tag("form li label", :text => /#{'meta_description'.humanize}/)
|
|
666
667
|
end
|
|
667
668
|
end
|
|
668
669
|
|
|
@@ -674,7 +675,7 @@ RSpec.describe 'with input class finder' do
|
|
|
674
675
|
concat(semantic_form_for(@new_post) do |builder|
|
|
675
676
|
concat(builder.input(:meta_description))
|
|
676
677
|
end)
|
|
677
|
-
expect(output_buffer).to have_tag("form li label", :text => /#{'meta_description'.capitalize}/)
|
|
678
|
+
expect(output_buffer.to_str).to have_tag("form li label", :text => /#{'meta_description'.capitalize}/)
|
|
678
679
|
end
|
|
679
680
|
end
|
|
680
681
|
end
|
|
@@ -703,7 +704,7 @@ RSpec.describe 'with input class finder' do
|
|
|
703
704
|
concat(builder.input(:title, :label => true))
|
|
704
705
|
concat(builder.input(:published, :as => :boolean, :label => true))
|
|
705
706
|
end)
|
|
706
|
-
expect(output_buffer).to have_tag('form li label', :text => Regexp.new('^' + @localized_label_text))
|
|
707
|
+
expect(output_buffer.to_str).to have_tag('form li label', :text => Regexp.new('^' + @localized_label_text))
|
|
707
708
|
end
|
|
708
709
|
end
|
|
709
710
|
|
|
@@ -722,7 +723,7 @@ RSpec.describe 'with input class finder' do
|
|
|
722
723
|
concat(builder.input(:title, :label => true))
|
|
723
724
|
concat(builder.input(:published, :as => :boolean, :label => true))
|
|
724
725
|
end)
|
|
725
|
-
expect(output_buffer).to have_tag('form li label', :text => Regexp.new('^' + @default_localized_label_text))
|
|
726
|
+
expect(output_buffer.to_str).to have_tag('form li label', :text => Regexp.new('^' + @default_localized_label_text))
|
|
726
727
|
end
|
|
727
728
|
end
|
|
728
729
|
end
|
|
@@ -743,7 +744,7 @@ RSpec.describe 'with input class finder' do
|
|
|
743
744
|
concat(semantic_form_for(@new_post) do |builder|
|
|
744
745
|
concat(builder.input(:title, :hint => hint_text))
|
|
745
746
|
end)
|
|
746
|
-
expect(output_buffer).to have_tag("form li p.inline-hints", :text => hint_text)
|
|
747
|
+
expect(output_buffer.to_str).to have_tag("form li p.inline-hints", :text => hint_text)
|
|
747
748
|
end
|
|
748
749
|
|
|
749
750
|
it 'should have a custom hint class defaulted for all forms' do
|
|
@@ -752,7 +753,7 @@ RSpec.describe 'with input class finder' do
|
|
|
752
753
|
concat(semantic_form_for(@new_post) do |builder|
|
|
753
754
|
concat(builder.input(:title, :hint => hint_text))
|
|
754
755
|
end)
|
|
755
|
-
expect(output_buffer).to have_tag("form li p.custom-hint-class", :text => hint_text)
|
|
756
|
+
expect(output_buffer.to_str).to have_tag("form li p.custom-hint-class", :text => hint_text)
|
|
756
757
|
end
|
|
757
758
|
end
|
|
758
759
|
|
|
@@ -787,7 +788,7 @@ RSpec.describe 'with input class finder' do
|
|
|
787
788
|
concat(semantic_form_for(@new_post) do |builder|
|
|
788
789
|
concat(builder.input(:title, :hint => true))
|
|
789
790
|
end)
|
|
790
|
-
expect(output_buffer).to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
791
|
+
expect(output_buffer.to_str).to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
791
792
|
end
|
|
792
793
|
end
|
|
793
794
|
|
|
@@ -796,7 +797,7 @@ RSpec.describe 'with input class finder' do
|
|
|
796
797
|
concat(semantic_form_for(@new_post) do |builder|
|
|
797
798
|
concat(builder.input(:title, :hint => true))
|
|
798
799
|
end)
|
|
799
|
-
expect(output_buffer).to have_tag('form li p.inline-hints', :text => @default_localized_hint_text)
|
|
800
|
+
expect(output_buffer.to_str).to have_tag('form li p.inline-hints', :text => @default_localized_hint_text)
|
|
800
801
|
end
|
|
801
802
|
end
|
|
802
803
|
end
|
|
@@ -807,7 +808,7 @@ RSpec.describe 'with input class finder' do
|
|
|
807
808
|
concat(semantic_form_for(@new_post) do |builder|
|
|
808
809
|
concat(builder.input(:title, :hint => false))
|
|
809
810
|
end)
|
|
810
|
-
expect(output_buffer).not_to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
811
|
+
expect(output_buffer.to_str).not_to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
811
812
|
end
|
|
812
813
|
end
|
|
813
814
|
end
|
|
@@ -827,7 +828,7 @@ RSpec.describe 'with input class finder' do
|
|
|
827
828
|
semantic_form_for(@new_post) do |builder|
|
|
828
829
|
concat(builder.input(:title, :hint => true))
|
|
829
830
|
end
|
|
830
|
-
expect(output_buffer).not_to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
831
|
+
expect(output_buffer.to_str).not_to have_tag('form li p.inline-hints', :text => @localized_hint_text)
|
|
831
832
|
end
|
|
832
833
|
end
|
|
833
834
|
end
|
|
@@ -838,7 +839,7 @@ RSpec.describe 'with input class finder' do
|
|
|
838
839
|
concat(semantic_form_for(@new_post) do |builder|
|
|
839
840
|
concat(builder.input(:title))
|
|
840
841
|
end)
|
|
841
|
-
expect(output_buffer).not_to have_tag('form li p.inline-hints')
|
|
842
|
+
expect(output_buffer.to_str).not_to have_tag('form li p.inline-hints')
|
|
842
843
|
end
|
|
843
844
|
end
|
|
844
845
|
end
|
|
@@ -853,25 +854,25 @@ RSpec.describe 'with input class finder' do
|
|
|
853
854
|
concat(semantic_form_for(@new_post) do |builder|
|
|
854
855
|
concat(builder.input(:title, :wrapper_html => {:id => :another_id}))
|
|
855
856
|
end)
|
|
856
|
-
expect(output_buffer).to have_tag("form li#another_id")
|
|
857
|
+
expect(output_buffer.to_str).to have_tag("form li#another_id")
|
|
857
858
|
end
|
|
858
859
|
|
|
859
860
|
it 'should append given classes to li default classes' do
|
|
860
861
|
concat(semantic_form_for(@new_post) do |builder|
|
|
861
862
|
concat(builder.input(:title, :wrapper_html => {:class => :another_class}, :required => true))
|
|
862
863
|
end)
|
|
863
|
-
expect(output_buffer).to have_tag("form li.string")
|
|
864
|
-
expect(output_buffer).to have_tag("form li.required")
|
|
865
|
-
expect(output_buffer).to have_tag("form li.another_class")
|
|
864
|
+
expect(output_buffer.to_str).to have_tag("form li.string")
|
|
865
|
+
expect(output_buffer.to_str).to have_tag("form li.required")
|
|
866
|
+
expect(output_buffer.to_str).to have_tag("form li.another_class")
|
|
866
867
|
end
|
|
867
868
|
|
|
868
869
|
it 'should allow classes to be an array' do
|
|
869
870
|
concat(semantic_form_for(@new_post) do |builder|
|
|
870
871
|
concat(builder.input(:title, :wrapper_html => {:class => [ :my_class, :another_class ]}))
|
|
871
872
|
end)
|
|
872
|
-
expect(output_buffer).to have_tag("form li.string")
|
|
873
|
-
expect(output_buffer).to have_tag("form li.my_class")
|
|
874
|
-
expect(output_buffer).to have_tag("form li.another_class")
|
|
873
|
+
expect(output_buffer.to_str).to have_tag("form li.string")
|
|
874
|
+
expect(output_buffer.to_str).to have_tag("form li.my_class")
|
|
875
|
+
expect(output_buffer.to_str).to have_tag("form li.another_class")
|
|
875
876
|
end
|
|
876
877
|
|
|
877
878
|
describe 'when nil' do
|
|
@@ -879,7 +880,7 @@ RSpec.describe 'with input class finder' do
|
|
|
879
880
|
concat(semantic_form_for(@new_post) do |builder|
|
|
880
881
|
concat(builder.input(:title, :wrapper_html => {:id => nil}))
|
|
881
882
|
end)
|
|
882
|
-
expect(output_buffer).to have_tag('form li:not([id])')
|
|
883
|
+
expect(output_buffer.to_str).to have_tag('form li:not([id])')
|
|
883
884
|
end
|
|
884
885
|
end
|
|
885
886
|
end
|
|
@@ -889,8 +890,8 @@ RSpec.describe 'with input class finder' do
|
|
|
889
890
|
concat(semantic_form_for(@new_post) do |builder|
|
|
890
891
|
concat(builder.input(:title))
|
|
891
892
|
end)
|
|
892
|
-
expect(output_buffer).to have_tag("form li#post_title_input")
|
|
893
|
-
expect(output_buffer).to have_tag("form li.string")
|
|
893
|
+
expect(output_buffer.to_str).to have_tag("form li#post_title_input")
|
|
894
|
+
expect(output_buffer.to_str).to have_tag("form li.string")
|
|
894
895
|
end
|
|
895
896
|
end
|
|
896
897
|
|
|
@@ -932,7 +933,7 @@ RSpec.describe 'with input class finder' do
|
|
|
932
933
|
concat(builder.input(:title, my_options))
|
|
933
934
|
concat(builder.input(:publish_at, my_options))
|
|
934
935
|
end)
|
|
935
|
-
expect(output_buffer).to have_tag 'li.string', :count => 2
|
|
936
|
+
expect(output_buffer.to_str).to have_tag 'li.string', :count => 2
|
|
936
937
|
end
|
|
937
938
|
end
|
|
938
939
|
|