formtastic 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 'datetime select input' do
|
@@ -6,7 +7,7 @@ RSpec.describe 'datetime select input' 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
|
|
@@ -14,7 +15,7 @@ RSpec.describe 'datetime select input' do
|
|
14
15
|
|
15
16
|
before do
|
16
17
|
::I18n.backend.store_translations :en, {}
|
17
|
-
output_buffer.
|
18
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
18
19
|
concat(semantic_form_for(@new_post) do |builder|
|
19
20
|
concat(builder.input(:publish_at, :as => :datetime_select))
|
20
21
|
end)
|
@@ -27,59 +28,59 @@ RSpec.describe 'datetime select input' do
|
|
27
28
|
it_should_have_a_nested_fieldset_with_class('fragments')
|
28
29
|
it_should_have_a_nested_ordered_list_with_class('fragments-group')
|
29
30
|
it_should_apply_error_logic_for_input_type(:datetime_select)
|
30
|
-
|
31
|
+
|
31
32
|
it 'should have a legend and label with the label text inside the fieldset' do
|
32
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label', :text => /Publish at/)
|
33
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label label', :text => /Publish at/)
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
it 'should associate the legend label with the first select' do
|
36
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label')
|
37
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label')
|
38
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for]')
|
39
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_1i"]')
|
37
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label')
|
38
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label label')
|
39
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label label[@for]')
|
40
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_1i"]')
|
40
41
|
end
|
41
|
-
|
42
|
+
|
42
43
|
it 'should have an ordered list of five items inside the fieldset' do
|
43
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol.fragments-group')
|
44
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li.fragment', :count => 5)
|
44
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol.fragments-group')
|
45
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li.fragment', :count => 5)
|
45
46
|
end
|
46
47
|
|
47
48
|
it 'should have five labels for year, month and day' do
|
48
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => 5)
|
49
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /year/i)
|
50
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /month/i)
|
51
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /day/i)
|
52
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /hour/i)
|
53
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /min/i)
|
54
|
-
end
|
55
|
-
|
49
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :count => 5)
|
50
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /year/i)
|
51
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /month/i)
|
52
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /day/i)
|
53
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /hour/i)
|
54
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /min/i)
|
55
|
+
end
|
56
|
+
|
56
57
|
it 'should have five selects' do
|
57
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li select', :count => 5)
|
58
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li select', :count => 5)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
describe "when namespace is provided" do
|
62
|
-
|
63
|
+
|
63
64
|
before do
|
64
|
-
output_buffer.
|
65
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
65
66
|
concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
|
66
67
|
concat(builder.input(:publish_at, :as => :datetime_select))
|
67
68
|
end)
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
|
71
72
|
it_should_have_select_with_id("context2_post_publish_at_1i")
|
72
73
|
it_should_have_select_with_id("context2_post_publish_at_2i")
|
73
74
|
it_should_have_select_with_id("context2_post_publish_at_3i")
|
74
75
|
it_should_have_select_with_id("context2_post_publish_at_4i")
|
75
76
|
it_should_have_select_with_id("context2_post_publish_at_5i")
|
76
|
-
|
77
|
+
|
77
78
|
end
|
78
|
-
|
79
|
+
|
79
80
|
describe "when index is provided" do
|
80
81
|
|
81
82
|
before do
|
82
|
-
@output_buffer = ''
|
83
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
83
84
|
mock_everything
|
84
85
|
|
85
86
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -88,81 +89,81 @@ RSpec.describe 'datetime select input' do
|
|
88
89
|
end)
|
89
90
|
end)
|
90
91
|
end
|
91
|
-
|
92
|
+
|
92
93
|
it 'should index the id of the wrapper' do
|
93
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
|
94
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_created_at_input")
|
94
95
|
end
|
95
|
-
|
96
|
+
|
96
97
|
it 'should index the id of the select tag' do
|
97
|
-
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_1i")
|
98
|
-
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_2i")
|
99
|
-
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_3i")
|
100
|
-
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_4i")
|
101
|
-
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_5i")
|
98
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_1i")
|
99
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_2i")
|
100
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_3i")
|
101
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_4i")
|
102
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_5i")
|
102
103
|
end
|
103
|
-
|
104
|
+
|
104
105
|
it 'should index the name of the select tag' do
|
105
|
-
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
|
106
|
-
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
|
107
|
-
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
|
108
|
-
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
|
109
|
-
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
|
106
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
|
107
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
|
108
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
|
109
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
|
110
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
|
110
111
|
end
|
111
|
-
|
112
|
+
|
112
113
|
end
|
113
|
-
|
114
|
-
|
114
|
+
|
115
|
+
|
115
116
|
describe ':labels option' do
|
116
117
|
fields = [:year, :month, :day, :hour, :minute]
|
117
118
|
fields.each do |field|
|
118
119
|
it "should replace the #{field} label with the specified text if :labels[:#{field}] is set" do
|
119
|
-
output_buffer.
|
120
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
120
121
|
concat(semantic_form_for(@new_post) do |builder|
|
121
122
|
concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => "another #{field} label" }))
|
122
123
|
end)
|
123
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length)
|
124
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length)
|
124
125
|
fields.each do |f|
|
125
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
|
126
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
|
126
127
|
end
|
127
128
|
end
|
128
|
-
|
129
|
+
|
129
130
|
it "should not display the label for the #{field} field when :labels[:#{field}] is blank" do
|
130
|
-
output_buffer.
|
131
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
131
132
|
concat(semantic_form_for(@new_post) do |builder|
|
132
133
|
concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => "" }))
|
133
134
|
end)
|
134
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
|
135
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
|
135
136
|
fields.each do |f|
|
136
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
137
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
137
138
|
end
|
138
139
|
end
|
139
|
-
|
140
|
+
|
140
141
|
it "should not display the label for the #{field} field when :labels[:#{field}] is false" do
|
141
|
-
output_buffer.
|
142
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
142
143
|
concat(semantic_form_for(@new_post) do |builder|
|
143
144
|
concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => false }))
|
144
145
|
end)
|
145
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
|
146
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
|
146
147
|
fields.each do |f|
|
147
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
148
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
148
149
|
end
|
149
150
|
end
|
150
|
-
|
151
|
-
it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
152
|
-
output_buffer.
|
151
|
+
|
152
|
+
it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
153
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
153
154
|
concat(semantic_form_for(@new_post) do |builder|
|
154
155
|
concat(builder.input(:created_at, :as => :datetime_select, :include_seconds => true, :labels => { field => false }))
|
155
156
|
end)
|
156
|
-
expect(output_buffer).not_to include(">")
|
157
|
+
expect(output_buffer.to_str).not_to include(">")
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
160
161
|
it "should not display labels for any fields when :labels is falsy" do
|
161
|
-
output_buffer.
|
162
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
162
163
|
concat(semantic_form_for(@new_post) do |builder|
|
163
164
|
concat(builder.input(:created_at, :as => :datetime_select, :labels => false))
|
164
165
|
end)
|
165
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => 0)
|
166
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset ol li label', :count => 0)
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
@@ -174,36 +175,36 @@ RSpec.describe 'datetime select input' do
|
|
174
175
|
end
|
175
176
|
)
|
176
177
|
|
177
|
-
expect(output_buffer).to have_tag "option[value='2018'][selected='selected']"
|
178
|
-
expect(output_buffer).to have_tag "option[value='10'][selected='selected']"
|
179
|
-
expect(output_buffer).to have_tag "option[value='4'][selected='selected']"
|
180
|
-
expect(output_buffer).to have_tag "option[value='12'][selected='selected']"
|
181
|
-
expect(output_buffer).to have_tag "option[value='00'][selected='selected']"
|
178
|
+
expect(output_buffer.to_str).to have_tag "option[value='2018'][selected='selected']"
|
179
|
+
expect(output_buffer.to_str).to have_tag "option[value='10'][selected='selected']"
|
180
|
+
expect(output_buffer.to_str).to have_tag "option[value='4'][selected='selected']"
|
181
|
+
expect(output_buffer.to_str).to have_tag "option[value='12'][selected='selected']"
|
182
|
+
expect(output_buffer.to_str).to have_tag "option[value='00'][selected='selected']"
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
185
186
|
describe "when required" do
|
186
187
|
it "should add the required attribute to the input's html options" do
|
187
|
-
with_config :use_required_attribute, true do
|
188
|
+
with_config :use_required_attribute, true do
|
188
189
|
concat(semantic_form_for(@new_post) do |builder|
|
189
190
|
concat(builder.input(:title, :as => :datetime_select, :required => true))
|
190
191
|
end)
|
191
|
-
expect(output_buffer).to have_tag("select[@required]", :count => 5)
|
192
|
+
expect(output_buffer.to_str).to have_tag("select[@required]", :count => 5)
|
192
193
|
end
|
193
194
|
end
|
194
195
|
end
|
195
196
|
|
196
197
|
describe "when order does not have year first" do
|
197
198
|
before do
|
198
|
-
output_buffer.
|
199
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
199
200
|
concat(semantic_form_for(@new_post) do |builder|
|
200
201
|
concat(builder.input(:publish_at, :as => :datetime_select, :order => [:day, :month, :year]))
|
201
202
|
end)
|
202
203
|
end
|
203
204
|
|
204
205
|
it 'should associate the legend label with the new first select' do
|
205
|
-
expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_3i"]')
|
206
|
+
expect(output_buffer.to_str).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_3i"]')
|
206
207
|
end
|
207
208
|
end
|
208
|
-
|
209
|
+
|
209
210
|
end
|
@@ -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 'email input' do
|
@@ -6,7 +7,7 @@ RSpec.describe 'email input' 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
|
|
@@ -41,11 +42,11 @@ RSpec.describe 'email input' do
|
|
41
42
|
it_should_have_label_and_input_with_id("context2_post_email")
|
42
43
|
|
43
44
|
end
|
44
|
-
|
45
|
+
|
45
46
|
describe "when index is provided" do
|
46
47
|
|
47
48
|
before do
|
48
|
-
@output_buffer = ''
|
49
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
49
50
|
mock_everything
|
50
51
|
|
51
52
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -54,32 +55,32 @@ RSpec.describe 'email input' do
|
|
54
55
|
end)
|
55
56
|
end)
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
it 'should index the id of the wrapper' do
|
59
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
60
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
it 'should index the id of the select tag' do
|
63
|
-
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
64
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
64
65
|
end
|
65
|
-
|
66
|
+
|
66
67
|
it 'should index the name of the select tag' do
|
67
|
-
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
68
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
end
|
71
|
-
|
72
|
-
|
72
|
+
|
73
|
+
|
73
74
|
describe "when required" do
|
74
75
|
it "should add the required attribute to the input's html options" do
|
75
|
-
with_config :use_required_attribute, true do
|
76
|
+
with_config :use_required_attribute, true do
|
76
77
|
concat(semantic_form_for(@new_post) do |builder|
|
77
78
|
concat(builder.input(:title, :as => :email, :required => true))
|
78
79
|
end)
|
79
|
-
expect(output_buffer).to have_tag("input[@required]")
|
80
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
end
|
85
86
|
|
@@ -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 'file input' do
|
@@ -6,7 +7,7 @@ RSpec.describe 'file input' 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
|
|
12
13
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -27,13 +28,13 @@ RSpec.describe 'file input' do
|
|
27
28
|
concat(semantic_form_for(@new_post) do |builder|
|
28
29
|
concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
|
29
30
|
end)
|
30
|
-
expect(output_buffer).to have_tag("form li input.myclass")
|
31
|
+
expect(output_buffer.to_str).to have_tag("form li input.myclass")
|
31
32
|
end
|
32
33
|
|
33
34
|
describe "when namespace is provided" do
|
34
35
|
|
35
36
|
before do
|
36
|
-
@output_buffer = ''
|
37
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
37
38
|
mock_everything
|
38
39
|
|
39
40
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
@@ -45,11 +46,11 @@ RSpec.describe 'file input' do
|
|
45
46
|
it_should_have_label_and_input_with_id("context2_post_body")
|
46
47
|
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
describe "when index is provided" do
|
50
51
|
|
51
52
|
before do
|
52
|
-
@output_buffer = ''
|
53
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
53
54
|
mock_everything
|
54
55
|
|
55
56
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -58,32 +59,32 @@ RSpec.describe 'file input' do
|
|
58
59
|
end)
|
59
60
|
end)
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
it 'should index the id of the wrapper' do
|
63
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
64
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
64
65
|
end
|
65
|
-
|
66
|
+
|
66
67
|
it 'should index the id of the select tag' do
|
67
|
-
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
68
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
it 'should index the name of the select tag' do
|
71
|
-
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
72
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
72
73
|
end
|
73
|
-
|
74
|
+
|
74
75
|
end
|
75
|
-
|
76
|
-
|
76
|
+
|
77
|
+
|
77
78
|
context "when required" do
|
78
79
|
it "should add the required attribute to the input's html options" do
|
79
80
|
with_config :use_required_attribute, true do
|
80
81
|
concat(semantic_form_for(@new_post) do |builder|
|
81
82
|
concat(builder.input(:title, :as => :file, :required => true))
|
82
83
|
end)
|
83
|
-
expect(output_buffer).to have_tag("input[@required]")
|
84
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
87
|
-
|
88
|
+
|
88
89
|
end
|
89
90
|
|
@@ -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 'hidden input' do
|
@@ -6,9 +7,9 @@ RSpec.describe 'hidden input' 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
|
+
|
12
13
|
concat(semantic_form_for(@new_post) do |builder|
|
13
14
|
concat(builder.input(:secret, :as => :hidden))
|
14
15
|
concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
|
@@ -22,21 +23,21 @@ RSpec.describe 'hidden input' do
|
|
22
23
|
it_should_not_have_a_label
|
23
24
|
|
24
25
|
it "should generate a input field" do
|
25
|
-
expect(output_buffer).to have_tag("form li input#post_secret")
|
26
|
-
expect(output_buffer).to have_tag("form li input#post_secret[@type=\"hidden\"]")
|
27
|
-
expect(output_buffer).to have_tag("form li input#post_secret[@name=\"post[secret]\"]")
|
26
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret")
|
27
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@type=\"hidden\"]")
|
28
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@name=\"post[secret]\"]")
|
28
29
|
end
|
29
30
|
|
30
31
|
it "should get value from the object" do
|
31
|
-
expect(output_buffer).to have_tag("form li input#post_secret[@type=\"hidden\"][@value=\"1\"]")
|
32
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@type=\"hidden\"][@value=\"1\"]")
|
32
33
|
end
|
33
|
-
|
34
|
+
|
34
35
|
it "should pass any explicitly specified value - using :input_html options" do
|
35
|
-
expect(output_buffer).to have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
|
36
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should pass any option specified using :input_html" do
|
39
|
-
expect(output_buffer).to have_tag("form li input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
|
40
|
+
expect(output_buffer.to_str).to have_tag("form li input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
|
40
41
|
end
|
41
42
|
|
42
43
|
it "should not render inline errors" do
|
@@ -48,8 +49,8 @@ RSpec.describe 'hidden input' do
|
|
48
49
|
concat(builder.input(:secret, :as => :hidden))
|
49
50
|
end)
|
50
51
|
|
51
|
-
expect(output_buffer).not_to have_tag("form li p.inline-errors")
|
52
|
-
expect(output_buffer).not_to have_tag("form li ul.errors")
|
52
|
+
expect(output_buffer.to_str).not_to have_tag("form li p.inline-errors")
|
53
|
+
expect(output_buffer.to_str).not_to have_tag("form li ul.errors")
|
53
54
|
end
|
54
55
|
|
55
56
|
it "should not render inline hints" do
|
@@ -57,16 +58,16 @@ RSpec.describe 'hidden input' do
|
|
57
58
|
concat(builder.input(:secret, :as => :hidden, :hint => "all your base are belong to use"))
|
58
59
|
end)
|
59
60
|
|
60
|
-
expect(output_buffer).not_to have_tag("form li p.inline-hints")
|
61
|
-
expect(output_buffer).not_to have_tag("form li ul.hints")
|
61
|
+
expect(output_buffer.to_str).not_to have_tag("form li p.inline-hints")
|
62
|
+
expect(output_buffer.to_str).not_to have_tag("form li ul.hints")
|
62
63
|
end
|
63
64
|
|
64
65
|
describe "when namespace is provided" do
|
65
66
|
|
66
67
|
before do
|
67
|
-
@output_buffer = ''
|
68
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
68
69
|
mock_everything
|
69
|
-
|
70
|
+
|
70
71
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
71
72
|
concat(builder.input(:secret, :as => :hidden))
|
72
73
|
concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
|
@@ -84,11 +85,11 @@ RSpec.describe 'hidden input' do
|
|
84
85
|
end
|
85
86
|
|
86
87
|
end
|
87
|
-
|
88
|
+
|
88
89
|
describe "when index is provided" do
|
89
90
|
|
90
91
|
before do
|
91
|
-
@output_buffer = ''
|
92
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
92
93
|
mock_everything
|
93
94
|
|
94
95
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -97,28 +98,28 @@ RSpec.describe 'hidden input' do
|
|
97
98
|
end)
|
98
99
|
end)
|
99
100
|
end
|
100
|
-
|
101
|
+
|
101
102
|
it 'should index the id of the wrapper' do
|
102
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
103
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
103
104
|
end
|
104
|
-
|
105
|
+
|
105
106
|
it 'should index the id of the select tag' do
|
106
|
-
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
107
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
107
108
|
end
|
108
|
-
|
109
|
+
|
109
110
|
it 'should index the name of the select tag' do
|
110
|
-
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
111
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
111
112
|
end
|
112
|
-
|
113
|
+
|
113
114
|
end
|
114
|
-
|
115
|
-
|
115
|
+
|
116
|
+
|
116
117
|
context "when required" do
|
117
118
|
it "should not add the required attribute to the input's html options" do
|
118
119
|
concat(semantic_form_for(@new_post) do |builder|
|
119
120
|
concat(builder.input(:title, :as => :hidden, :required => true))
|
120
121
|
end)
|
121
|
-
expect(output_buffer).not_to have_tag("input[@required]")
|
122
|
+
expect(output_buffer.to_str).not_to have_tag("input[@required]")
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
@@ -127,7 +128,7 @@ RSpec.describe 'hidden input' do
|
|
127
128
|
concat(semantic_form_for(@new_post) do |builder|
|
128
129
|
concat(builder.input(:title, :as => :hidden, :input_html => {:autofocus => true}))
|
129
130
|
end)
|
130
|
-
expect(output_buffer).not_to have_tag("input[@autofocus]")
|
131
|
+
expect(output_buffer.to_str).not_to have_tag("input[@autofocus]")
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
@@ -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 "*select: options[:include_blank]" do
|
@@ -6,7 +7,7 @@ RSpec.describe "*select: options[:include_blank]" 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
|
|
12
13
|
allow(@new_post).to receive(:author_id).and_return(nil)
|
@@ -29,7 +30,7 @@ RSpec.describe "*select: options[:include_blank]" do
|
|
29
30
|
concat(semantic_form_for(@new_post) do |builder|
|
30
31
|
concat(builder.input(attribute, :as => as))
|
31
32
|
end)
|
32
|
-
expect(output_buffer).to have_tag("form li select option[@value='']", "")
|
33
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "")
|
33
34
|
end
|
34
35
|
|
35
36
|
it 'blank value should not be included if the default value specified in config is false' do
|
@@ -37,7 +38,7 @@ RSpec.describe "*select: options[:include_blank]" do
|
|
37
38
|
concat(semantic_form_for(@new_post) do |builder|
|
38
39
|
concat(builder.input(attribute, :as => as))
|
39
40
|
end)
|
40
|
-
expect(output_buffer).not_to have_tag("form li select option[@value='']", "")
|
41
|
+
expect(output_buffer.to_str).not_to have_tag("form li select option[@value='']", "")
|
41
42
|
end
|
42
43
|
|
43
44
|
after do
|
@@ -50,7 +51,7 @@ RSpec.describe "*select: options[:include_blank]" do
|
|
50
51
|
concat(semantic_form_for(@new_post) do |builder|
|
51
52
|
concat(builder.input(attribute, :as => as, :include_blank => false))
|
52
53
|
end)
|
53
|
-
expect(output_buffer).not_to have_tag("form li select option[@value='']", "")
|
54
|
+
expect(output_buffer.to_str).not_to have_tag("form li select option[@value='']", "")
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
@@ -59,7 +60,7 @@ RSpec.describe "*select: options[:include_blank]" do
|
|
59
60
|
concat(semantic_form_for(@new_post) do |builder|
|
60
61
|
concat(builder.input(attribute, :as => as, :include_blank => true))
|
61
62
|
end)
|
62
|
-
expect(output_buffer).to have_tag("form li select option[@value='']", "")
|
63
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "")
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
@@ -69,7 +70,7 @@ RSpec.describe "*select: options[:include_blank]" do
|
|
69
70
|
concat(semantic_form_for(@new_post) do |builder|
|
70
71
|
concat(builder.input(attribute, :as => as, :include_blank => 'string'))
|
71
72
|
end)
|
72
|
-
expect(output_buffer).to have_tag("form li select option[@value='']", "string")
|
73
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "string")
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|