speedo-formstrap 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/README.md +4 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/speedo-formstrap/form_builder.rb +7 -5
- data/lib/speedo-formstrap/helpers.rb +3 -1
- data/lib/speedo-formstrap/helpers/buttons_helper.rb +13 -9
- data/lib/speedo-formstrap/helpers/fieldset_wrapper.rb +11 -6
- data/lib/speedo-formstrap/helpers/inputs_helper.rb +4 -4
- data/lib/speedo-formstrap/inputs/base.rb +2 -1
- data/lib/speedo-formstrap/inputs/base/choices.rb +12 -23
- data/lib/speedo-formstrap/inputs/base/labelling.rb +16 -6
- data/lib/speedo-formstrap/inputs/base/timeish.rb +5 -12
- data/lib/speedo-formstrap/inputs/base/wrapping.rb +32 -14
- data/lib/speedo-formstrap/inputs/number_input.rb +2 -2
- data/lib/speedo-formstrap/inputs/radio_input.rb +13 -12
- data/lib/speedo-formstrap/inputs/range_input.rb +2 -2
- data/spec/builder/semantic_fields_for_spec.rb +16 -16
- data/spec/helpers/buttons_helper_spec.rb +56 -46
- data/spec/helpers/input_helper_spec.rb +209 -209
- data/spec/helpers/inputs_helper_spec.rb +117 -103
- data/spec/inputs/boolean_input_spec.rb +74 -46
- data/spec/inputs/check_boxes_input_spec.rb +110 -82
- data/spec/inputs/date_input_spec.rb +81 -15
- data/spec/inputs/datetime_input_spec.rb +13 -13
- data/spec/inputs/email_input_spec.rb +34 -6
- data/spec/inputs/file_input_spec.rb +34 -6
- data/spec/inputs/hidden_input_spec.rb +41 -13
- data/spec/inputs/number_input_spec.rb +127 -97
- data/spec/inputs/password_input_spec.rb +34 -6
- data/spec/inputs/phone_input_spec.rb +34 -6
- data/spec/inputs/radio_input_spec.rb +73 -45
- data/spec/inputs/range_input_spec.rb +94 -66
- data/spec/inputs/search_input_spec.rb +33 -6
- data/spec/inputs/select_input_spec.rb +124 -78
- data/spec/inputs/string_input_spec.rb +67 -22
- data/spec/inputs/text_input_spec.rb +42 -15
- data/spec/inputs/time_input_spec.rb +23 -23
- data/spec/inputs/time_zone_input_spec.rb +20 -20
- data/spec/inputs/url_input_spec.rb +34 -6
- data/spec/support/custom_macros.rb +67 -196
- data/spec/support/formtastic_spec_helper.rb +22 -6
- data/speedo-formstrap.gemspec +2 -2
- metadata +17 -17
@@ -8,7 +8,7 @@ describe 'date input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "general" do
|
@@ -20,8 +20,8 @@ describe 'date input' do
|
|
20
20
|
end)
|
21
21
|
end
|
22
22
|
|
23
|
-
it_should_have_input_wrapper_with_class("date")
|
24
|
-
it_should_have_input_wrapper_with_class(
|
23
|
+
it_should_have_input_wrapper_with_class("date-wrapper")
|
24
|
+
it_should_have_input_wrapper_with_class("control-group")
|
25
25
|
it_should_have_input_wrapper_with_class(:stringish)
|
26
26
|
it_should_have_input_class_in_the_right_place
|
27
27
|
it_should_have_input_wrapper_with_id("post_publish_at_input")
|
@@ -31,7 +31,7 @@ describe 'date input' do
|
|
31
31
|
it_should_apply_error_logic_for_input_type(:date)
|
32
32
|
|
33
33
|
it 'should have a legend and label with the label text inside the fieldset' do
|
34
|
-
output_buffer.should have_tag('form div.
|
34
|
+
output_buffer.should have_tag('form div.control-group.date-wrapper label.control-label', /Publish at/)
|
35
35
|
end
|
36
36
|
|
37
37
|
# it 'should associate the legend label with the first select' do
|
@@ -42,8 +42,8 @@ describe 'date input' do
|
|
42
42
|
# end
|
43
43
|
|
44
44
|
it 'should (sort of) associate the label with the input' do
|
45
|
-
output_buffer.should have_tag('form div.
|
46
|
-
output_buffer.should have_tag('form div.
|
45
|
+
output_buffer.should have_tag('form div.control-group.date-wrapper label.control-label[@for="post_publish_at"]')
|
46
|
+
output_buffer.should have_tag('form div.control-group.date-wrapper div.controls input[@id="post_publish_at[date]"]')
|
47
47
|
end
|
48
48
|
|
49
49
|
# it 'should have an ordered list of three items inside the fieldset' do
|
@@ -58,7 +58,7 @@ describe 'date input' do
|
|
58
58
|
# output_buffer.should have_tag('form li.date fieldset ol li label', /day/i)
|
59
59
|
# end
|
60
60
|
it 'should have an text input inside the div' do
|
61
|
-
output_buffer.should have_tag('form div.
|
61
|
+
output_buffer.should have_tag('form div.control-group.date-wrapper div.controls input[@type="text"]')
|
62
62
|
end
|
63
63
|
|
64
64
|
# it 'should have three selects for year, month and day' do
|
@@ -97,7 +97,7 @@ describe 'date input' do
|
|
97
97
|
# output_buffer.should have_tag('form li.date fieldset ol li label', f == field ? /another #{f} label/i : /#{f}/i)
|
98
98
|
# end
|
99
99
|
# end
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# it "should not display the label for the #{field} field when :labels[:#{field}] is blank" do
|
102
102
|
# output_buffer.replace ''
|
103
103
|
# concat(semantic_form_for(@new_post) do |builder|
|
@@ -108,7 +108,7 @@ describe 'date input' do
|
|
108
108
|
# output_buffer.should have_tag('form li.date fieldset ol li label', /#{f}/i) unless field == f
|
109
109
|
# end
|
110
110
|
# end
|
111
|
-
#
|
111
|
+
#
|
112
112
|
# it "should not display the label for the #{field} field when :labels[:#{field}] is false" do
|
113
113
|
# output_buffer.replace ''
|
114
114
|
# concat(semantic_form_for(@new_post) do |builder|
|
@@ -119,21 +119,21 @@ describe 'date input' do
|
|
119
119
|
# output_buffer.should have_tag('form li.date fieldset ol li label', /#{f}/i) unless field == f
|
120
120
|
# end
|
121
121
|
# end
|
122
|
-
#
|
123
|
-
# it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
122
|
+
#
|
123
|
+
# it "should not render unsafe HTML when :labels[:#{field}] is false" do
|
124
124
|
# output_buffer.replace ''
|
125
125
|
# concat(semantic_form_for(@new_post) do |builder|
|
126
126
|
# concat(builder.input(:created_at, :as => :time, :include_seconds => true, :labels => { field => false }))
|
127
127
|
# end)
|
128
128
|
# output_buffer.should_not include(">")
|
129
129
|
# end
|
130
|
-
#
|
130
|
+
#
|
131
131
|
# end
|
132
132
|
# end
|
133
|
-
|
133
|
+
|
134
134
|
describe "when required" do
|
135
135
|
it "should add the required attribute to the input's html options" do
|
136
|
-
with_config :use_required_attribute, true do
|
136
|
+
with_config :use_required_attribute, true do
|
137
137
|
concat(semantic_form_for(@new_post) do |builder|
|
138
138
|
concat(builder.input(:title, :as => :date, :required => true))
|
139
139
|
end)
|
@@ -143,5 +143,71 @@ describe 'date input' do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
|
+
# We use text field for dates
|
148
|
+
|
149
|
+
# describe "when order does not include day" do
|
150
|
+
# before do
|
151
|
+
# output_buffer.replace ''
|
152
|
+
# concat(semantic_form_for(@new_post) do |builder|
|
153
|
+
# concat(builder.input(:publish_at, :as => :date, :order => [:year, :month]))
|
154
|
+
# end)
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# it "should include a hidden input for day" do
|
158
|
+
# output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(3i)]"][@value="1"]')
|
159
|
+
# end
|
160
|
+
#
|
161
|
+
# it "should not include a select for day" do
|
162
|
+
# output_buffer.should_not have_tag('select[@name="post[publish_at(3i)]"]')
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# describe "when order does not include month" do
|
167
|
+
# before do
|
168
|
+
# output_buffer.replace ''
|
169
|
+
# concat(semantic_form_for(@new_post) do |builder|
|
170
|
+
# concat(builder.input(:publish_at, :as => :date, :order => [:year, :day]))
|
171
|
+
# end)
|
172
|
+
# end
|
173
|
+
#
|
174
|
+
# it "should include a hidden input for month" do
|
175
|
+
# output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(2i)]"][@value="1"]')
|
176
|
+
# end
|
177
|
+
#
|
178
|
+
# it "should not include a select for month" do
|
179
|
+
# output_buffer.should_not have_tag('select[@name="post[publish_at(2i)]"]')
|
180
|
+
# end
|
181
|
+
# end
|
182
|
+
#
|
183
|
+
# describe "when order does not include year" do
|
184
|
+
# before do
|
185
|
+
# output_buffer.replace ''
|
186
|
+
# concat(semantic_form_for(@new_post) do |builder|
|
187
|
+
# concat(builder.input(:publish_at, :as => :date, :order => [:month, :day]))
|
188
|
+
# end)
|
189
|
+
# end
|
190
|
+
#
|
191
|
+
# it "should include a hidden input for month" do
|
192
|
+
# output_buffer.should have_tag("input[@type=\"hidden\"][@name=\"post[publish_at(1i)]\"][@value=\"#{Time.now.year}\"]")
|
193
|
+
# end
|
194
|
+
#
|
195
|
+
# it "should not include a select for month" do
|
196
|
+
# output_buffer.should_not have_tag('select[@name="post[publish_at(1i)]"]')
|
197
|
+
# end
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# describe "when order does not have year first" do
|
201
|
+
# before do
|
202
|
+
# output_buffer.replace ''
|
203
|
+
# concat(semantic_form_for(@new_post) do |builder|
|
204
|
+
# concat(builder.input(:publish_at, :as => :date, :order => [:day, :month, :year]))
|
205
|
+
# end)
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
# it 'should associate the legend label with the new first select' do
|
209
|
+
# output_buffer.should have_tag('form li.date fieldset legend.label label[@for="post_publish_at_3i"]')
|
210
|
+
# end
|
211
|
+
# end
|
212
|
+
|
147
213
|
end
|
@@ -8,7 +8,7 @@ describe 'datetime input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "general" do
|
@@ -21,8 +21,8 @@ describe 'datetime input' do
|
|
21
21
|
end)
|
22
22
|
end
|
23
23
|
|
24
|
-
it_should_have_input_wrapper_with_class("datetime")
|
25
|
-
it_should_have_input_wrapper_with_class(
|
24
|
+
it_should_have_input_wrapper_with_class("datetime-wrapper")
|
25
|
+
it_should_have_input_wrapper_with_class("control-group")
|
26
26
|
it_should_have_input_wrapper_with_class(:stringish) # Decide about this.
|
27
27
|
it_should_have_input_class_in_the_right_place
|
28
28
|
it_should_have_input_wrapper_with_id("post_publish_at_input")
|
@@ -30,9 +30,9 @@ describe 'datetime input' do
|
|
30
30
|
# it_should_have_a_nested_fieldset_with_class('fragments')
|
31
31
|
# it_should_have_a_nested_ordered_list_with_class('fragments-group')
|
32
32
|
it_should_apply_error_logic_for_input_type(:datetime)
|
33
|
-
|
33
|
+
|
34
34
|
it 'should have a legend and label with the label text inside the fieldset' do
|
35
|
-
output_buffer.should have_tag('form div.
|
35
|
+
output_buffer.should have_tag('form div.control-group.datetime-wrapper label.control-label', /Publish at/)
|
36
36
|
end
|
37
37
|
|
38
38
|
# it 'should associate the legend label with the first select' do
|
@@ -41,7 +41,7 @@ describe 'datetime input' do
|
|
41
41
|
# output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for]')
|
42
42
|
# output_buffer.should have_tag('form li.datetime fieldset legend.label label[@for="post_publish_at_1i"]')
|
43
43
|
# end
|
44
|
-
|
44
|
+
|
45
45
|
# it 'should have an ordered list of five items inside the fieldset' do
|
46
46
|
# output_buffer.should have_tag('form li.datetime fieldset ol.fragments-group')
|
47
47
|
# output_buffer.should have_tag('form li.datetime fieldset ol li.fragment', :count => 5)
|
@@ -55,26 +55,26 @@ describe 'datetime input' do
|
|
55
55
|
# output_buffer.should have_tag('form li.datetime fieldset ol li label', /hour/i)
|
56
56
|
# output_buffer.should have_tag('form li.datetime fieldset ol li label', /min/i)
|
57
57
|
# end
|
58
|
-
|
58
|
+
|
59
59
|
# it 'should have five selects' do
|
60
60
|
# output_buffer.should have_tag('form li.datetime fieldset ol li select', :count => 5)
|
61
61
|
# end
|
62
62
|
|
63
63
|
it 'should have two inputs' do
|
64
|
-
output_buffer.should have_tag('form div.
|
64
|
+
output_buffer.should have_tag('form div.control-group.datetime-wrapper div.controls input', :count => 2)
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "when namespace is provided" do
|
70
|
-
|
70
|
+
|
71
71
|
before do
|
72
72
|
output_buffer.replace ''
|
73
73
|
concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
|
74
74
|
concat(builder.input(:publish_at, :as => :datetime))
|
75
75
|
end)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
|
79
79
|
it_should_have_input_with_id("context2_post_publish_at[date]")
|
80
80
|
it_should_have_input_with_id("context2_post_publish_at[time]")
|
@@ -83,12 +83,12 @@ describe 'datetime input' do
|
|
83
83
|
# it_should_have_select_with_id("context2_post_publish_at_3i")
|
84
84
|
# it_should_have_select_with_id("context2_post_publish_at_4i")
|
85
85
|
# it_should_have_select_with_id("context2_post_publish_at_5i")
|
86
|
-
|
86
|
+
|
87
87
|
end
|
88
88
|
|
89
89
|
describe "when required" do
|
90
90
|
it "should add the required attribute to the input's html options" do
|
91
|
-
with_config :use_required_attribute, true do
|
91
|
+
with_config :use_required_attribute, true do
|
92
92
|
concat(semantic_form_for(@new_post) do |builder|
|
93
93
|
concat(builder.input(:title, :as => :datetime, :required => true))
|
94
94
|
end)
|
@@ -97,5 +97,5 @@ describe 'datetime input' do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
end
|
@@ -8,7 +8,7 @@ describe 'email input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "when object is provided" do
|
@@ -18,8 +18,8 @@ describe 'email input' do
|
|
18
18
|
end)
|
19
19
|
end
|
20
20
|
|
21
|
-
it_should_have_input_wrapper_with_class(
|
22
|
-
it_should_have_input_wrapper_with_class(
|
21
|
+
it_should_have_input_wrapper_with_class('email-wrapper')
|
22
|
+
it_should_have_input_wrapper_with_class("control-group")
|
23
23
|
it_should_have_input_wrapper_with_class(:stringish)
|
24
24
|
it_should_have_input_class_in_the_right_place
|
25
25
|
it_should_have_input_wrapper_with_id("post_email_input")
|
@@ -43,10 +43,38 @@ describe 'email input' do
|
|
43
43
|
it_should_have_label_and_input_with_id("context2_post_email")
|
44
44
|
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
|
+
describe "when index is provided" do
|
48
|
+
|
49
|
+
before do
|
50
|
+
@output_buffer = ''
|
51
|
+
mock_everything
|
52
|
+
|
53
|
+
concat(semantic_form_for(@new_post) do |builder|
|
54
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
55
|
+
concat(author.input(:name, :as => :email))
|
56
|
+
end)
|
57
|
+
end)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should index the id of the wrapper' do
|
61
|
+
output_buffer.should have_tag("div#post_author_attributes_3_name_input")
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should index the id of the select tag' do
|
65
|
+
output_buffer.should have_tag("input#post_author_attributes_3_name")
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should index the name of the select tag' do
|
69
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
47
75
|
describe "when required" do
|
48
76
|
it "should add the required attribute to the input's html options" do
|
49
|
-
with_config :use_required_attribute, true do
|
77
|
+
with_config :use_required_attribute, true do
|
50
78
|
concat(semantic_form_for(@new_post) do |builder|
|
51
79
|
concat(builder.input(:title, :as => :email, :required => true))
|
52
80
|
end)
|
@@ -54,6 +82,6 @@ describe 'email input' do
|
|
54
82
|
end
|
55
83
|
end
|
56
84
|
end
|
57
|
-
|
85
|
+
|
58
86
|
end
|
59
87
|
|
@@ -8,15 +8,15 @@ describe 'file input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
12
|
|
13
13
|
concat(semantic_form_for(@new_post) do |builder|
|
14
14
|
concat(builder.input(:body, :as => :file))
|
15
15
|
end)
|
16
16
|
end
|
17
17
|
|
18
|
-
it_should_have_input_wrapper_with_class("file")
|
19
|
-
it_should_have_input_wrapper_with_class(
|
18
|
+
it_should_have_input_wrapper_with_class("file-wrapper")
|
19
|
+
it_should_have_input_wrapper_with_class("control-group")
|
20
20
|
it_should_have_input_class_in_the_right_place
|
21
21
|
it_should_have_input_wrapper_with_id("post_body_input")
|
22
22
|
it_should_have_label_with_text(/Body/)
|
@@ -29,7 +29,7 @@ describe 'file input' do
|
|
29
29
|
concat(semantic_form_for(@new_post) do |builder|
|
30
30
|
concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
|
31
31
|
end)
|
32
|
-
output_buffer.should have_tag("form div.
|
32
|
+
output_buffer.should have_tag("form div.control-group div.controls input.myclass")
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "when namespace is provided" do
|
@@ -47,7 +47,35 @@ describe 'file input' do
|
|
47
47
|
it_should_have_label_and_input_with_id("context2_post_body")
|
48
48
|
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
describe "when index is provided" do
|
52
|
+
|
53
|
+
before do
|
54
|
+
@output_buffer = ''
|
55
|
+
mock_everything
|
56
|
+
|
57
|
+
concat(semantic_form_for(@new_post) do |builder|
|
58
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
59
|
+
concat(author.input(:name, :as => :file))
|
60
|
+
end)
|
61
|
+
end)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should index the id of the wrapper' do
|
65
|
+
output_buffer.should have_tag("div#post_author_attributes_3_name_input")
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should index the id of the select tag' do
|
69
|
+
output_buffer.should have_tag("input#post_author_attributes_3_name")
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should index the name of the select tag' do
|
73
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
51
79
|
context "when required" do
|
52
80
|
it "should add the required attribute to the input's html options" do
|
53
81
|
with_config :use_required_attribute, true do
|
@@ -58,6 +86,6 @@ describe 'file input' do
|
|
58
86
|
end
|
59
87
|
end
|
60
88
|
end
|
61
|
-
|
89
|
+
|
62
90
|
end
|
63
91
|
|
@@ -8,7 +8,7 @@ describe 'hidden input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
12
|
|
13
13
|
concat(semantic_form_for(@new_post) do |builder|
|
14
14
|
concat(builder.input(:secret, :as => :hidden))
|
@@ -19,37 +19,37 @@ describe 'hidden input' do
|
|
19
19
|
end)
|
20
20
|
end
|
21
21
|
|
22
|
-
it_should_have_input_wrapper_with_class("hidden")
|
23
|
-
it_should_have_input_wrapper_with_class(
|
22
|
+
it_should_have_input_wrapper_with_class("hidden-wrapper")
|
23
|
+
it_should_have_input_wrapper_with_class("control-group")
|
24
24
|
it_should_have_input_class_in_the_right_place
|
25
25
|
it_should_have_input_wrapper_with_id("post_secret_input")
|
26
26
|
it_should_not_have_a_label
|
27
27
|
|
28
28
|
it "should generate a input field" do
|
29
|
-
output_buffer.should have_tag("form div.
|
30
|
-
output_buffer.should have_tag("form div.
|
31
|
-
output_buffer.should have_tag("form div.
|
29
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_secret")
|
30
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@type=\"hidden\"]")
|
31
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@name=\"post[secret]\"]")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should get value from the object" do
|
35
|
-
output_buffer.should have_tag("form div.
|
35
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_secret[@type=\"hidden\"][@value=\"1\"]")
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should pass any explicitly specified value - using :value" do
|
39
|
-
output_buffer.should have_tag("form div.
|
39
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_author_id[@type=\"hidden\"][@value=\"99\"]")
|
40
40
|
end
|
41
41
|
|
42
42
|
# Handle Formtastic :input_html options for consistency.
|
43
43
|
it "should pass any explicitly specified value - using :input_html options" do
|
44
|
-
output_buffer.should have_tag("form div.
|
44
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_published[@type=\"hidden\"][@value=\"true\"]")
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should pass any option specified using :input_html" do
|
48
|
-
output_buffer.should have_tag("form div.
|
48
|
+
output_buffer.should have_tag("form div.control-group div.controls input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should prefer :input_html over directly supplied options" do
|
52
|
-
output_buffer.should have_tag("form div.
|
52
|
+
output_buffer.should have_tag("form div.control-group div.controls input#post_author_id[@type=\"hidden\"][@value=\"formtastic_value\"]")
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should not render inline errors" do
|
@@ -99,7 +99,35 @@ describe 'hidden input' do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
|
+
describe "when index is provided" do
|
104
|
+
|
105
|
+
before do
|
106
|
+
@output_buffer = ''
|
107
|
+
mock_everything
|
108
|
+
|
109
|
+
concat(semantic_form_for(@new_post) do |builder|
|
110
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
111
|
+
concat(author.input(:name, :as => :hidden))
|
112
|
+
end)
|
113
|
+
end)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should index the id of the wrapper' do
|
117
|
+
output_buffer.should have_tag("div#post_author_attributes_3_name_input")
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should index the id of the select tag' do
|
121
|
+
output_buffer.should have_tag("input#post_author_attributes_3_name")
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should index the name of the select tag' do
|
125
|
+
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
|
103
131
|
context "when required" do
|
104
132
|
it "should not add the required attribute to the input's html options" do
|
105
133
|
concat(semantic_form_for(@new_post) do |builder|
|