formtastic 3.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 +5 -13
- data/.gitattributes +1 -0
- data/.github/workflows/test.yml +61 -0
- data/.gitignore +3 -2
- data/CHANGELOG.md +61 -0
- data/Gemfile.lock +140 -0
- data/MIT-LICENSE +1 -1
- data/{README.textile → README.md} +191 -168
- data/RELEASE_PROCESS +3 -1
- data/Rakefile +24 -8
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +13 -17
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_6.1/Gemfile +5 -0
- data/gemfiles/rails_7.0/Gemfile +5 -0
- data/gemfiles/rails_7.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic/action_class_finder.rb +19 -0
- data/lib/formtastic/actions/base.rb +1 -0
- data/lib/formtastic/actions/button_action.rb +56 -53
- data/lib/formtastic/actions/buttonish.rb +1 -0
- data/lib/formtastic/actions/input_action.rb +60 -57
- data/lib/formtastic/actions/link_action.rb +69 -67
- data/lib/formtastic/actions.rb +7 -3
- data/lib/formtastic/deprecation.rb +6 -0
- data/lib/formtastic/engine.rb +4 -1
- data/lib/formtastic/form_builder.rb +32 -25
- data/lib/formtastic/helpers/action_helper.rb +22 -31
- data/lib/formtastic/helpers/actions_helper.rb +1 -0
- data/lib/formtastic/helpers/enum.rb +14 -0
- data/lib/formtastic/helpers/errors_helper.rb +3 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -11
- data/lib/formtastic/helpers/file_column_detection.rb +1 -0
- data/lib/formtastic/helpers/form_helper.rb +4 -3
- data/lib/formtastic/helpers/input_helper.rb +59 -80
- data/lib/formtastic/helpers/inputs_helper.rb +33 -27
- data/lib/formtastic/helpers/reflection.rb +5 -4
- data/lib/formtastic/helpers.rb +2 -2
- data/lib/formtastic/html_attributes.rb +13 -1
- data/lib/formtastic/i18n.rb +2 -1
- data/lib/formtastic/input_class_finder.rb +19 -0
- data/lib/formtastic/inputs/base/associations.rb +1 -0
- data/lib/formtastic/inputs/base/choices.rb +4 -3
- data/lib/formtastic/inputs/base/collections.rb +47 -11
- data/lib/formtastic/inputs/base/database.rb +8 -5
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
- data/lib/formtastic/inputs/base/errors.rb +7 -6
- data/lib/formtastic/inputs/base/fileish.rb +1 -0
- data/lib/formtastic/inputs/base/hints.rb +2 -1
- data/lib/formtastic/inputs/base/html.rb +12 -10
- data/lib/formtastic/inputs/base/labelling.rb +3 -2
- data/lib/formtastic/inputs/base/naming.rb +5 -4
- data/lib/formtastic/inputs/base/numeric.rb +1 -0
- data/lib/formtastic/inputs/base/options.rb +3 -3
- 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 +9 -4
- data/lib/formtastic/inputs/base/validations.rb +39 -12
- data/lib/formtastic/inputs/base/wrapping.rb +2 -3
- data/lib/formtastic/inputs/base.rb +17 -12
- data/lib/formtastic/inputs/boolean_input.rb +2 -1
- data/lib/formtastic/inputs/check_boxes_input.rb +16 -24
- data/lib/formtastic/inputs/color_input.rb +1 -1
- data/lib/formtastic/inputs/country_input.rb +4 -1
- data/lib/formtastic/inputs/datalist_input.rb +42 -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 +3 -2
- 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 +26 -21
- 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 +32 -10
- 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 +17 -6
- data/lib/formtastic/inputs/url_input.rb +1 -0
- data/lib/formtastic/inputs.rb +33 -28
- data/lib/formtastic/localized_string.rb +2 -1
- data/lib/formtastic/localizer.rb +23 -24
- data/lib/formtastic/namespaced_class_finder.rb +98 -0
- data/lib/formtastic/version.rb +2 -1
- data/lib/formtastic.rb +19 -14
- data/lib/generators/formtastic/form/form_generator.rb +8 -2
- data/lib/generators/formtastic/input/input_generator.rb +47 -0
- data/lib/generators/formtastic/install/install_generator.rb +2 -0
- data/lib/generators/templates/formtastic.rb +29 -7
- data/lib/generators/templates/input.rb +19 -0
- data/sample/basic_inputs.html +1 -1
- data/script/integration-template.rb +73 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +13 -0
- data/spec/actions/button_action_spec.rb +21 -20
- data/spec/actions/generic_action_spec.rb +134 -133
- data/spec/actions/input_action_spec.rb +20 -19
- data/spec/actions/link_action_spec.rb +30 -29
- data/spec/builder/custom_builder_spec.rb +39 -22
- data/spec/builder/error_proc_spec.rb +6 -5
- data/spec/builder/semantic_fields_for_spec.rb +46 -45
- data/spec/fast_spec_helper.rb +13 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +33 -32
- data/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +10 -9
- data/spec/helpers/action_helper_spec.rb +70 -97
- data/spec/helpers/actions_helper_spec.rb +43 -42
- data/spec/helpers/form_helper_spec.rb +56 -39
- data/spec/helpers/input_helper_spec.rb +314 -255
- data/spec/helpers/inputs_helper_spec.rb +217 -202
- data/spec/helpers/reflection_helper_spec.rb +7 -6
- data/spec/helpers/semantic_errors_helper_spec.rb +26 -25
- data/spec/i18n_spec.rb +30 -29
- data/spec/input_class_finder_spec.rb +11 -0
- data/spec/inputs/base/collections_spec.rb +78 -0
- data/spec/inputs/base/validations_spec.rb +481 -0
- data/spec/inputs/boolean_input_spec.rb +73 -72
- data/spec/inputs/check_boxes_input_spec.rb +174 -123
- data/spec/inputs/color_input_spec.rb +53 -64
- data/spec/inputs/country_input_spec.rb +23 -22
- data/spec/inputs/custom_input_spec.rb +3 -6
- data/spec/inputs/datalist_input_spec.rb +62 -0
- data/spec/inputs/date_picker_input_spec.rb +114 -113
- data/spec/inputs/date_select_input_spec.rb +76 -61
- data/spec/inputs/datetime_picker_input_spec.rb +123 -122
- data/spec/inputs/datetime_select_input_spec.rb +85 -68
- data/spec/inputs/email_input_spec.rb +17 -16
- data/spec/inputs/file_input_spec.rb +18 -17
- data/spec/inputs/hidden_input_spec.rb +32 -31
- data/spec/inputs/include_blank_spec.rb +10 -9
- data/spec/inputs/label_spec.rb +36 -31
- data/spec/inputs/number_input_spec.rb +212 -211
- data/spec/inputs/password_input_spec.rb +17 -16
- data/spec/inputs/phone_input_spec.rb +17 -16
- data/spec/inputs/placeholder_spec.rb +18 -17
- data/spec/inputs/radio_input_spec.rb +92 -65
- data/spec/inputs/range_input_spec.rb +136 -135
- data/spec/inputs/readonly_spec.rb +51 -0
- data/spec/inputs/search_input_spec.rb +16 -15
- data/spec/inputs/select_input_spec.rb +209 -102
- data/spec/inputs/string_input_spec.rb +51 -50
- data/spec/inputs/text_input_spec.rb +34 -33
- data/spec/inputs/time_picker_input_spec.rb +115 -114
- data/spec/inputs/time_select_input_spec.rb +84 -70
- data/spec/inputs/time_zone_input_spec.rb +58 -31
- data/spec/inputs/url_input_spec.rb +17 -16
- data/spec/inputs/with_options_spec.rb +9 -8
- data/spec/localizer_spec.rb +18 -17
- data/spec/namespaced_class_finder_spec.rb +91 -0
- data/spec/schema.rb +22 -0
- data/spec/spec_helper.rb +180 -249
- data/spec/support/custom_macros.rb +128 -98
- data/spec/support/deprecation.rb +2 -1
- data/spec/support/shared_examples.rb +13 -0
- data/spec/support/specialized_class_finder_shared_example.rb +28 -0
- data/spec/support/test_environment.rb +25 -10
- metadata +95 -136
- data/.travis.yml +0 -28
- data/Appraisals +0 -25
- data/CHANGELOG +0 -27
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.0.4.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.gemfile +0 -7
- data/gemfiles/rails_edge.gemfile +0 -10
- data/lib/formtastic/util.rb +0 -53
- data/spec/support/deferred_garbage_collection.rb +0 -21
- data/spec/util_spec.rb +0 -52
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'spec_helper'
|
|
3
4
|
|
|
4
|
-
describe 'date select input' do
|
|
5
|
+
RSpec.describe 'date select input' do
|
|
5
6
|
|
|
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
|
describe "general" do
|
|
14
15
|
|
|
15
16
|
before do
|
|
16
|
-
output_buffer.
|
|
17
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
17
18
|
concat(semantic_form_for(@new_post) do |builder|
|
|
18
19
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:year, :month, :day]))
|
|
19
20
|
end)
|
|
@@ -28,37 +29,37 @@ describe 'date select input' do
|
|
|
28
29
|
it_should_apply_error_logic_for_input_type(:date_select)
|
|
29
30
|
|
|
30
31
|
it 'should have a legend and label with the label text inside the fieldset' do
|
|
31
|
-
output_buffer.
|
|
32
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label label', :text => /Publish at/)
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
it 'should associate the legend label with the first select' do
|
|
35
|
-
output_buffer.
|
|
36
|
-
output_buffer.
|
|
37
|
-
output_buffer.
|
|
38
|
-
output_buffer.
|
|
36
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label')
|
|
37
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label label')
|
|
38
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label label[@for]')
|
|
39
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_1i"]')
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
it 'should have an ordered list of three items inside the fieldset' do
|
|
42
|
-
output_buffer.
|
|
43
|
-
output_buffer.
|
|
43
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol.fragments-group')
|
|
44
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li.fragment', :count => 3)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
it 'should have three labels for year, month and day' do
|
|
47
|
-
output_buffer.
|
|
48
|
-
output_buffer.
|
|
49
|
-
output_buffer.
|
|
50
|
-
output_buffer.
|
|
48
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :count => 3)
|
|
49
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :text => /year/i)
|
|
50
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :text => /month/i)
|
|
51
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :text => /day/i)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
it 'should have three selects for year, month and day' do
|
|
54
|
-
output_buffer.
|
|
55
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li select', :count => 3)
|
|
55
56
|
end
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
describe "when namespace is provided" do
|
|
59
60
|
|
|
60
61
|
before do
|
|
61
|
-
output_buffer.
|
|
62
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
62
63
|
concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
|
|
63
64
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:year, :month, :day]))
|
|
64
65
|
end)
|
|
@@ -70,11 +71,11 @@ describe 'date select input' do
|
|
|
70
71
|
it_should_have_select_with_id("context2_post_publish_at_3i")
|
|
71
72
|
|
|
72
73
|
end
|
|
73
|
-
|
|
74
|
+
|
|
74
75
|
describe "when index is provided" do
|
|
75
76
|
|
|
76
77
|
before do
|
|
77
|
-
@output_buffer = ''
|
|
78
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
78
79
|
mock_everything
|
|
79
80
|
|
|
80
81
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -83,152 +84,166 @@ describe 'date select input' do
|
|
|
83
84
|
end)
|
|
84
85
|
end)
|
|
85
86
|
end
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
it 'should index the id of the wrapper' do
|
|
88
|
-
output_buffer.
|
|
89
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_created_at_input")
|
|
89
90
|
end
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
it 'should index the id of the select tag' do
|
|
92
|
-
output_buffer.
|
|
93
|
-
output_buffer.
|
|
94
|
-
output_buffer.
|
|
93
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_1i")
|
|
94
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_2i")
|
|
95
|
+
expect(output_buffer.to_str).to have_tag("select#post_author_attributes_3_created_at_3i")
|
|
95
96
|
end
|
|
96
|
-
|
|
97
|
+
|
|
97
98
|
it 'should index the name of the select tag' do
|
|
98
|
-
output_buffer.
|
|
99
|
-
output_buffer.
|
|
100
|
-
output_buffer.
|
|
99
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
|
|
100
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
|
|
101
|
+
expect(output_buffer.to_str).to have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
|
|
101
102
|
end
|
|
102
|
-
|
|
103
|
+
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
describe ':labels option' do
|
|
106
107
|
fields = [:year, :month, :day]
|
|
107
108
|
fields.each do |field|
|
|
108
109
|
it "should replace the #{field} label with the specified text if :labels[:#{field}] is set" do
|
|
109
|
-
output_buffer.
|
|
110
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
110
111
|
concat(semantic_form_for(@new_post) do |builder|
|
|
111
112
|
concat(builder.input(:created_at, :as => :date_select, :labels => { field => "another #{field} label" }))
|
|
112
113
|
end)
|
|
113
|
-
output_buffer.
|
|
114
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :count => fields.length)
|
|
114
115
|
fields.each do |f|
|
|
115
|
-
output_buffer.
|
|
116
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
|
|
116
117
|
end
|
|
117
118
|
end
|
|
118
119
|
|
|
119
120
|
it "should not display the label for the #{field} field when :labels[:#{field}] is blank" do
|
|
120
|
-
output_buffer.
|
|
121
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
121
122
|
concat(semantic_form_for(@new_post) do |builder|
|
|
122
123
|
concat(builder.input(:created_at, :as => :date_select, :labels => { field => "" }))
|
|
123
124
|
end)
|
|
124
|
-
output_buffer.
|
|
125
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
|
|
125
126
|
fields.each do |f|
|
|
126
|
-
output_buffer.
|
|
127
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
|
127
128
|
end
|
|
128
129
|
end
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
it "should not display the label for the #{field} field when :labels[:#{field}] is false" do
|
|
131
|
-
output_buffer.
|
|
132
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
132
133
|
concat(semantic_form_for(@new_post) do |builder|
|
|
133
134
|
concat(builder.input(:created_at, :as => :date_select, :labels => { field => false }))
|
|
134
135
|
end)
|
|
135
|
-
output_buffer.
|
|
136
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
|
|
136
137
|
fields.each do |f|
|
|
137
|
-
output_buffer.
|
|
138
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', /#{f}/i) unless field == f
|
|
138
139
|
end
|
|
139
140
|
end
|
|
140
|
-
|
|
141
|
-
it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
|
142
|
-
output_buffer.
|
|
141
|
+
|
|
142
|
+
it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
|
143
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
143
144
|
concat(semantic_form_for(@new_post) do |builder|
|
|
144
145
|
concat(builder.input(:created_at, :as => :date_select, :include_seconds => true, :labels => { field => false }))
|
|
145
146
|
end)
|
|
146
|
-
output_buffer.
|
|
147
|
+
expect(output_buffer.to_str).not_to include(">")
|
|
147
148
|
end
|
|
148
|
-
|
|
149
|
+
|
|
149
150
|
end
|
|
150
151
|
|
|
151
152
|
it "should not display labels for any fields when :labels is falsy" do
|
|
152
|
-
output_buffer.
|
|
153
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
153
154
|
concat(semantic_form_for(@new_post) do |builder|
|
|
154
155
|
concat(builder.input(:created_at, :as => :date_select, :labels => false))
|
|
155
156
|
end)
|
|
156
|
-
output_buffer.
|
|
157
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset ol li label', :count => 0)
|
|
157
158
|
end
|
|
158
159
|
end
|
|
159
|
-
|
|
160
|
+
|
|
161
|
+
describe ":selected option for setting a value" do
|
|
162
|
+
it "should set the selected value for the form" do
|
|
163
|
+
concat(
|
|
164
|
+
semantic_form_for(@new_post) do |f|
|
|
165
|
+
concat(f.input(:created_at, :as => :datetime_select, :selected => Date.new(2018, 10, 4)))
|
|
166
|
+
end
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
expect(output_buffer.to_str).to have_tag "option[value='2018'][selected='selected']"
|
|
170
|
+
expect(output_buffer.to_str).to have_tag "option[value='10'][selected='selected']"
|
|
171
|
+
expect(output_buffer.to_str).to have_tag "option[value='4'][selected='selected']"
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
160
175
|
describe "when required" do
|
|
161
176
|
it "should add the required attribute to the input's html options" do
|
|
162
|
-
with_config :use_required_attribute, true do
|
|
177
|
+
with_config :use_required_attribute, true do
|
|
163
178
|
concat(semantic_form_for(@new_post) do |builder|
|
|
164
179
|
concat(builder.input(:title, :as => :date_select, :required => true))
|
|
165
180
|
end)
|
|
166
|
-
output_buffer.
|
|
181
|
+
expect(output_buffer.to_str).to have_tag("select[@required]", :count => 3)
|
|
167
182
|
end
|
|
168
183
|
end
|
|
169
184
|
end
|
|
170
|
-
|
|
185
|
+
|
|
171
186
|
describe "when order does not include day" do
|
|
172
187
|
before do
|
|
173
|
-
output_buffer.
|
|
188
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
174
189
|
concat(semantic_form_for(@new_post) do |builder|
|
|
175
190
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:year, :month]))
|
|
176
191
|
end)
|
|
177
192
|
end
|
|
178
193
|
|
|
179
194
|
it "should include a hidden input for day" do
|
|
180
|
-
output_buffer.
|
|
195
|
+
expect(output_buffer.to_str).to have_tag('input[@type="hidden"][@name="post[publish_at(3i)]"][@value="1"]')
|
|
181
196
|
end
|
|
182
197
|
|
|
183
198
|
it "should not include a select for day" do
|
|
184
|
-
output_buffer.
|
|
199
|
+
expect(output_buffer.to_str).not_to have_tag('select[@name="post[publish_at(3i)]"]')
|
|
185
200
|
end
|
|
186
201
|
end
|
|
187
202
|
|
|
188
203
|
describe "when order does not include month" do
|
|
189
204
|
before do
|
|
190
|
-
output_buffer.
|
|
205
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
191
206
|
concat(semantic_form_for(@new_post) do |builder|
|
|
192
207
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:year, :day]))
|
|
193
208
|
end)
|
|
194
209
|
end
|
|
195
210
|
|
|
196
211
|
it "should include a hidden input for month" do
|
|
197
|
-
output_buffer.
|
|
212
|
+
expect(output_buffer.to_str).to have_tag('input[@type="hidden"][@name="post[publish_at(2i)]"][@value="1"]')
|
|
198
213
|
end
|
|
199
214
|
|
|
200
215
|
it "should not include a select for month" do
|
|
201
|
-
output_buffer.
|
|
216
|
+
expect(output_buffer.to_str).not_to have_tag('select[@name="post[publish_at(2i)]"]')
|
|
202
217
|
end
|
|
203
218
|
end
|
|
204
219
|
|
|
205
220
|
describe "when order does not include year" do
|
|
206
221
|
before do
|
|
207
|
-
output_buffer.
|
|
222
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
208
223
|
concat(semantic_form_for(@new_post) do |builder|
|
|
209
224
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:month, :day]))
|
|
210
225
|
end)
|
|
211
226
|
end
|
|
212
227
|
|
|
213
228
|
it "should include a hidden input for month" do
|
|
214
|
-
output_buffer.
|
|
229
|
+
expect(output_buffer.to_str).to have_tag("input[@type=\"hidden\"][@name=\"post[publish_at(1i)]\"][@value=\"#{Time.now.year}\"]")
|
|
215
230
|
end
|
|
216
231
|
|
|
217
232
|
it "should not include a select for month" do
|
|
218
|
-
output_buffer.
|
|
233
|
+
expect(output_buffer.to_str).not_to have_tag('select[@name="post[publish_at(1i)]"]')
|
|
219
234
|
end
|
|
220
235
|
end
|
|
221
236
|
|
|
222
237
|
describe "when order does not have year first" do
|
|
223
238
|
before do
|
|
224
|
-
output_buffer.
|
|
239
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
225
240
|
concat(semantic_form_for(@new_post) do |builder|
|
|
226
241
|
concat(builder.input(:publish_at, :as => :date_select, :order => [:day, :month, :year]))
|
|
227
242
|
end)
|
|
228
243
|
end
|
|
229
244
|
|
|
230
245
|
it 'should associate the legend label with the new first select' do
|
|
231
|
-
output_buffer.
|
|
246
|
+
expect(output_buffer.to_str).to have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_3i"]')
|
|
232
247
|
end
|
|
233
248
|
end
|
|
234
249
|
|