speedo-formstrap 1.2.0 → 1.2.1
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.
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +1 -1
- data/lib/formtastic-bootstrap.rb +5 -5
- data/lib/formtastic-bootstrap/actions.rb +4 -4
- data/lib/formtastic-bootstrap/actions/base.rb +1 -1
- data/lib/formtastic-bootstrap/actions/button_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/input_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/link_action.rb +1 -1
- data/lib/formtastic-bootstrap/engine.rb +1 -1
- data/lib/formtastic-bootstrap/form_builder.rb +9 -11
- data/lib/formtastic-bootstrap/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +10 -14
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +7 -12
- data/lib/formtastic-bootstrap/helpers/input_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +6 -6
- data/lib/formtastic-bootstrap/inputs.rb +21 -21
- data/lib/formtastic-bootstrap/inputs/base.rb +10 -11
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +24 -13
- data/lib/formtastic-bootstrap/inputs/base/errors.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/html.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +7 -17
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +13 -6
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +15 -33
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/date_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -14
- data/lib/formtastic-bootstrap/inputs/range_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/select_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/string_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
- data/spec/actions/button_action_spec.rb +1 -1
- data/spec/actions/generic_action_spec.rb +1 -1
- data/spec/actions/input_action_spec.rb +1 -1
- data/spec/actions/link_action_spec.rb +1 -1
- data/spec/builder/semantic_fields_for_spec.rb +16 -16
- data/spec/helpers/action_helper_spec.rb +1 -1
- data/spec/helpers/actions_helper_spec.rb +1 -1
- data/spec/helpers/buttons_helper_spec.rb +46 -56
- data/spec/helpers/input_helper_spec.rb +209 -209
- data/spec/helpers/inputs_helper_spec.rb +103 -117
- data/spec/inputs/boolean_input_spec.rb +46 -74
- data/spec/inputs/check_boxes_input_spec.rb +82 -110
- data/spec/inputs/date_input_spec.rb +15 -81
- data/spec/inputs/datetime_input_spec.rb +13 -13
- data/spec/inputs/email_input_spec.rb +6 -34
- data/spec/inputs/file_input_spec.rb +6 -34
- data/spec/inputs/hidden_input_spec.rb +13 -41
- data/spec/inputs/number_input_spec.rb +97 -127
- data/spec/inputs/password_input_spec.rb +6 -34
- data/spec/inputs/phone_input_spec.rb +6 -34
- data/spec/inputs/radio_input_spec.rb +45 -73
- data/spec/inputs/range_input_spec.rb +66 -94
- data/spec/inputs/search_input_spec.rb +6 -33
- data/spec/inputs/select_input_spec.rb +78 -124
- data/spec/inputs/string_input_spec.rb +22 -67
- data/spec/inputs/text_input_spec.rb +15 -42
- 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 +6 -34
- data/spec/support/custom_macros.rb +196 -67
- data/spec/support/formtastic_spec_helper.rb +6 -22
- data/speedo-formstrap.gemspec +146 -0
- metadata +18 -17
@@ -8,7 +8,7 @@ describe 'search input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "when object is provided" do
|
@@ -18,8 +18,8 @@ describe 'search 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(:search)
|
22
|
+
it_should_have_input_wrapper_with_class(:clearfix)
|
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_search_input")
|
@@ -43,37 +43,10 @@ describe 'search input' do
|
|
43
43
|
it_should_have_label_and_input_with_id("context2_post_search")
|
44
44
|
|
45
45
|
end
|
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 => :search))
|
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
|
-
|
46
|
+
|
74
47
|
describe "when required" do
|
75
48
|
it "should add the required attribute to the input's html options" do
|
76
|
-
with_config :use_required_attribute, true do
|
49
|
+
with_config :use_required_attribute, true do
|
77
50
|
concat(semantic_form_for(@new_post) do |builder|
|
78
51
|
concat(builder.input(:title, :as => :search, :required => true))
|
79
52
|
end)
|
@@ -81,6 +54,6 @@ describe 'search input' do
|
|
81
54
|
end
|
82
55
|
end
|
83
56
|
end
|
84
|
-
|
57
|
+
|
85
58
|
end
|
86
59
|
|
@@ -8,7 +8,7 @@ describe 'select input' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'explicit values' do
|
@@ -24,10 +24,10 @@ describe 'select input' do
|
|
24
24
|
|
25
25
|
it 'should have a option for each key and/or value' do
|
26
26
|
@array_with_values.each do |v|
|
27
|
-
output_buffer.should have_tag("form div.
|
27
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{v}']", /^#{v}$/)
|
28
28
|
end
|
29
29
|
@array_with_keys_and_values.each do |v|
|
30
|
-
output_buffer.should have_tag("form div.
|
30
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{v.second}']", /^#{v.first}$/)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -41,9 +41,9 @@ describe 'select input' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should draw select options' do
|
44
|
-
output_buffer.should have_tag('form div.
|
45
|
-
output_buffer.should have_tag('form div.
|
46
|
-
output_buffer.should_not have_tag('form div.
|
44
|
+
output_buffer.should have_tag('form div.clearfix div.input select')
|
45
|
+
output_buffer.should have_tag('form div.clearfix div.input select#post_reviewer_id')
|
46
|
+
output_buffer.should_not have_tag('form div.clearfix div.input select#post_mongoid_reviewer_id')
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -57,7 +57,7 @@ describe 'select input' do
|
|
57
57
|
|
58
58
|
it 'should have an option for each value' do
|
59
59
|
@range_with_values.each do |v|
|
60
|
-
output_buffer.should have_tag("form div.
|
60
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{v}']", /^#{v}$/)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -72,20 +72,10 @@ describe 'select input' do
|
|
72
72
|
|
73
73
|
it 'should render select options using provided HTML string' do
|
74
74
|
2.times do |v|
|
75
|
-
output_buffer.should have_tag("form div.
|
75
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{v}']", /^#{v}$/)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
describe 'using a nil name' do
|
81
|
-
before do
|
82
|
-
concat(semantic_form_for(@new_post) do |builder|
|
83
|
-
concat(builder.input(:title, :as => :select, :collection => [], :input_html => {:name => nil}))
|
84
|
-
end)
|
85
|
-
end
|
86
|
-
|
87
|
-
it_should_have_select_with_name("post[title]")
|
88
|
-
end
|
89
79
|
end
|
90
80
|
|
91
81
|
describe 'for boolean columns' do
|
@@ -94,20 +84,19 @@ describe 'select input' do
|
|
94
84
|
# # Note: Works, but something like Formtastic.root.join(...) would probably be "safer".
|
95
85
|
# ::I18n.load_path = [File.join(File.dirname(__FILE__), *%w[.. .. lib locale en.yml])]
|
96
86
|
# ::I18n.backend.send(:init_translations)
|
97
|
-
#
|
87
|
+
#
|
98
88
|
# concat(semantic_form_for(@new_post) do |builder|
|
99
89
|
# concat(builder.input(:published, :as => :select))
|
100
90
|
# end)
|
101
91
|
# end
|
102
|
-
#
|
92
|
+
#
|
103
93
|
# after do
|
104
|
-
# ::I18n.load_path = []
|
105
94
|
# ::I18n.backend.store_translations :en, {}
|
106
95
|
# end
|
107
|
-
#
|
96
|
+
#
|
108
97
|
# it 'should render a select with at least options: true/false' do
|
109
|
-
# output_buffer.should have_tag("form div.
|
110
|
-
# output_buffer.should have_tag("form div.
|
98
|
+
# output_buffer.should have_tag("form div.clearfix div.input select option[@value='true']", /^Yes$/)
|
99
|
+
# output_buffer.should have_tag("form div.clearfix div.input select option[@value='false']", /^No$/)
|
111
100
|
# end
|
112
101
|
# end
|
113
102
|
|
@@ -126,8 +115,8 @@ describe 'select input' do
|
|
126
115
|
end
|
127
116
|
|
128
117
|
it 'should render a select with at least options: true/false' do
|
129
|
-
output_buffer.should have_tag("form div.
|
130
|
-
output_buffer.should have_tag("form div.
|
118
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='true']", /#{@boolean_select_labels[:yes]}/)
|
119
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='false']", /#{@boolean_select_labels[:no]}/)
|
131
120
|
end
|
132
121
|
end
|
133
122
|
end
|
@@ -140,8 +129,8 @@ describe 'select input' do
|
|
140
129
|
end)
|
141
130
|
end
|
142
131
|
|
143
|
-
it_should_have_input_wrapper_with_class("select
|
144
|
-
it_should_have_input_wrapper_with_class(
|
132
|
+
it_should_have_input_wrapper_with_class("select")
|
133
|
+
it_should_have_input_wrapper_with_class(:clearfix)
|
145
134
|
it_should_have_input_class_in_the_right_place
|
146
135
|
it_should_have_input_wrapper_with_id("post_author_input")
|
147
136
|
it_should_have_label_with_text(/Author/)
|
@@ -151,42 +140,38 @@ describe 'select input' do
|
|
151
140
|
it_should_use_the_collection_when_provided(:select, 'option')
|
152
141
|
|
153
142
|
it 'should have a select inside the wrapper' do
|
154
|
-
output_buffer.should have_tag('form div.
|
155
|
-
output_buffer.should have_tag('form div.
|
156
|
-
output_buffer.should have_tag('form div.
|
143
|
+
output_buffer.should have_tag('form div.clearfix div.input select')
|
144
|
+
output_buffer.should have_tag('form div.clearfix div.input select#post_author_id')
|
145
|
+
output_buffer.should have_tag('form div.clearfix div.input select#post_reviewer_id')
|
157
146
|
end
|
158
147
|
|
159
148
|
it 'should have a valid name' do
|
160
|
-
output_buffer.should have_tag("form div.
|
161
|
-
output_buffer.should_not have_tag("form div.
|
162
|
-
output_buffer.should_not have_tag("form div.
|
149
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@name='post[author_id]']")
|
150
|
+
output_buffer.should_not have_tag("form div.clearfix div.input select[@name='post[author_id][]']")
|
151
|
+
output_buffer.should_not have_tag("form div.clearfix div.input select[@name='post[reviewer_id][]']")
|
163
152
|
end
|
164
153
|
|
165
154
|
it 'should not create a multi-select' do
|
166
|
-
output_buffer.should_not have_tag('form div.
|
167
|
-
end
|
168
|
-
|
169
|
-
it 'should not add a hidden input' do
|
170
|
-
output_buffer.should_not have_tag("form div.control-group div.controls input[@type='hidden']")
|
155
|
+
output_buffer.should_not have_tag('form div.clearfix div.input select[@multiple]')
|
171
156
|
end
|
172
157
|
|
173
158
|
it 'should create a select without size' do
|
174
|
-
output_buffer.should_not have_tag('form div.
|
159
|
+
output_buffer.should_not have_tag('form div.clearfix div.input select[@size]')
|
175
160
|
end
|
176
161
|
|
177
162
|
it 'should have a blank option' do
|
178
|
-
output_buffer.should have_tag("form div.
|
163
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']")
|
179
164
|
end
|
180
165
|
|
181
166
|
it 'should have a select option for each Author' do
|
182
|
-
output_buffer.should have_tag("form div.
|
167
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@name='post[author_id]'] option", :count => ::Author.all.size + 1)
|
183
168
|
::Author.all.each do |author|
|
184
|
-
output_buffer.should have_tag("form div.
|
169
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{author.id}']", /#{author.to_label}/)
|
185
170
|
end
|
186
171
|
end
|
187
172
|
|
188
173
|
it 'should have one option with a "selected" attribute (bob)' do
|
189
|
-
output_buffer.should have_tag("form div.
|
174
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@name='post[author_id]'] option[@selected]", :count => 1)
|
190
175
|
end
|
191
176
|
|
192
177
|
it 'should not singularize the association name' do
|
@@ -198,7 +183,7 @@ describe 'select input' do
|
|
198
183
|
concat(builder.input(:author_status, :as => :select))
|
199
184
|
end)
|
200
185
|
|
201
|
-
output_buffer.should have_tag('form div.
|
186
|
+
output_buffer.should have_tag('form div.clearfix div.input select#post_author_status_id')
|
202
187
|
end
|
203
188
|
end
|
204
189
|
|
@@ -268,7 +253,7 @@ describe 'select input' do
|
|
268
253
|
end)
|
269
254
|
end
|
270
255
|
|
271
|
-
it_should_have_input_wrapper_with_class("select
|
256
|
+
it_should_have_input_wrapper_with_class("select")
|
272
257
|
it_should_have_input_wrapper_with_id("post_author_input")
|
273
258
|
it_should_have_label_with_text(/Author/)
|
274
259
|
it_should_have_label_for('post_author_id')
|
@@ -277,29 +262,29 @@ describe 'select input' do
|
|
277
262
|
|
278
263
|
0.upto(1) do |i|
|
279
264
|
it 'should have all option groups and the right values' do
|
280
|
-
output_buffer.should have_tag("form div.
|
265
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{@continent_names[i]}']", @authors[i].to_label)
|
281
266
|
end
|
282
267
|
|
283
268
|
it 'should have custom group labels' do
|
284
|
-
output_buffer.should have_tag("form div.
|
269
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{@continents[i].id}']", @authors[i].to_label)
|
285
270
|
end
|
286
271
|
|
287
272
|
it 'should have custom author labels' do
|
288
|
-
output_buffer.should have_tag("form div.
|
273
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{@continent_names[i]}']", @authors[i].login)
|
289
274
|
end
|
290
275
|
|
291
276
|
it 'should have custom author and group labels' do
|
292
|
-
output_buffer.should have_tag("form div.
|
277
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{@continents[i].id}']", @authors[i].login)
|
293
278
|
end
|
294
279
|
end
|
295
280
|
|
296
281
|
it 'should have no duplicate groups' do
|
297
|
-
output_buffer.should have_tag('form div.
|
282
|
+
output_buffer.should have_tag('form div.clearfix div.input select optgroup', :count => 8)
|
298
283
|
end
|
299
284
|
|
300
285
|
it 'should sort the groups on the label method' do
|
301
|
-
output_buffer.should have_tag("form div.
|
302
|
-
output_buffer.should have_tag("form div.
|
286
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='Africa']")
|
287
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='99']")
|
303
288
|
end
|
304
289
|
|
305
290
|
it 'should call find with :include for more optimized queries' do
|
@@ -318,7 +303,7 @@ describe 'select input' do
|
|
318
303
|
end)
|
319
304
|
end
|
320
305
|
|
321
|
-
it_should_have_input_wrapper_with_class("select
|
306
|
+
it_should_have_input_wrapper_with_class("select")
|
322
307
|
it_should_have_input_wrapper_with_id("author_posts_input")
|
323
308
|
it_should_have_label_with_text(/Post/)
|
324
309
|
it_should_have_label_for('author_post_ids')
|
@@ -327,31 +312,27 @@ describe 'select input' do
|
|
327
312
|
it_should_use_the_collection_when_provided(:select, 'option')
|
328
313
|
|
329
314
|
it 'should have a select inside the wrapper' do
|
330
|
-
output_buffer.should have_tag('form div.
|
331
|
-
output_buffer.should have_tag('form div.
|
315
|
+
output_buffer.should have_tag('form div.clearfix div.input select')
|
316
|
+
output_buffer.should have_tag('form div.clearfix div.input select#author_post_ids')
|
332
317
|
end
|
333
318
|
|
334
319
|
it 'should have a multi-select select' do
|
335
|
-
output_buffer.should have_tag('form div.
|
320
|
+
output_buffer.should have_tag('form div.clearfix div.input select[@multiple="multiple"]')
|
336
321
|
end
|
337
322
|
|
338
323
|
it 'should append [] to the name attribute for multiple select' do
|
339
|
-
output_buffer.should have_tag('form div.
|
340
|
-
end
|
341
|
-
|
342
|
-
it 'should have a hidden field' do
|
343
|
-
output_buffer.should have_tag('form div.control-group div.controls input[@type="hidden"][@name="author[post_ids][]"]')
|
324
|
+
output_buffer.should have_tag('form div.clearfix div.input select[@multiple="multiple"][@name="author[post_ids][]"]')
|
344
325
|
end
|
345
326
|
|
346
327
|
it 'should have a select option for each Post' do
|
347
|
-
output_buffer.should have_tag('form div.
|
328
|
+
output_buffer.should have_tag('form div.clearfix div.input select option', :count => ::Post.all.size)
|
348
329
|
::Post.all.each do |post|
|
349
|
-
output_buffer.should have_tag("form div.
|
330
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{post.id}']", /#{post.to_label}/)
|
350
331
|
end
|
351
332
|
end
|
352
333
|
|
353
334
|
it 'should not have a blank option by default' do
|
354
|
-
output_buffer.should_not have_tag("form div.
|
335
|
+
output_buffer.should_not have_tag("form div.clearfix div.input select option[@value='']")
|
355
336
|
end
|
356
337
|
|
357
338
|
it 'should respect the :include_blank option for single selects' do
|
@@ -359,7 +340,7 @@ describe 'select input' do
|
|
359
340
|
concat(builder.input(:posts, :as => :select, :multiple => false, :include_blank => true))
|
360
341
|
end)
|
361
342
|
|
362
|
-
output_buffer.should have_tag("form div.
|
343
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']")
|
363
344
|
end
|
364
345
|
|
365
346
|
it 'should respect the :include_blank option for multiple selects' do
|
@@ -367,11 +348,11 @@ describe 'select input' do
|
|
367
348
|
concat(builder.input(:posts, :as => :select, :multiple => true, :include_blank => true))
|
368
349
|
end)
|
369
350
|
|
370
|
-
output_buffer.should have_tag("form div.
|
351
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']")
|
371
352
|
end
|
372
353
|
|
373
354
|
it 'should have one option with a "selected" attribute' do
|
374
|
-
output_buffer.should have_tag('form div.
|
355
|
+
output_buffer.should have_tag('form div.clearfix div.input select option[@selected]', :count => 1)
|
375
356
|
end
|
376
357
|
end
|
377
358
|
|
@@ -382,7 +363,7 @@ describe 'select input' do
|
|
382
363
|
end)
|
383
364
|
end
|
384
365
|
|
385
|
-
it_should_have_input_wrapper_with_class("select
|
366
|
+
it_should_have_input_wrapper_with_class("select")
|
386
367
|
it_should_have_input_wrapper_with_id("post_authors_input")
|
387
368
|
it_should_have_label_with_text(/Author/)
|
388
369
|
it_should_have_label_for('post_author_ids')
|
@@ -391,23 +372,23 @@ describe 'select input' do
|
|
391
372
|
it_should_use_the_collection_when_provided(:select, 'option')
|
392
373
|
|
393
374
|
it 'should have a select inside the wrapper' do
|
394
|
-
output_buffer.should have_tag('form div.
|
395
|
-
output_buffer.should have_tag('form div.
|
375
|
+
output_buffer.should have_tag('form div.clearfix div.input select')
|
376
|
+
output_buffer.should have_tag('form div.clearfix div.input select#post_author_ids')
|
396
377
|
end
|
397
378
|
|
398
379
|
it 'should have a multi-select select' do
|
399
|
-
output_buffer.should have_tag('form div.
|
380
|
+
output_buffer.should have_tag('form div.clearfix div.input select[@multiple="multiple"]')
|
400
381
|
end
|
401
382
|
|
402
383
|
it 'should have a select option for each Author' do
|
403
|
-
output_buffer.should have_tag('form div.
|
384
|
+
output_buffer.should have_tag('form div.clearfix div.input select option', :count => ::Author.all.size)
|
404
385
|
::Author.all.each do |author|
|
405
|
-
output_buffer.should have_tag("form div.
|
386
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{author.id}']", /#{author.to_label}/)
|
406
387
|
end
|
407
388
|
end
|
408
389
|
|
409
390
|
it 'should not have a blank option by default' do
|
410
|
-
output_buffer.should_not have_tag("form div.
|
391
|
+
output_buffer.should_not have_tag("form div.clearfix div.input select option[@value='']")
|
411
392
|
end
|
412
393
|
|
413
394
|
it 'should respect the :include_blank option for single selects' do
|
@@ -415,7 +396,7 @@ describe 'select input' do
|
|
415
396
|
concat(builder.input(:authors, :as => :select, :multiple => false, :include_blank => true))
|
416
397
|
end)
|
417
398
|
|
418
|
-
output_buffer.should have_tag("form div.
|
399
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']")
|
419
400
|
end
|
420
401
|
|
421
402
|
it 'should respect the :include_blank option for multiple selects' do
|
@@ -423,11 +404,11 @@ describe 'select input' do
|
|
423
404
|
concat(builder.input(:authors, :as => :select, :multiple => true, :include_blank => true))
|
424
405
|
end)
|
425
406
|
|
426
|
-
output_buffer.should have_tag("form div.
|
407
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']")
|
427
408
|
end
|
428
409
|
|
429
410
|
it 'should have one option with a "selected" attribute' do
|
430
|
-
output_buffer.should have_tag('form div.
|
411
|
+
output_buffer.should have_tag('form div.clearfix div.input select option[@selected]', :count => 1)
|
431
412
|
end
|
432
413
|
end
|
433
414
|
|
@@ -440,11 +421,11 @@ describe 'select input' do
|
|
440
421
|
end
|
441
422
|
|
442
423
|
it 'should have a select with prompt' do
|
443
|
-
output_buffer.should have_tag("form div.
|
424
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='']", /choose author/, :count => 1)
|
444
425
|
end
|
445
426
|
|
446
|
-
it 'should not have a
|
447
|
-
output_buffer.
|
427
|
+
it 'should not have a blank select option' do
|
428
|
+
output_buffer.should_not have_tag("form div.clearfix div.input select option[@value='']", "")
|
448
429
|
end
|
449
430
|
end
|
450
431
|
|
@@ -456,18 +437,18 @@ describe 'select input' do
|
|
456
437
|
end
|
457
438
|
|
458
439
|
it 'should generate label' do
|
459
|
-
output_buffer.should have_tag('form div.
|
460
|
-
output_buffer.should have_tag("form div.
|
440
|
+
output_buffer.should have_tag('form div.clearfix label', /Author/)
|
441
|
+
output_buffer.should have_tag("form div.clearfix label[@for='project_author']")
|
461
442
|
end
|
462
443
|
|
463
444
|
it 'should generate select inputs' do
|
464
|
-
output_buffer.should have_tag('form div.
|
465
|
-
output_buffer.should have_tag('form div.
|
445
|
+
output_buffer.should have_tag('form div.clearfix div.input select#project_author')
|
446
|
+
output_buffer.should have_tag('form div.clearfix div.input select option', :count => ::Author.all.size + 1)
|
466
447
|
end
|
467
448
|
|
468
449
|
it 'should generate an option to each item' do
|
469
450
|
::Author.all.each do |author|
|
470
|
-
output_buffer.should have_tag("form div.
|
451
|
+
output_buffer.should have_tag("form div.clearfix div.input select option[@value='#{author.id}']", /#{author.to_label}/)
|
471
452
|
end
|
472
453
|
end
|
473
454
|
end
|
@@ -478,27 +459,27 @@ describe 'select input' do
|
|
478
459
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
479
460
|
concat(builder.input(:author_name, :as => :select, :collection => ::Author.all))
|
480
461
|
end)
|
481
|
-
output_buffer.should have_tag("form div.
|
462
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@name='project[author_name]']")
|
482
463
|
end
|
483
|
-
|
464
|
+
|
484
465
|
describe 'and :multiple is set to true through :input_html' do
|
485
466
|
it "should make the select a multi-select" do
|
486
467
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
487
468
|
concat(builder.input(:author_name, :as => :select, :input_html => {:multiple => true} ))
|
488
469
|
end)
|
489
|
-
output_buffer.should have_tag("form div.
|
470
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@multiple]")
|
490
471
|
end
|
491
472
|
end
|
492
|
-
|
473
|
+
|
493
474
|
describe 'and :multiple is set to true' do
|
494
475
|
it "should make the select a multi-select" do
|
495
476
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
496
477
|
concat(builder.input(:author_name, :as => :select, :multiple => true, :collection => ["Fred", "Bob"]))
|
497
478
|
end)
|
498
|
-
output_buffer.should have_tag("form div.
|
479
|
+
output_buffer.should have_tag("form div.clearfix div.input select[@multiple]")
|
499
480
|
end
|
500
481
|
end
|
501
|
-
|
482
|
+
|
502
483
|
end
|
503
484
|
|
504
485
|
describe 'when a grouped collection collection is given' do
|
@@ -513,12 +494,12 @@ describe 'select input' do
|
|
513
494
|
|
514
495
|
it 'should generate an option to each item' do
|
515
496
|
@grouped_opts.each do |opt_pair|
|
516
|
-
output_buffer.should have_tag("form div.
|
497
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{opt_pair[0]}']")
|
517
498
|
opt_pair[1].each do |v|
|
518
|
-
output_buffer.should have_tag("form div.
|
499
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup[@label='#{opt_pair[0]}'] option[@value='#{v}']")
|
519
500
|
end
|
520
501
|
end
|
521
|
-
output_buffer.should have_tag("form div.
|
502
|
+
output_buffer.should have_tag("form div.clearfix div.input select optgroup option[@selected]","hands")
|
522
503
|
end
|
523
504
|
end
|
524
505
|
|
@@ -540,7 +521,7 @@ describe 'select input' do
|
|
540
521
|
end
|
541
522
|
|
542
523
|
it "should render a select field" do
|
543
|
-
output_buffer.should have_tag("form div.
|
524
|
+
output_buffer.should have_tag("form div.clearfix div.input select", :count => 2)
|
544
525
|
end
|
545
526
|
end
|
546
527
|
|
@@ -556,7 +537,7 @@ describe 'select input' do
|
|
556
537
|
end
|
557
538
|
|
558
539
|
it "should render a text field" do
|
559
|
-
output_buffer.should have_tag("form div.
|
540
|
+
output_buffer.should have_tag("form div.clearfix div.input input[@type='text']", :count => 2)
|
560
541
|
end
|
561
542
|
end
|
562
543
|
end
|
@@ -572,33 +553,6 @@ describe 'select input' do
|
|
572
553
|
it_should_have_label_for("context2_post_author_ids")
|
573
554
|
end
|
574
555
|
|
575
|
-
describe "when index is provided" do
|
576
|
-
|
577
|
-
before do
|
578
|
-
@output_buffer = ''
|
579
|
-
mock_everything
|
580
|
-
|
581
|
-
concat(semantic_form_for(@new_post) do |builder|
|
582
|
-
concat(builder.fields_for(:author, :index => 3) do |author|
|
583
|
-
concat(author.input(:name, :as => :select))
|
584
|
-
end)
|
585
|
-
end)
|
586
|
-
end
|
587
|
-
|
588
|
-
it 'should index the id of the wrapper' do
|
589
|
-
output_buffer.should have_tag("div#post_author_attributes_3_name_input")
|
590
|
-
end
|
591
|
-
|
592
|
-
it 'should index the id of the select tag' do
|
593
|
-
output_buffer.should have_tag("select#post_author_attributes_3_name")
|
594
|
-
end
|
595
|
-
|
596
|
-
it 'should index the name of the select' do
|
597
|
-
output_buffer.should have_tag("select[@name='post[author_attributes][3][name]']")
|
598
|
-
end
|
599
|
-
|
600
|
-
end
|
601
|
-
|
602
556
|
context "when required" do
|
603
557
|
it "should add the required attribute to the select's html options" do
|
604
558
|
with_config :use_required_attribute, true do
|