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 'datetime_picker input' do
|
|
@@ -6,21 +7,21 @@ RSpec.describe 'datetime_picker 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
|
+
|
|
13
14
|
after do
|
|
14
15
|
::I18n.backend.reload!
|
|
15
16
|
end
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
context "with an object" do
|
|
18
19
|
before do
|
|
19
20
|
concat(semantic_form_for(@new_post) do |builder|
|
|
20
21
|
concat(builder.input(:publish_at, :as => :datetime_picker))
|
|
21
22
|
end)
|
|
22
23
|
end
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
it_should_have_input_wrapper_with_class(:datetime_picker)
|
|
25
26
|
it_should_have_input_wrapper_with_class(:input)
|
|
26
27
|
it_should_have_input_wrapper_with_class(:stringish)
|
|
@@ -33,27 +34,27 @@ RSpec.describe 'datetime_picker input' do
|
|
|
33
34
|
it_should_apply_custom_input_attributes_when_input_html_provided(:datetime_picker)
|
|
34
35
|
it_should_apply_custom_for_to_label_when_input_html_id_provided(:datetime_picker)
|
|
35
36
|
# TODO why does this blow-up it_should_apply_error_logic_for_input_type(:datetime_picker)
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
end
|
|
38
|
-
|
|
39
|
+
|
|
39
40
|
describe ":local option for UTC or local time" do
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
it "should default to a datetime-local input (true)" do
|
|
42
43
|
concat(
|
|
43
44
|
semantic_form_for(@new_post) do |f|
|
|
44
45
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
45
46
|
end
|
|
46
47
|
)
|
|
47
|
-
expect(output_buffer).to have_tag "input[type='datetime-local']"
|
|
48
|
+
expect(output_buffer.to_str).to have_tag "input[type='datetime-local']"
|
|
48
49
|
end
|
|
49
|
-
|
|
50
|
+
|
|
50
51
|
it "can be set to true for a datetime-local" do
|
|
51
52
|
concat(
|
|
52
53
|
semantic_form_for(@new_post) do |f|
|
|
53
54
|
concat(f.input(:publish_at, :as => :datetime_picker, :local => true))
|
|
54
55
|
end
|
|
55
56
|
)
|
|
56
|
-
expect(output_buffer).to have_tag "input[type='datetime-local']"
|
|
57
|
+
expect(output_buffer.to_str).to have_tag "input[type='datetime-local']"
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
it "can be set to false for a datetime" do
|
|
@@ -62,38 +63,38 @@ RSpec.describe 'datetime_picker input' do
|
|
|
62
63
|
concat(f.input(:publish_at, :as => :datetime_picker, :local => false))
|
|
63
64
|
end
|
|
64
65
|
)
|
|
65
|
-
expect(output_buffer).to have_tag "input[type='datetime']"
|
|
66
|
+
expect(output_buffer.to_str).to have_tag "input[type='datetime']"
|
|
66
67
|
end
|
|
67
|
-
|
|
68
|
+
|
|
68
69
|
end
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
describe "size attribute" do
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
it "defaults to 10 chars (YYYY-YY-YY HH:MM)" do
|
|
73
74
|
concat(
|
|
74
75
|
semantic_form_for(@new_post) do |f|
|
|
75
76
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
76
77
|
end
|
|
77
78
|
)
|
|
78
|
-
expect(output_buffer).to have_tag "input[size='16']"
|
|
79
|
+
expect(output_buffer.to_str).to have_tag "input[size='16']"
|
|
79
80
|
end
|
|
80
|
-
|
|
81
|
+
|
|
81
82
|
it "can be set from :input_html options" do
|
|
82
83
|
concat(
|
|
83
84
|
semantic_form_for(@new_post) do |f|
|
|
84
85
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :size => "11" }))
|
|
85
86
|
end
|
|
86
87
|
)
|
|
87
|
-
expect(output_buffer).to have_tag "input[size='11']"
|
|
88
|
+
expect(output_buffer.to_str).to have_tag "input[size='11']"
|
|
88
89
|
end
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
it "can be set from options (ignoring input_html)" do
|
|
91
92
|
concat(
|
|
92
93
|
semantic_form_for(@new_post) do |f|
|
|
93
94
|
concat(f.input(:publish_at, :as => :datetime_picker, :size => '12', :input_html => { :size => "11" }))
|
|
94
95
|
end
|
|
95
96
|
)
|
|
96
|
-
expect(output_buffer).to have_tag "input[size='12']"
|
|
97
|
+
expect(output_buffer.to_str).to have_tag "input[size='12']"
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
end
|
|
@@ -106,7 +107,7 @@ RSpec.describe 'datetime_picker input' do
|
|
|
106
107
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
107
108
|
end
|
|
108
109
|
)
|
|
109
|
-
expect(output_buffer).to have_tag "input[maxlength='16']"
|
|
110
|
+
expect(output_buffer.to_str).to have_tag "input[maxlength='16']"
|
|
110
111
|
end
|
|
111
112
|
|
|
112
113
|
it "can be set from :input_html options" do
|
|
@@ -115,58 +116,58 @@ RSpec.describe 'datetime_picker input' do
|
|
|
115
116
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :maxlength => "11" }))
|
|
116
117
|
end
|
|
117
118
|
)
|
|
118
|
-
expect(output_buffer).to have_tag "input[maxlength='11']"
|
|
119
|
+
expect(output_buffer.to_str).to have_tag "input[maxlength='11']"
|
|
119
120
|
end
|
|
120
|
-
|
|
121
|
+
|
|
121
122
|
it "can be set from options (ignoring input_html)" do
|
|
122
123
|
concat(
|
|
123
124
|
semantic_form_for(@new_post) do |f|
|
|
124
125
|
concat(f.input(:publish_at, :as => :datetime_picker, :maxlength => 12, :input_html => { :maxlength => "11" }))
|
|
125
126
|
end
|
|
126
127
|
)
|
|
127
|
-
expect(output_buffer).to have_tag "input[maxlength='12']"
|
|
128
|
+
expect(output_buffer.to_str).to have_tag "input[maxlength='12']"
|
|
128
129
|
end
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
end
|
|
131
|
-
|
|
132
|
+
|
|
132
133
|
describe "value attribute" do
|
|
133
|
-
|
|
134
|
+
|
|
134
135
|
context "when method returns nil" do
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
it "has no value" do
|
|
137
138
|
concat(
|
|
138
139
|
semantic_form_for(@new_post) do |f|
|
|
139
140
|
concat(f.input(:publish_at, :as => :datetime_picker ))
|
|
140
141
|
end
|
|
141
142
|
)
|
|
142
|
-
expect(output_buffer).not_to have_tag "li input[value]"
|
|
143
|
+
expect(output_buffer.to_str).not_to have_tag "li input[value]"
|
|
143
144
|
end
|
|
144
|
-
|
|
145
|
+
|
|
145
146
|
it "can be set from :input_html options" do
|
|
146
147
|
concat(
|
|
147
148
|
semantic_form_for(@new_post) do |f|
|
|
148
149
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T23:00:00" }))
|
|
149
150
|
end
|
|
150
151
|
)
|
|
151
|
-
expect(output_buffer).to have_tag "input[value='1111-11-11T23:00:00']"
|
|
152
|
+
expect(output_buffer.to_str).to have_tag "input[value='1111-11-11T23:00:00']"
|
|
152
153
|
end
|
|
153
|
-
|
|
154
|
+
|
|
154
155
|
end
|
|
155
|
-
|
|
156
|
+
|
|
156
157
|
context "when method returns a Date" do
|
|
157
|
-
|
|
158
|
+
|
|
158
159
|
before do
|
|
159
160
|
@date = Date.new(2000, 11, 11)
|
|
160
161
|
allow(@new_post).to receive(:publish_at).and_return(@date)
|
|
161
162
|
end
|
|
162
|
-
|
|
163
|
+
|
|
163
164
|
it "renders the date as YYYY-MM-DDT00:00:00" do
|
|
164
165
|
concat(
|
|
165
166
|
semantic_form_for(@new_post) do |f|
|
|
166
167
|
concat(f.input(:publish_at, :as => :datetime_picker ))
|
|
167
168
|
end
|
|
168
169
|
)
|
|
169
|
-
expect(output_buffer).to have_tag "input[value='2000-11-11T00:00:00']"
|
|
170
|
+
expect(output_buffer.to_str).to have_tag "input[value='2000-11-11T00:00:00']"
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
it "can be set from :input_html options" do
|
|
@@ -175,114 +176,114 @@ RSpec.describe 'datetime_picker input' do
|
|
|
175
176
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T00:00:00" }))
|
|
176
177
|
end
|
|
177
178
|
)
|
|
178
|
-
expect(output_buffer).to have_tag "input[value='1111-11-11T00:00:00']"
|
|
179
|
+
expect(output_buffer.to_str).to have_tag "input[value='1111-11-11T00:00:00']"
|
|
179
180
|
end
|
|
180
|
-
|
|
181
|
+
|
|
181
182
|
end
|
|
182
|
-
|
|
183
|
+
|
|
183
184
|
context "when method returns a Time" do
|
|
184
|
-
|
|
185
|
+
|
|
185
186
|
before do
|
|
186
187
|
@time = Time.utc(2000,11,11,11,11,11)
|
|
187
188
|
allow(@new_post).to receive(:publish_at).and_return(@time)
|
|
188
189
|
end
|
|
189
|
-
|
|
190
|
+
|
|
190
191
|
it "renders the time as a YYYY-MM-DD HH:MM" do
|
|
191
192
|
concat(
|
|
192
193
|
semantic_form_for(@new_post) do |f|
|
|
193
194
|
concat(f.input(:publish_at, :as => :datetime_picker ))
|
|
194
195
|
end
|
|
195
196
|
)
|
|
196
|
-
expect(output_buffer).to have_tag "input[value='2000-11-11T11:11:11']"
|
|
197
|
+
expect(output_buffer.to_str).to have_tag "input[value='2000-11-11T11:11:11']"
|
|
197
198
|
end
|
|
198
|
-
|
|
199
|
+
|
|
199
200
|
it "can be set from :input_html options" do
|
|
200
201
|
concat(
|
|
201
202
|
semantic_form_for(@new_post) do |f|
|
|
202
203
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
|
|
203
204
|
end
|
|
204
205
|
)
|
|
205
|
-
expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
206
|
+
expect(output_buffer.to_str).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
206
207
|
end
|
|
207
|
-
|
|
208
|
+
|
|
208
209
|
end
|
|
209
|
-
|
|
210
|
+
|
|
210
211
|
context "when method returns an empty String" do
|
|
211
|
-
|
|
212
|
+
|
|
212
213
|
before do
|
|
213
214
|
allow(@new_post).to receive(:publish_at).and_return("")
|
|
214
215
|
end
|
|
215
|
-
|
|
216
|
+
|
|
216
217
|
it "will be empty" do
|
|
217
218
|
concat(
|
|
218
219
|
semantic_form_for(@new_post) do |f|
|
|
219
220
|
concat(f.input(:publish_at, :as => :datetime_picker ))
|
|
220
221
|
end
|
|
221
222
|
)
|
|
222
|
-
expect(output_buffer).to have_tag "input[value='']"
|
|
223
|
+
expect(output_buffer.to_str).to have_tag "input[value='']"
|
|
223
224
|
end
|
|
224
|
-
|
|
225
|
+
|
|
225
226
|
it "can be set from :input_html options" do
|
|
226
227
|
concat(
|
|
227
228
|
semantic_form_for(@new_post) do |f|
|
|
228
229
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
|
|
229
230
|
end
|
|
230
231
|
)
|
|
231
|
-
expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
232
|
+
expect(output_buffer.to_str).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
232
233
|
end
|
|
233
|
-
|
|
234
|
+
|
|
234
235
|
end
|
|
235
|
-
|
|
236
|
+
|
|
236
237
|
context "when method returns a String" do
|
|
237
|
-
|
|
238
|
+
|
|
238
239
|
before do
|
|
239
240
|
allow(@new_post).to receive(:publish_at).and_return("yeah")
|
|
240
241
|
end
|
|
241
|
-
|
|
242
|
+
|
|
242
243
|
it "will be the string" do
|
|
243
244
|
concat(
|
|
244
245
|
semantic_form_for(@new_post) do |f|
|
|
245
246
|
concat(f.input(:publish_at, :as => :datetime_picker ))
|
|
246
247
|
end
|
|
247
248
|
)
|
|
248
|
-
expect(output_buffer).to have_tag "input[value='yeah']"
|
|
249
|
+
expect(output_buffer.to_str).to have_tag "input[value='yeah']"
|
|
249
250
|
end
|
|
250
|
-
|
|
251
|
+
|
|
251
252
|
it "can be set from :input_html options" do
|
|
252
253
|
concat(
|
|
253
254
|
semantic_form_for(@new_post) do |f|
|
|
254
255
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
|
|
255
256
|
end
|
|
256
257
|
)
|
|
257
|
-
expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
258
|
+
expect(output_buffer.to_str).to have_tag "input[value='1111-11-11T11:11:11']"
|
|
258
259
|
end
|
|
259
|
-
|
|
260
|
+
|
|
260
261
|
end
|
|
261
262
|
|
|
262
263
|
end
|
|
263
|
-
|
|
264
|
+
|
|
264
265
|
describe "min attribute" do
|
|
265
|
-
|
|
266
|
+
|
|
266
267
|
it "will be omitted by default" do
|
|
267
268
|
concat(
|
|
268
269
|
semantic_form_for(@new_post) do |f|
|
|
269
270
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
270
271
|
end
|
|
271
272
|
)
|
|
272
|
-
expect(output_buffer).not_to have_tag "input[min]"
|
|
273
|
+
expect(output_buffer.to_str).not_to have_tag "input[min]"
|
|
273
274
|
end
|
|
274
|
-
|
|
275
|
+
|
|
275
276
|
it "can be set from :input_html options" do
|
|
276
277
|
concat(
|
|
277
278
|
semantic_form_for(@new_post) do |f|
|
|
278
279
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :min => "1970-01-01 12:00" }))
|
|
279
280
|
end
|
|
280
281
|
)
|
|
281
|
-
expect(output_buffer).to have_tag "input[min='1970-01-01 12:00']"
|
|
282
|
+
expect(output_buffer.to_str).to have_tag "input[min='1970-01-01 12:00']"
|
|
282
283
|
end
|
|
283
|
-
|
|
284
|
+
|
|
284
285
|
end
|
|
285
|
-
|
|
286
|
+
|
|
286
287
|
describe "max attribute" do
|
|
287
288
|
|
|
288
289
|
it "will be omitted by default" do
|
|
@@ -291,29 +292,29 @@ RSpec.describe 'datetime_picker input' do
|
|
|
291
292
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
292
293
|
end
|
|
293
294
|
)
|
|
294
|
-
expect(output_buffer).not_to have_tag "input[max]"
|
|
295
|
+
expect(output_buffer.to_str).not_to have_tag "input[max]"
|
|
295
296
|
end
|
|
296
|
-
|
|
297
|
+
|
|
297
298
|
it "can be set from :input_html options" do
|
|
298
299
|
concat(
|
|
299
300
|
semantic_form_for(@new_post) do |f|
|
|
300
301
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :max => "1970-01-01 12:00" }))
|
|
301
302
|
end
|
|
302
303
|
)
|
|
303
|
-
expect(output_buffer).to have_tag "input[max='1970-01-01 12:00']"
|
|
304
|
+
expect(output_buffer.to_str).to have_tag "input[max='1970-01-01 12:00']"
|
|
304
305
|
end
|
|
305
|
-
|
|
306
|
+
|
|
306
307
|
end
|
|
307
|
-
|
|
308
|
+
|
|
308
309
|
describe "step attribute" do
|
|
309
|
-
|
|
310
|
+
|
|
310
311
|
it "defaults to 1" do
|
|
311
312
|
concat(
|
|
312
313
|
semantic_form_for(@new_post) do |f|
|
|
313
314
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
314
315
|
end
|
|
315
316
|
)
|
|
316
|
-
expect(output_buffer).to have_tag "input[step='1']"
|
|
317
|
+
expect(output_buffer.to_str).to have_tag "input[step='1']"
|
|
317
318
|
end
|
|
318
319
|
|
|
319
320
|
it "can be set from :input_html options" do
|
|
@@ -322,124 +323,124 @@ RSpec.describe 'datetime_picker input' do
|
|
|
322
323
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :step => "5" }))
|
|
323
324
|
end
|
|
324
325
|
)
|
|
325
|
-
expect(output_buffer).to have_tag "input[step='5']"
|
|
326
|
+
expect(output_buffer.to_str).to have_tag "input[step='5']"
|
|
326
327
|
end
|
|
327
|
-
|
|
328
|
+
|
|
328
329
|
describe "macros" do
|
|
329
|
-
before do
|
|
330
|
+
before do
|
|
330
331
|
concat(
|
|
331
332
|
semantic_form_for(@new_post) do |f|
|
|
332
333
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :step => step }))
|
|
333
334
|
end
|
|
334
335
|
)
|
|
335
336
|
end
|
|
336
|
-
|
|
337
|
+
|
|
337
338
|
context ":second" do
|
|
338
339
|
let(:step) { :second }
|
|
339
340
|
it "uses 1" do
|
|
340
|
-
expect(output_buffer).to have_tag "input[step='1']"
|
|
341
|
+
expect(output_buffer.to_str).to have_tag "input[step='1']"
|
|
341
342
|
end
|
|
342
343
|
end
|
|
343
|
-
|
|
344
|
+
|
|
344
345
|
context ":minute" do
|
|
345
346
|
let(:step) { :minute }
|
|
346
347
|
it "uses 60" do
|
|
347
|
-
expect(output_buffer).to have_tag "input[step='60']"
|
|
348
|
+
expect(output_buffer.to_str).to have_tag "input[step='60']"
|
|
348
349
|
end
|
|
349
350
|
end
|
|
350
|
-
|
|
351
|
+
|
|
351
352
|
context ":fifteen_minutes" do
|
|
352
353
|
let(:step) { :fifteen_minutes }
|
|
353
354
|
it "uses 900" do
|
|
354
|
-
expect(output_buffer).to have_tag "input[step='900']"
|
|
355
|
+
expect(output_buffer.to_str).to have_tag "input[step='900']"
|
|
355
356
|
end
|
|
356
357
|
end
|
|
357
|
-
|
|
358
|
+
|
|
358
359
|
context ":quarter_hour" do
|
|
359
360
|
let(:step) { :quarter_hour }
|
|
360
361
|
it "uses 900" do
|
|
361
|
-
expect(output_buffer).to have_tag "input[step='900']"
|
|
362
|
+
expect(output_buffer.to_str).to have_tag "input[step='900']"
|
|
362
363
|
end
|
|
363
364
|
end
|
|
364
|
-
|
|
365
|
+
|
|
365
366
|
context ":thirty_minutes" do
|
|
366
367
|
let(:step) { :thirty_minutes }
|
|
367
368
|
it "uses 1800" do
|
|
368
|
-
expect(output_buffer).to have_tag "input[step='1800']"
|
|
369
|
+
expect(output_buffer.to_str).to have_tag "input[step='1800']"
|
|
369
370
|
end
|
|
370
371
|
end
|
|
371
|
-
|
|
372
|
+
|
|
372
373
|
context ":half_hour" do
|
|
373
374
|
let(:step) { :half_hour }
|
|
374
375
|
it "uses 1800" do
|
|
375
|
-
expect(output_buffer).to have_tag "input[step='1800']"
|
|
376
|
+
expect(output_buffer.to_str).to have_tag "input[step='1800']"
|
|
376
377
|
end
|
|
377
378
|
end
|
|
378
|
-
|
|
379
|
+
|
|
379
380
|
context ":hour" do
|
|
380
381
|
let(:step) { :hour }
|
|
381
382
|
it "uses 3600" do
|
|
382
|
-
expect(output_buffer).to have_tag "input[step='3600']"
|
|
383
|
+
expect(output_buffer.to_str).to have_tag "input[step='3600']"
|
|
383
384
|
end
|
|
384
385
|
end
|
|
385
|
-
|
|
386
|
+
|
|
386
387
|
context ":sixty_minutes" do
|
|
387
388
|
let(:step) { :sixty_minutes }
|
|
388
389
|
it "uses 3600" do
|
|
389
|
-
expect(output_buffer).to have_tag "input[step='3600']"
|
|
390
|
+
expect(output_buffer.to_str).to have_tag "input[step='3600']"
|
|
390
391
|
end
|
|
391
392
|
end
|
|
392
|
-
|
|
393
|
+
|
|
393
394
|
end
|
|
394
|
-
|
|
395
|
+
|
|
395
396
|
end
|
|
396
|
-
|
|
397
|
+
|
|
397
398
|
describe "placeholder attribute" do
|
|
398
|
-
|
|
399
|
+
|
|
399
400
|
it "will be omitted" do
|
|
400
401
|
concat(
|
|
401
402
|
semantic_form_for(@new_post) do |f|
|
|
402
403
|
concat(f.input(:publish_at, :as => :datetime_picker))
|
|
403
404
|
end
|
|
404
405
|
)
|
|
405
|
-
expect(output_buffer).not_to have_tag "input[placeholder]"
|
|
406
|
+
expect(output_buffer.to_str).not_to have_tag "input[placeholder]"
|
|
406
407
|
end
|
|
407
|
-
|
|
408
|
+
|
|
408
409
|
it "can be set from :input_html options" do
|
|
409
410
|
concat(
|
|
410
411
|
semantic_form_for(@new_post) do |f|
|
|
411
412
|
concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :placeholder => "1970-01-01 00:00" }))
|
|
412
413
|
end
|
|
413
414
|
)
|
|
414
|
-
expect(output_buffer).to have_tag "input[placeholder='1970-01-01 00:00']"
|
|
415
|
+
expect(output_buffer.to_str).to have_tag "input[placeholder='1970-01-01 00:00']"
|
|
415
416
|
end
|
|
416
|
-
|
|
417
|
+
|
|
417
418
|
context "with i18n set" do
|
|
418
419
|
before do
|
|
419
420
|
::I18n.backend.store_translations :en, :formtastic => { :placeholders => { :publish_at => 'YYYY-MM-DD HH:MM' }}
|
|
420
421
|
end
|
|
421
|
-
|
|
422
|
+
|
|
422
423
|
it "can be set with i18n" do
|
|
423
424
|
with_config :i18n_lookups_by_default, true do
|
|
424
425
|
concat(semantic_form_for(@new_post) do |builder|
|
|
425
426
|
concat(builder.input(:publish_at, :as => :datetime_picker))
|
|
426
427
|
end)
|
|
427
|
-
expect(output_buffer).to have_tag('input[@placeholder="YYYY-MM-DD HH:MM"]')
|
|
428
|
+
expect(output_buffer.to_str).to have_tag('input[@placeholder="YYYY-MM-DD HH:MM"]')
|
|
428
429
|
end
|
|
429
430
|
end
|
|
430
|
-
|
|
431
|
+
|
|
431
432
|
it "can be set with input_html, trumping i18n" do
|
|
432
433
|
with_config :i18n_lookups_by_default, true do
|
|
433
434
|
concat(semantic_form_for(@new_post) do |builder|
|
|
434
435
|
concat(builder.input(:publish_at, :as => :datetime_picker, :input_html => { :placeholder => "Something" }))
|
|
435
436
|
end)
|
|
436
|
-
expect(output_buffer).to have_tag('input[@placeholder="Something"]')
|
|
437
|
+
expect(output_buffer.to_str).to have_tag('input[@placeholder="Something"]')
|
|
437
438
|
end
|
|
438
439
|
end
|
|
439
440
|
end
|
|
440
|
-
|
|
441
|
+
|
|
441
442
|
end
|
|
442
|
-
|
|
443
|
+
|
|
443
444
|
describe "when namespace is provided" do
|
|
444
445
|
before do
|
|
445
446
|
concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
|
|
@@ -450,10 +451,10 @@ RSpec.describe 'datetime_picker input' do
|
|
|
450
451
|
it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
|
|
451
452
|
it_should_have_label_and_input_with_id("context2_post_publish_at")
|
|
452
453
|
end
|
|
453
|
-
|
|
454
|
+
|
|
454
455
|
describe "when index is provided" do
|
|
455
456
|
before do
|
|
456
|
-
@output_buffer = ''
|
|
457
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
457
458
|
mock_everything
|
|
458
459
|
|
|
459
460
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -462,29 +463,29 @@ RSpec.describe 'datetime_picker input' do
|
|
|
462
463
|
end)
|
|
463
464
|
end)
|
|
464
465
|
end
|
|
465
|
-
|
|
466
|
+
|
|
466
467
|
it 'should index the id of the wrapper' do
|
|
467
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
|
|
468
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_created_at_input")
|
|
468
469
|
end
|
|
469
|
-
|
|
470
|
+
|
|
470
471
|
it 'should index the id of the select tag' do
|
|
471
|
-
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
|
|
472
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_created_at")
|
|
472
473
|
end
|
|
473
|
-
|
|
474
|
+
|
|
474
475
|
it 'should index the name of the select tag' do
|
|
475
|
-
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
|
|
476
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][created_at]']")
|
|
476
477
|
end
|
|
477
478
|
end
|
|
478
|
-
|
|
479
|
+
|
|
479
480
|
describe "when required" do
|
|
480
481
|
it "should add the required attribute to the input's html options" do
|
|
481
|
-
with_config :use_required_attribute, true do
|
|
482
|
+
with_config :use_required_attribute, true do
|
|
482
483
|
concat(semantic_form_for(@new_post) do |builder|
|
|
483
484
|
concat(builder.input(:publish_at, :as => :datetime_picker, :required => true))
|
|
484
485
|
end)
|
|
485
|
-
expect(output_buffer).to have_tag("input[@required]")
|
|
486
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
|
486
487
|
end
|
|
487
488
|
end
|
|
488
489
|
end
|
|
489
|
-
|
|
490
|
+
|
|
490
491
|
end
|