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 'Formtastic::FormBuilder#inputs' do
|
|
@@ -6,90 +7,90 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' 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
|
describe 'with a block (block forms syntax)' do
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
describe 'when no options are provided' do
|
|
16
17
|
before do
|
|
17
|
-
output_buffer.
|
|
18
|
+
@output_buffer = ActionView::OutputBuffer.new 'before_builder' # replace the output buffer and with one set to before_builder
|
|
18
19
|
concat(semantic_form_for(@new_post) do |builder|
|
|
19
20
|
@inputs_output = builder.inputs do
|
|
20
21
|
concat('hello')
|
|
21
22
|
end
|
|
22
23
|
end)
|
|
23
24
|
end
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
it 'should output just the content wrapped in inputs, not the whole template' do
|
|
26
|
-
expect(output_buffer).to match(/before_builder/)
|
|
27
|
+
expect(output_buffer.to_str).to match(/before_builder/)
|
|
27
28
|
expect(@inputs_output).not_to match(/before_builder/)
|
|
28
29
|
end
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
it 'should render a fieldset inside the form, with a class of "inputs"' do
|
|
31
|
-
expect(output_buffer).to have_tag("form fieldset.inputs")
|
|
32
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs")
|
|
32
33
|
end
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
it 'should render an ol inside the fieldset' do
|
|
35
|
-
expect(output_buffer).to have_tag("form fieldset.inputs ol")
|
|
36
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs ol")
|
|
36
37
|
end
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
it 'should render the contents of the block inside the ol' do
|
|
39
|
-
expect(output_buffer).to have_tag("form fieldset.inputs ol", :text => /hello/)
|
|
40
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs ol", :text => /hello/)
|
|
40
41
|
end
|
|
41
|
-
|
|
42
|
+
|
|
42
43
|
it 'should not render a legend inside the fieldset' do
|
|
43
|
-
expect(output_buffer).not_to have_tag("form fieldset.inputs legend")
|
|
44
|
+
expect(output_buffer.to_str).not_to have_tag("form fieldset.inputs legend")
|
|
44
45
|
end
|
|
45
|
-
|
|
46
|
+
|
|
46
47
|
it 'should render a fieldset even if no object is given' do
|
|
47
48
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
|
48
49
|
@inputs_output = builder.inputs do
|
|
49
50
|
concat('bye')
|
|
50
51
|
end
|
|
51
52
|
end)
|
|
52
|
-
expect(output_buffer).to have_tag("form fieldset.inputs ol", :text => /bye/)
|
|
53
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs ol", :text => /bye/)
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
|
-
|
|
56
|
+
|
|
56
57
|
describe 'when a :for option is provided' do
|
|
57
|
-
|
|
58
|
+
|
|
58
59
|
before do
|
|
59
60
|
allow(@new_post).to receive(:respond_to?).and_return(true, true)
|
|
60
61
|
allow(@new_post).to receive(:respond_to?).with(:empty?).and_return(false)
|
|
61
62
|
allow(@new_post).to receive(:author).and_return(@bob)
|
|
62
63
|
end
|
|
63
|
-
|
|
64
|
+
|
|
64
65
|
it 'should render nested inputs' do
|
|
65
66
|
allow(@bob).to receive(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
|
|
66
|
-
|
|
67
|
+
|
|
67
68
|
concat(semantic_form_for(@new_post) do |builder|
|
|
68
69
|
inputs = builder.inputs :for => [:author, @bob] do |bob_builder|
|
|
69
70
|
concat(bob_builder.input(:login))
|
|
70
71
|
end
|
|
71
72
|
concat(inputs)
|
|
72
73
|
end)
|
|
73
|
-
expect(output_buffer).to have_tag("form fieldset.inputs #post_author_attributes_login")
|
|
74
|
-
expect(output_buffer).not_to have_tag("form fieldset.inputs #author_login")
|
|
74
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs #post_author_attributes_login")
|
|
75
|
+
expect(output_buffer.to_str).not_to have_tag("form fieldset.inputs #author_login")
|
|
75
76
|
end
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
it 'should concat rendered nested inputs to the template' do
|
|
78
79
|
allow(@bob).to receive(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
concat(semantic_form_for(@new_post) do |builder|
|
|
81
82
|
builder.inputs :for => [:author, @bob] do |bob_builder|
|
|
82
83
|
concat(bob_builder.input(:login))
|
|
83
84
|
end
|
|
84
85
|
end)
|
|
85
|
-
|
|
86
|
-
expect(output_buffer).to have_tag("form fieldset.inputs #post_author_attributes_login")
|
|
87
|
-
expect(output_buffer).not_to have_tag("form fieldset.inputs #author_login")
|
|
88
|
-
|
|
86
|
+
|
|
87
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs #post_author_attributes_login")
|
|
88
|
+
expect(output_buffer.to_str).not_to have_tag("form fieldset.inputs #author_login")
|
|
89
|
+
|
|
89
90
|
end
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
describe "as a symbol representing the association name" do
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
it 'should nest the inputs with an _attributes suffix on the association name' do
|
|
94
95
|
concat(semantic_form_for(@new_post) do |post|
|
|
95
96
|
inputs = post.inputs :for => :author do |author|
|
|
@@ -97,48 +98,48 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
97
98
|
end
|
|
98
99
|
concat(inputs)
|
|
99
100
|
end)
|
|
100
|
-
expect(output_buffer).to have_tag("form input[@name='post[author_attributes][login]']")
|
|
101
|
+
expect(output_buffer.to_str).to have_tag("form input[@name='post[author_attributes][login]']")
|
|
101
102
|
end
|
|
102
|
-
|
|
103
|
+
|
|
103
104
|
end
|
|
104
|
-
|
|
105
|
+
|
|
105
106
|
describe "as a symbol representing a has_many association name" do
|
|
106
107
|
before do
|
|
107
108
|
allow(@new_post).to receive(:authors).and_return([@bob, @fred])
|
|
108
109
|
allow(@new_post).to receive(:authors_attributes=)
|
|
109
110
|
end
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
it 'should nest the inputs with a fieldset, legend and :name input for each item' do
|
|
112
113
|
concat(semantic_form_for(@new_post) do |post|
|
|
113
114
|
post.inputs :for => :authors, :name => '%i' do |author|
|
|
114
115
|
concat(author.input(:login))
|
|
115
116
|
end
|
|
116
117
|
end)
|
|
117
|
-
|
|
118
|
-
expect(output_buffer).to have_tag("form fieldset.inputs", :count => 2)
|
|
119
|
-
expect(output_buffer).to have_tag("form fieldset.inputs legend", :count => 2)
|
|
120
|
-
expect(output_buffer).to have_tag("form fieldset.inputs legend", :text => "1", :count => 1)
|
|
121
|
-
expect(output_buffer).to have_tag("form fieldset.inputs legend", :text => "2")
|
|
122
|
-
expect(output_buffer).to have_tag("form input[@name='post[authors_attributes][0][login]']")
|
|
123
|
-
expect(output_buffer).to have_tag("form input[@name='post[authors_attributes][1][login]']")
|
|
124
|
-
expect(output_buffer).not_to have_tag('form fieldset[@name]')
|
|
118
|
+
|
|
119
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs", :count => 2)
|
|
120
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs legend", :count => 2)
|
|
121
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs legend", :text => "1", :count => 1)
|
|
122
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs legend", :text => "2")
|
|
123
|
+
expect(output_buffer.to_str).to have_tag("form input[@name='post[authors_attributes][0][login]']")
|
|
124
|
+
expect(output_buffer.to_str).to have_tag("form input[@name='post[authors_attributes][1][login]']")
|
|
125
|
+
expect(output_buffer.to_str).not_to have_tag('form fieldset[@name]')
|
|
125
126
|
end
|
|
126
|
-
|
|
127
|
+
|
|
127
128
|
it 'should include an indexed :label input for each item' do
|
|
128
129
|
concat(semantic_form_for(@new_post) do |post|
|
|
129
130
|
post.inputs :for => :authors do |author, index|
|
|
130
131
|
concat(author.input(:login, :label => "#{index}", :required => false))
|
|
131
132
|
end
|
|
132
133
|
end)
|
|
133
|
-
|
|
134
|
-
expect(output_buffer).to have_tag("form fieldset.inputs label", :text => "1", :count => 1)
|
|
135
|
-
expect(output_buffer).to have_tag("form fieldset.inputs label", :text => "2", :count => 1)
|
|
136
|
-
expect(output_buffer).not_to have_tag('form fieldset legend')
|
|
134
|
+
|
|
135
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs label", :text => "1", :count => 1)
|
|
136
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs label", :text => "2", :count => 1)
|
|
137
|
+
expect(output_buffer.to_str).not_to have_tag('form fieldset legend')
|
|
137
138
|
end
|
|
138
139
|
end
|
|
139
|
-
|
|
140
|
+
|
|
140
141
|
describe 'as an array containing the a symbole for the association name and the associated object' do
|
|
141
|
-
|
|
142
|
+
|
|
142
143
|
it 'should nest the inputs with an _attributes suffix on the association name' do
|
|
143
144
|
concat(semantic_form_for(@new_post) do |post|
|
|
144
145
|
inputs = post.inputs :for => [:author, @new_post.author] do |author|
|
|
@@ -146,13 +147,13 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
146
147
|
end
|
|
147
148
|
concat(inputs)
|
|
148
149
|
end)
|
|
149
|
-
expect(output_buffer).to have_tag("form input[@name='post[author_attributes][login]']")
|
|
150
|
+
expect(output_buffer.to_str).to have_tag("form input[@name='post[author_attributes][login]']")
|
|
150
151
|
end
|
|
151
|
-
|
|
152
|
+
|
|
152
153
|
end
|
|
153
|
-
|
|
154
|
+
|
|
154
155
|
describe 'as an associated object' do
|
|
155
|
-
|
|
156
|
+
|
|
156
157
|
it 'should not nest the inputs with an _attributes suffix' do
|
|
157
158
|
concat(semantic_form_for(@new_post) do |post|
|
|
158
159
|
inputs = post.inputs :for => @new_post.author do |author|
|
|
@@ -160,35 +161,34 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
160
161
|
end
|
|
161
162
|
concat(inputs)
|
|
162
163
|
end)
|
|
163
|
-
expect(output_buffer).to have_tag("form input[@name='post[author][login]']")
|
|
164
|
+
expect(output_buffer.to_str).to have_tag("form input[@name='post[author][login]']")
|
|
164
165
|
end
|
|
165
|
-
|
|
166
|
+
|
|
166
167
|
end
|
|
167
|
-
|
|
168
|
+
|
|
168
169
|
it 'should raise an error if :for and block with no argument is given' do
|
|
169
170
|
semantic_form_for(@new_post) do |builder|
|
|
170
171
|
expect {
|
|
171
172
|
builder.inputs(:for => [:author, @bob]) do
|
|
172
173
|
#
|
|
173
174
|
end
|
|
174
|
-
}.to raise_error(ArgumentError, 'You gave :for option with a block to inputs method, '
|
|
175
|
-
'but the block does not accept any argument.')
|
|
175
|
+
}.to raise_error(ArgumentError, 'You gave :for option with a block to inputs method, but the block does not accept any argument.')
|
|
176
176
|
end
|
|
177
177
|
end
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
it 'should pass options down to semantic_fields_for' do
|
|
180
180
|
allow(@bob).to receive(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
concat(semantic_form_for(@new_post) do |builder|
|
|
183
183
|
inputs = builder.inputs :for => [:author, @bob], :for_options => { :index => 10 } do |bob_builder|
|
|
184
184
|
concat(bob_builder.input(:login))
|
|
185
185
|
end
|
|
186
186
|
concat(inputs)
|
|
187
187
|
end)
|
|
188
|
-
|
|
189
|
-
expect(output_buffer).to have_tag('form fieldset ol li #post_author_attributes_10_login')
|
|
188
|
+
|
|
189
|
+
expect(output_buffer.to_str).to have_tag('form fieldset ol li #post_author_attributes_10_login')
|
|
190
190
|
end
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
it 'should not add builder as a fieldset attribute tag' do
|
|
193
193
|
concat(semantic_form_for(@new_post) do |builder|
|
|
194
194
|
inputs = builder.inputs :for => [:author, @bob], :for_options => { :index => 10 } do |bob_builder|
|
|
@@ -196,10 +196,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
196
196
|
end
|
|
197
197
|
concat(inputs)
|
|
198
198
|
end)
|
|
199
|
-
|
|
200
|
-
expect(output_buffer).not_to have_tag('fieldset[@builder="Formtastic::Helpers::FormHelper"]')
|
|
199
|
+
|
|
200
|
+
expect(output_buffer.to_str).not_to have_tag('fieldset[@builder="Formtastic::Helpers::FormHelper"]')
|
|
201
201
|
end
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
it 'should send parent_builder as an option to allow child index interpolation for legends' do
|
|
204
204
|
concat(semantic_form_for(@new_post) do |builder|
|
|
205
205
|
builder.instance_variable_set('@nested_child_index', 0)
|
|
@@ -208,10 +208,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
208
208
|
end
|
|
209
209
|
concat(inputs)
|
|
210
210
|
end)
|
|
211
|
-
|
|
212
|
-
expect(output_buffer).to have_tag('fieldset legend', :text => 'Author #1')
|
|
211
|
+
|
|
212
|
+
expect(output_buffer.to_str).to have_tag('fieldset legend', :text => 'Author #1')
|
|
213
213
|
end
|
|
214
|
-
|
|
214
|
+
|
|
215
215
|
it 'should also provide child index interpolation for legends when nested child index is a hash' do
|
|
216
216
|
concat(semantic_form_for(@new_post) do |builder|
|
|
217
217
|
builder.instance_variable_set('@nested_child_index', :author => 10)
|
|
@@ -220,10 +220,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
220
220
|
end
|
|
221
221
|
concat(inputs)
|
|
222
222
|
end)
|
|
223
|
-
|
|
224
|
-
expect(output_buffer).to have_tag('fieldset legend', :text => 'Author #11')
|
|
223
|
+
|
|
224
|
+
expect(output_buffer.to_str).to have_tag('fieldset legend', :text => 'Author #11')
|
|
225
225
|
end
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
it 'should send parent_builder as an option to allow child index interpolation for labels' do
|
|
228
228
|
concat(semantic_form_for(@new_post) do |builder|
|
|
229
229
|
builder.instance_variable_set('@nested_child_index', 'post[author_attributes]' => 0)
|
|
@@ -232,10 +232,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
232
232
|
end
|
|
233
233
|
concat(inputs)
|
|
234
234
|
end)
|
|
235
|
-
|
|
236
|
-
expect(output_buffer).to have_tag('fieldset label', :text => 'Author #1')
|
|
235
|
+
|
|
236
|
+
expect(output_buffer.to_str).to have_tag('fieldset label', :text => 'Author #1')
|
|
237
237
|
end
|
|
238
|
-
|
|
238
|
+
|
|
239
239
|
it 'should also provide child index interpolation for labels when nested child index is a hash' do
|
|
240
240
|
concat(semantic_form_for(@new_post) do |builder|
|
|
241
241
|
builder.instance_variable_set('@nested_child_index', 'post[author_attributes]' => 10)
|
|
@@ -244,11 +244,11 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
244
244
|
end
|
|
245
245
|
concat(inputs)
|
|
246
246
|
end)
|
|
247
|
-
|
|
248
|
-
expect(output_buffer).to have_tag('fieldset label', :text => 'Author #11')
|
|
247
|
+
|
|
248
|
+
expect(output_buffer.to_str).to have_tag('fieldset label', :text => 'Author #11')
|
|
249
249
|
end
|
|
250
250
|
end
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
describe 'when a :name or :title option is provided' do
|
|
253
253
|
describe 'and is a string' do
|
|
254
254
|
before do
|
|
@@ -271,16 +271,16 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
271
271
|
concat(inputs)
|
|
272
272
|
end)
|
|
273
273
|
end
|
|
274
|
-
|
|
274
|
+
|
|
275
275
|
# TODO: looks like the block isn't being called for the last assertion here
|
|
276
276
|
it 'should render a fieldset with a legend inside the form' do
|
|
277
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@legend_text}$/)
|
|
278
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@legend_text_using_name}$/)
|
|
279
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@legend_text_using_title}$/)
|
|
280
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@nested_forms_legend_text}$/)
|
|
277
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@legend_text}$/)
|
|
278
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@legend_text_using_name}$/)
|
|
279
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@legend_text_using_title}$/)
|
|
280
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@nested_forms_legend_text}$/)
|
|
281
281
|
end
|
|
282
282
|
end
|
|
283
|
-
|
|
283
|
+
|
|
284
284
|
describe 'and is a symbol' do
|
|
285
285
|
before do
|
|
286
286
|
@localized_legend_text = "Localized advanced options"
|
|
@@ -308,162 +308,162 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
308
308
|
end)
|
|
309
309
|
end)
|
|
310
310
|
end
|
|
311
|
-
|
|
311
|
+
|
|
312
312
|
# TODO: looks like the block isn't being called for the last assertion here
|
|
313
313
|
it 'should render a fieldset with a localized legend inside the form' do
|
|
314
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text}$/)
|
|
315
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text_using_name}$/)
|
|
316
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text_using_title}$/)
|
|
317
|
-
expect(output_buffer).to have_tag("form fieldset legend", :text => /^#{@localized_nested_forms_legend_text}$/)
|
|
314
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text}$/)
|
|
315
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text_using_name}$/)
|
|
316
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@localized_legend_text_using_title}$/)
|
|
317
|
+
expect(output_buffer.to_str).to have_tag("form fieldset legend", :text => /^#{@localized_nested_forms_legend_text}$/)
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
end
|
|
321
|
-
|
|
321
|
+
|
|
322
322
|
describe 'when other options are provided' do
|
|
323
323
|
before do
|
|
324
324
|
@id_option = 'advanced'
|
|
325
325
|
@class_option = 'wide'
|
|
326
|
-
|
|
326
|
+
|
|
327
327
|
concat(semantic_form_for(@new_post) do |builder|
|
|
328
328
|
builder.inputs :id => @id_option, :class => @class_option do
|
|
329
329
|
end
|
|
330
330
|
end)
|
|
331
331
|
end
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
it 'should pass the options into the fieldset tag as attributes' do
|
|
334
|
-
expect(output_buffer).to have_tag("form fieldset##{@id_option}")
|
|
335
|
-
expect(output_buffer).to have_tag("form fieldset.#{@class_option}")
|
|
334
|
+
expect(output_buffer.to_str).to have_tag("form fieldset##{@id_option}")
|
|
335
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.#{@class_option}")
|
|
336
336
|
end
|
|
337
337
|
end
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
end
|
|
340
|
-
|
|
340
|
+
|
|
341
341
|
describe 'without a block' do
|
|
342
|
-
|
|
342
|
+
|
|
343
343
|
before do
|
|
344
344
|
allow(::Post).to receive(:reflections).and_return({:author => double('reflection', :options => {}, :macro => :belongs_to),
|
|
345
345
|
:comments => double('reflection', :options => {}, :macro => :has_many) })
|
|
346
|
-
|
|
346
|
+
|
|
347
347
|
allow(@new_post).to receive(:title)
|
|
348
348
|
allow(@new_post).to receive(:body)
|
|
349
349
|
allow(@new_post).to receive(:author_id)
|
|
350
|
-
|
|
350
|
+
|
|
351
351
|
allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :string, :limit => 255))
|
|
352
352
|
allow(@new_post).to receive(:column_for_attribute).with(:body).and_return(double('column', :type => :text))
|
|
353
353
|
allow(@new_post).to receive(:column_for_attribute).with(:created_at).and_return(double('column', :type => :datetime))
|
|
354
354
|
allow(@new_post).to receive(:column_for_attribute).with(:author).and_return(nil)
|
|
355
355
|
end
|
|
356
|
-
|
|
356
|
+
|
|
357
357
|
describe 'with no args (quick forms syntax)' do
|
|
358
358
|
before do
|
|
359
359
|
concat(semantic_form_for(@new_post) do |builder|
|
|
360
360
|
concat(builder.inputs)
|
|
361
361
|
end)
|
|
362
362
|
end
|
|
363
|
-
|
|
363
|
+
|
|
364
364
|
it 'should render a form' do
|
|
365
|
-
expect(output_buffer).to have_tag('form')
|
|
365
|
+
expect(output_buffer.to_str).to have_tag('form')
|
|
366
366
|
end
|
|
367
|
-
|
|
367
|
+
|
|
368
368
|
it 'should render a fieldset inside the form' do
|
|
369
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs')
|
|
369
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs')
|
|
370
370
|
end
|
|
371
|
-
|
|
371
|
+
|
|
372
372
|
it 'should not render a legend in the fieldset' do
|
|
373
|
-
expect(output_buffer).not_to have_tag('form > fieldset.inputs > legend')
|
|
373
|
+
expect(output_buffer.to_str).not_to have_tag('form > fieldset.inputs > legend')
|
|
374
374
|
end
|
|
375
|
-
|
|
375
|
+
|
|
376
376
|
it 'should render an ol in the fieldset' do
|
|
377
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol')
|
|
377
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol')
|
|
378
378
|
end
|
|
379
|
-
|
|
379
|
+
|
|
380
380
|
it 'should render a list item in the ol for each column and reflection' do
|
|
381
381
|
# Remove the :has_many macro and :created_at column
|
|
382
382
|
count = ::Post.content_columns.size + ::Post.reflections.size - 2
|
|
383
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li', :count => count)
|
|
383
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li', :count => count)
|
|
384
384
|
end
|
|
385
|
-
|
|
385
|
+
|
|
386
386
|
it 'should render a string list item for title' do
|
|
387
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
387
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
388
388
|
end
|
|
389
|
-
|
|
389
|
+
|
|
390
390
|
it 'should render a text list item for body' do
|
|
391
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
391
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
392
392
|
end
|
|
393
|
-
|
|
393
|
+
|
|
394
394
|
it 'should render a select list item for author_id' do
|
|
395
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.select', :count => 1)
|
|
395
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.select', :count => 1)
|
|
396
396
|
end
|
|
397
|
-
|
|
397
|
+
|
|
398
398
|
it 'should not render timestamps inputs by default' do
|
|
399
|
-
expect(output_buffer).not_to have_tag('form > fieldset.inputs > ol > li.datetime')
|
|
399
|
+
expect(output_buffer.to_str).not_to have_tag('form > fieldset.inputs > ol > li.datetime')
|
|
400
400
|
end
|
|
401
401
|
|
|
402
402
|
context "with non-standard foregin keys" do
|
|
403
403
|
before do
|
|
404
|
-
@output_buffer = ''
|
|
404
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
405
405
|
end
|
|
406
406
|
|
|
407
407
|
it 'should respect foreign key while rendering select' do
|
|
408
408
|
concat(semantic_form_for(LegacyPost.new, {:url => '/'}) do |builder|
|
|
409
409
|
concat(builder.inputs)
|
|
410
410
|
end)
|
|
411
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.select select#legacy_post_post_author', :count => 1)
|
|
412
|
-
expect(output_buffer).not_to have_tag('input#legacy_post_post_author')
|
|
411
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.select select#legacy_post_post_author', :count => 1)
|
|
412
|
+
expect(output_buffer.to_str).not_to have_tag('input#legacy_post_post_author')
|
|
413
413
|
end
|
|
414
|
-
|
|
414
|
+
|
|
415
415
|
end
|
|
416
416
|
|
|
417
417
|
context "with a polymorphic association" do
|
|
418
|
-
|
|
419
|
-
before do
|
|
418
|
+
|
|
419
|
+
before do
|
|
420
420
|
allow(@new_post).to receive(:commentable)
|
|
421
|
-
allow(@new_post.class).to receive(:reflections).and_return({
|
|
421
|
+
allow(@new_post.class).to receive(:reflections).and_return({
|
|
422
422
|
:commentable => double('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
|
|
423
423
|
})
|
|
424
424
|
allow(@new_post).to receive(:column_for_attribute).with(:commentable).and_return(
|
|
425
425
|
double('column', :type => :integer)
|
|
426
426
|
)
|
|
427
427
|
end
|
|
428
|
-
|
|
428
|
+
|
|
429
429
|
it 'should not render an input for the polymorphic association (the collection class cannot be guessed)' do
|
|
430
430
|
concat(semantic_form_for(@new_post) do |builder|
|
|
431
431
|
concat(builder.inputs)
|
|
432
432
|
end)
|
|
433
|
-
expect(output_buffer).not_to have_tag('li#post_commentable_input')
|
|
433
|
+
expect(output_buffer.to_str).not_to have_tag('li#post_commentable_input')
|
|
434
434
|
end
|
|
435
|
-
|
|
435
|
+
|
|
436
436
|
end
|
|
437
437
|
end
|
|
438
|
-
|
|
438
|
+
|
|
439
439
|
describe 'with column names as args (short hand forms syntax)' do
|
|
440
440
|
describe 'and an object is given' do
|
|
441
441
|
it 'should render a form with a fieldset containing two list items' do
|
|
442
442
|
concat(semantic_form_for(@new_post) do |builder|
|
|
443
443
|
concat(builder.inputs(:title, :body))
|
|
444
444
|
end)
|
|
445
|
-
|
|
446
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
447
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
448
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
445
|
+
|
|
446
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
447
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
448
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
449
449
|
end
|
|
450
450
|
end
|
|
451
|
-
|
|
451
|
+
|
|
452
452
|
describe 'and no object is given' do
|
|
453
453
|
it 'should render a form with a fieldset containing two list items' do
|
|
454
454
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
|
455
455
|
concat(builder.inputs(:title, :body))
|
|
456
456
|
end)
|
|
457
|
-
|
|
458
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.string', :count => 2)
|
|
457
|
+
|
|
458
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.string', :count => 2)
|
|
459
459
|
end
|
|
460
460
|
end
|
|
461
|
-
|
|
461
|
+
|
|
462
462
|
context "with a polymorphic association" do
|
|
463
|
-
|
|
463
|
+
|
|
464
464
|
it 'should raise an error for polymorphic associations (the collection class cannot be guessed)' do
|
|
465
465
|
allow(@new_post).to receive(:commentable)
|
|
466
|
-
allow(@new_post.class).to receive(:reflections).and_return({
|
|
466
|
+
allow(@new_post.class).to receive(:reflections).and_return({
|
|
467
467
|
:commentable => double('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
|
|
468
468
|
})
|
|
469
469
|
allow(@new_post).to receive(:column_for_attribute).with(:commentable).and_return(
|
|
@@ -472,18 +472,18 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
472
472
|
allow(@new_post.class).to receive(:reflect_on_association).with(:commentable).and_return(
|
|
473
473
|
double('reflection', :macro => :belongs_to, :options => { :polymorphic => true })
|
|
474
474
|
)
|
|
475
|
-
|
|
476
|
-
expect {
|
|
475
|
+
|
|
476
|
+
expect {
|
|
477
477
|
concat(semantic_form_for(@new_post) do |builder|
|
|
478
478
|
concat(builder.inputs :commentable)
|
|
479
479
|
end)
|
|
480
480
|
}.to raise_error(Formtastic::PolymorphicInputWithoutCollectionError)
|
|
481
481
|
end
|
|
482
|
-
|
|
482
|
+
|
|
483
483
|
end
|
|
484
|
-
|
|
484
|
+
|
|
485
485
|
end
|
|
486
|
-
|
|
486
|
+
|
|
487
487
|
describe 'when a :for option is provided' do
|
|
488
488
|
describe 'and an object is given' do
|
|
489
489
|
it 'should render nested inputs' do
|
|
@@ -491,23 +491,23 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
491
491
|
concat(semantic_form_for(@new_post) do |builder|
|
|
492
492
|
concat(builder.inputs(:login, :for => @bob))
|
|
493
493
|
end)
|
|
494
|
-
|
|
495
|
-
expect(output_buffer).to have_tag("form fieldset.inputs #post_author_login")
|
|
496
|
-
expect(output_buffer).not_to have_tag("form fieldset.inputs #author_login")
|
|
494
|
+
|
|
495
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs #post_author_login")
|
|
496
|
+
expect(output_buffer.to_str).not_to have_tag("form fieldset.inputs #author_login")
|
|
497
497
|
end
|
|
498
498
|
end
|
|
499
|
-
|
|
499
|
+
|
|
500
500
|
describe 'and no object is given' do
|
|
501
501
|
it 'should render nested inputs' do
|
|
502
502
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
|
503
503
|
concat(builder.inputs(:login, :for => @bob))
|
|
504
504
|
end)
|
|
505
|
-
expect(output_buffer).to have_tag("form fieldset.inputs #project_author_login")
|
|
506
|
-
expect(output_buffer).not_to have_tag("form fieldset.inputs #project_login")
|
|
505
|
+
expect(output_buffer.to_str).to have_tag("form fieldset.inputs #project_author_login")
|
|
506
|
+
expect(output_buffer.to_str).not_to have_tag("form fieldset.inputs #project_login")
|
|
507
507
|
end
|
|
508
508
|
end
|
|
509
509
|
end
|
|
510
|
-
|
|
510
|
+
|
|
511
511
|
describe 'with column names and an options hash as args' do
|
|
512
512
|
before do
|
|
513
513
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -517,18 +517,18 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
517
517
|
concat(builder.inputs(@legend_text_using_arg, :title, :body, :id => "my-id-2"))
|
|
518
518
|
end)
|
|
519
519
|
end
|
|
520
|
-
|
|
520
|
+
|
|
521
521
|
it 'should render a form with a fieldset containing two list items' do
|
|
522
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li', :count => 4)
|
|
522
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li', :count => 4)
|
|
523
523
|
end
|
|
524
|
-
|
|
524
|
+
|
|
525
525
|
it 'should pass the options down to the fieldset' do
|
|
526
|
-
expect(output_buffer).to have_tag('form > fieldset#my-id.inputs')
|
|
526
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset#my-id.inputs')
|
|
527
527
|
end
|
|
528
|
-
|
|
528
|
+
|
|
529
529
|
it 'should use the special :name option as a text for the legend tag' do
|
|
530
|
-
expect(output_buffer).to have_tag('form > fieldset#my-id.inputs > legend', :text => /^#{@legend_text_using_option}$/)
|
|
531
|
-
expect(output_buffer).to have_tag('form > fieldset#my-id-2.inputs > legend', :text => /^#{@legend_text_using_arg}$/)
|
|
530
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset#my-id.inputs > legend', :text => /^#{@legend_text_using_option}$/)
|
|
531
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset#my-id-2.inputs > legend', :text => /^#{@legend_text_using_arg}$/)
|
|
532
532
|
end
|
|
533
533
|
end
|
|
534
534
|
|
|
@@ -539,9 +539,9 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
539
539
|
concat(builder.inputs :except => :body)
|
|
540
540
|
end)
|
|
541
541
|
|
|
542
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
543
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
544
|
-
expect(output_buffer).not_to have_tag('form > fieldset.inputs > ol > li.text')
|
|
542
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
543
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.string')
|
|
544
|
+
expect(output_buffer.to_str).not_to have_tag('form > fieldset.inputs > ol > li.text')
|
|
545
545
|
end
|
|
546
546
|
|
|
547
547
|
it 'should render a form with a fieldset containing only text item' do
|
|
@@ -549,9 +549,9 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
549
549
|
concat(builder.inputs :except => :title)
|
|
550
550
|
end)
|
|
551
551
|
|
|
552
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
553
|
-
expect(output_buffer).not_to have_tag('form > fieldset.inputs > ol > li.string')
|
|
554
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
552
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li', :count => 2)
|
|
553
|
+
expect(output_buffer.to_str).not_to have_tag('form > fieldset.inputs > ol > li.string')
|
|
554
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.text')
|
|
555
555
|
end
|
|
556
556
|
end
|
|
557
557
|
|
|
@@ -561,24 +561,24 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
561
561
|
concat(builder.inputs(:title, :body))
|
|
562
562
|
end)
|
|
563
563
|
|
|
564
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li.string', :count => 2)
|
|
564
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li.string', :count => 2)
|
|
565
565
|
end
|
|
566
566
|
end
|
|
567
567
|
end
|
|
568
568
|
end
|
|
569
|
-
|
|
569
|
+
|
|
570
570
|
describe 'nesting' do
|
|
571
|
-
|
|
571
|
+
|
|
572
572
|
context "when not nested" do
|
|
573
573
|
it "should not wrap the inputs in an li block" do
|
|
574
574
|
concat(semantic_form_for(@new_post) do |builder|
|
|
575
575
|
concat(builder.inputs do
|
|
576
576
|
end)
|
|
577
577
|
end)
|
|
578
|
-
expect(output_buffer).not_to have_tag('form > li')
|
|
578
|
+
expect(output_buffer.to_str).not_to have_tag('form > li')
|
|
579
579
|
end
|
|
580
580
|
end
|
|
581
|
-
|
|
581
|
+
|
|
582
582
|
context "when nested (with block)" do
|
|
583
583
|
it "should wrap the nested inputs in an li block to maintain HTML validity" do
|
|
584
584
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -587,10 +587,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
587
587
|
end)
|
|
588
588
|
end)
|
|
589
589
|
end)
|
|
590
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
590
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
591
591
|
end
|
|
592
592
|
end
|
|
593
|
-
|
|
593
|
+
|
|
594
594
|
context "when nested (with block and :for)" do
|
|
595
595
|
it "should wrap the nested inputs in an li block to maintain HTML validity" do
|
|
596
596
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -599,10 +599,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
599
599
|
end)
|
|
600
600
|
end)
|
|
601
601
|
end)
|
|
602
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
602
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
603
603
|
end
|
|
604
604
|
end
|
|
605
|
-
|
|
605
|
+
|
|
606
606
|
context "when nested (without block)" do
|
|
607
607
|
it "should wrap the nested inputs in an li block to maintain HTML validity" do
|
|
608
608
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -610,10 +610,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
610
610
|
concat(builder.inputs(:title))
|
|
611
611
|
end)
|
|
612
612
|
end)
|
|
613
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
613
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
614
614
|
end
|
|
615
615
|
end
|
|
616
|
-
|
|
616
|
+
|
|
617
617
|
context "when nested (without block, with :for)" do
|
|
618
618
|
it "should wrap the nested inputs in an li block to maintain HTML validity" do
|
|
619
619
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -621,10 +621,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
621
621
|
concat(builder.inputs(:name, :for => :author))
|
|
622
622
|
end)
|
|
623
623
|
end)
|
|
624
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
624
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
625
625
|
end
|
|
626
626
|
end
|
|
627
|
-
|
|
627
|
+
|
|
628
628
|
context "when double nested" do
|
|
629
629
|
it "should wrap the nested inputs in an li block to maintain HTML validity" do
|
|
630
630
|
concat(semantic_form_for(@new_post) do |builder|
|
|
@@ -635,7 +635,7 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
635
635
|
end)
|
|
636
636
|
end)
|
|
637
637
|
end)
|
|
638
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
638
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol > li > fieldset.inputs > ol')
|
|
639
639
|
end
|
|
640
640
|
end
|
|
641
641
|
|
|
@@ -649,10 +649,10 @@ RSpec.describe 'Formtastic::FormBuilder#inputs' do
|
|
|
649
649
|
end)
|
|
650
650
|
end)
|
|
651
651
|
end)
|
|
652
|
-
expect(output_buffer).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol', :count => 2)
|
|
652
|
+
expect(output_buffer.to_str).to have_tag('form > fieldset.inputs > ol > li > fieldset.inputs > ol', :count => 2)
|
|
653
653
|
end
|
|
654
654
|
end
|
|
655
|
-
|
|
655
|
+
|
|
656
656
|
end
|
|
657
657
|
|
|
658
658
|
describe 'when using MongoMapper associations ' do
|