formtastic-bootstrap 2.0.0 → 2.1.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.
Files changed (89) hide show
  1. data/README.md +11 -2
  2. data/VERSION +1 -1
  3. data/vendor/assets/stylesheets/formtastic-bootstrap.css +4 -0
  4. metadata +51 -154
  5. data/.rspec +0 -1
  6. data/Gemfile +0 -14
  7. data/Gemfile.lock +0 -131
  8. data/Rakefile +0 -49
  9. data/formtastic-bootstrap.gemspec +0 -166
  10. data/lib/action_view/helpers/text_field_date_helper.rb +0 -166
  11. data/lib/formtastic-bootstrap/actions.rb +0 -10
  12. data/lib/formtastic-bootstrap/actions/base.rb +0 -22
  13. data/lib/formtastic-bootstrap/actions/button_action.rb +0 -13
  14. data/lib/formtastic-bootstrap/actions/input_action.rb +0 -13
  15. data/lib/formtastic-bootstrap/actions/link_action.rb +0 -12
  16. data/lib/formtastic-bootstrap/engine.rb +0 -4
  17. data/lib/formtastic-bootstrap/form_builder.rb +0 -40
  18. data/lib/formtastic-bootstrap/helpers.rb +0 -17
  19. data/lib/formtastic-bootstrap/helpers/action_helper.rb +0 -12
  20. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +0 -24
  21. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +0 -35
  22. data/lib/formtastic-bootstrap/helpers/input_helper.rb +0 -12
  23. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -34
  24. data/lib/formtastic-bootstrap/inputs.rb +0 -36
  25. data/lib/formtastic-bootstrap/inputs/base.rb +0 -45
  26. data/lib/formtastic-bootstrap/inputs/base/choices.rb +0 -20
  27. data/lib/formtastic-bootstrap/inputs/base/collections.rb +0 -9
  28. data/lib/formtastic-bootstrap/inputs/base/errors.rb +0 -48
  29. data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +0 -9
  30. data/lib/formtastic-bootstrap/inputs/base/hints.rb +0 -27
  31. data/lib/formtastic-bootstrap/inputs/base/html.rb +0 -21
  32. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +0 -29
  33. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +0 -9
  34. data/lib/formtastic-bootstrap/inputs/base/stringish.rb +0 -17
  35. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +0 -55
  36. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +0 -55
  37. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +0 -29
  38. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +0 -40
  39. data/lib/formtastic-bootstrap/inputs/date_input.rb +0 -10
  40. data/lib/formtastic-bootstrap/inputs/date_select_input.rb +0 -8
  41. data/lib/formtastic-bootstrap/inputs/datetime_input.rb +0 -10
  42. data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +0 -8
  43. data/lib/formtastic-bootstrap/inputs/email_input.rb +0 -15
  44. data/lib/formtastic-bootstrap/inputs/file_input.rb +0 -14
  45. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +0 -12
  46. data/lib/formtastic-bootstrap/inputs/number_input.rb +0 -15
  47. data/lib/formtastic-bootstrap/inputs/password_input.rb +0 -15
  48. data/lib/formtastic-bootstrap/inputs/phone_input.rb +0 -15
  49. data/lib/formtastic-bootstrap/inputs/radio_input.rb +0 -46
  50. data/lib/formtastic-bootstrap/inputs/range_input.rb +0 -15
  51. data/lib/formtastic-bootstrap/inputs/search_input.rb +0 -15
  52. data/lib/formtastic-bootstrap/inputs/select_input.rb +0 -16
  53. data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -8
  54. data/lib/formtastic-bootstrap/inputs/text_input.rb +0 -14
  55. data/lib/formtastic-bootstrap/inputs/time_input.rb +0 -10
  56. data/lib/formtastic-bootstrap/inputs/time_select_input.rb +0 -8
  57. data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +0 -14
  58. data/lib/formtastic-bootstrap/inputs/url_input.rb +0 -14
  59. data/spec/actions/button_action_spec.rb +0 -63
  60. data/spec/actions/input_action_spec.rb +0 -59
  61. data/spec/actions/link_action_spec.rb +0 -92
  62. data/spec/builder/semantic_fields_for_spec.rb +0 -130
  63. data/spec/helpers/action_helper_spec.rb +0 -368
  64. data/spec/helpers/actions_helper_spec.rb +0 -147
  65. data/spec/helpers/input_helper_spec.rb +0 -935
  66. data/spec/helpers/inputs_helper_spec.rb +0 -636
  67. data/spec/inputs/boolean_input_spec.rb +0 -226
  68. data/spec/inputs/check_boxes_input_spec.rb +0 -454
  69. data/spec/inputs/date_select_input_spec.rb +0 -164
  70. data/spec/inputs/datetime_select_input_spec.rb +0 -112
  71. data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +0 -48
  72. data/spec/inputs/email_input_spec.rb +0 -86
  73. data/spec/inputs/file_input_spec.rb +0 -90
  74. data/spec/inputs/hidden_input_spec.rb +0 -153
  75. data/spec/inputs/number_input_spec.rb +0 -816
  76. data/spec/inputs/password_input_spec.rb +0 -100
  77. data/spec/inputs/phone_input_spec.rb +0 -86
  78. data/spec/inputs/radio_input_spec.rb +0 -267
  79. data/spec/inputs/range_input_spec.rb +0 -506
  80. data/spec/inputs/search_input_spec.rb +0 -85
  81. data/spec/inputs/select_input_spec.rb +0 -624
  82. data/spec/inputs/string_input_spec.rb +0 -210
  83. data/spec/inputs/text_input_spec.rb +0 -188
  84. data/spec/inputs/time_select_input_spec.rb +0 -191
  85. data/spec/inputs/time_zone_input_spec.rb +0 -118
  86. data/spec/inputs/url_input_spec.rb +0 -86
  87. data/spec/spec_helper.rb +0 -30
  88. data/spec/support/custom_macros.rb +0 -537
  89. data/spec/support/fb_custom_macros.rb +0 -23
@@ -1,210 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'string input' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- describe "when object is provided" do
14
- before do
15
- concat(semantic_form_for(@new_post) do |builder|
16
- concat(builder.input(:title, :as => :string))
17
- end)
18
- end
19
-
20
- it_should_have_bootstrap_horizontal_wrapping
21
- it_should_have_input_wrapper_with_class(:string)
22
- it_should_have_input_wrapper_with_class(:input)
23
- it_should_have_input_wrapper_with_class(:stringish)
24
- it_should_have_input_wrapper_with_id("post_title_input")
25
- it_should_have_label_with_text(/Title/)
26
- it_should_have_label_for("post_title")
27
- it_should_have_input_with_id("post_title")
28
- it_should_have_input_with_type(:text)
29
- it_should_have_input_with_name("post[title]")
30
- it_should_have_maxlength_matching_column_limit
31
- it_should_use_default_text_field_size_when_not_nil(:string)
32
- it_should_not_use_default_text_field_size_when_nil(:string)
33
- it_should_apply_custom_input_attributes_when_input_html_provided(:string)
34
- it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
35
- it_should_apply_error_logic_for_input_type(:string)
36
-
37
- # This doesn't get called anywhere!
38
- def input_field_for_method_should_have_maxlength(method, maxlength)
39
- concat(semantic_form_for(@new_post) do |builder|
40
- concat(builder.input(method))
41
- end)
42
- output_buffer.should have_tag("form li input[@maxlength='#{maxlength}']")
43
- end
44
-
45
- describe 'and its a ActiveModel' do
46
- let(:default_maxlength) { 50 }
47
-
48
- before do
49
- @new_post.stub!(:class).and_return(::PostModel)
50
- end
51
-
52
- after do
53
- @new_post.stub!(:class).and_return(::Post)
54
- end
55
-
56
- describe 'and validates_length_of was called for the method' do
57
- def should_have_maxlength(maxlength, options)
58
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
59
- active_model_length_validator([:title], options[:options])
60
- ])
61
-
62
- concat(semantic_form_for(@new_post) do |builder|
63
- concat(builder.input(:title))
64
- end)
65
-
66
- output_buffer.should have_tag("form div.control-group div.controls input##{@new_post.class.name.underscore}_title[@maxlength='#{maxlength}']")
67
- end
68
-
69
- it 'should have maxlength if the optional :if or :unless options are not supplied' do
70
- should_have_maxlength(42, :options => {:maximum => 42})
71
- end
72
-
73
- it 'should have default maxlength if the optional :if condition is not satisifed' do
74
- should_have_maxlength(default_maxlength, :options => {:maximum => 42, :if => false})
75
- end
76
-
77
- it 'should have default_maxlength if the optional :if proc evaluates to false' do
78
- should_have_maxlength(default_maxlength, :options => {:maximum => 42, :if => proc { |record| false }})
79
- end
80
-
81
- it 'should have maxlength if the optional :if proc evaluates to true' do
82
- should_have_maxlength(42, :options => { :maximum => 42, :if => proc { |record| true } })
83
- end
84
-
85
- it 'should have default maxlength if the optional :if with a method name evaluates to false' do
86
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(false)
87
- should_have_maxlength(default_maxlength, :options => { :maximum => 42, :if => :specify_maxlength })
88
- end
89
-
90
- it 'should have maxlength if the optional :if with a method name evaluates to true' do
91
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(true)
92
- should_have_maxlength(42, :options => { :maximum => 42, :if => :specify_maxlength })
93
- end
94
-
95
- it 'should have default maxlength if the optional :unless proc evaluates to true' do
96
- should_have_maxlength(default_maxlength, :options => { :maximum => 42, :unless => proc { |record| true } })
97
- end
98
-
99
- it 'should have maxlength if the optional :unless proc evaluates to false' do
100
- should_have_maxlength(42, :options => { :maximum => 42, :unless => proc { |record| false } })
101
- end
102
-
103
- it 'should have default maxlength if the optional :unless with a method name evaluates to true' do
104
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(true)
105
- should_have_maxlength(default_maxlength, :options => { :maximum => 42, :unless => :specify_maxlength })
106
- end
107
-
108
- it 'should have maxlength if the optional :unless with a method name evaluates to false' do
109
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(false)
110
- should_have_maxlength(42, :options => { :maximum => 42, :unless => :specify_maxlength })
111
- end
112
- end
113
- end
114
- end
115
-
116
- describe "when namespace is provided" do
117
-
118
- before do
119
- concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
120
- concat(builder.input(:title, :as => :string))
121
- end)
122
- end
123
-
124
- it_should_have_input_wrapper_with_id("context2_post_title_input")
125
- it_should_have_label_and_input_with_id("context2_post_title")
126
-
127
- end
128
-
129
- describe "when index is provided" do
130
-
131
- before do
132
- @output_buffer = ''
133
- mock_everything
134
-
135
- concat(semantic_form_for(@new_post) do |builder|
136
- concat(builder.fields_for(:author, :index => 3) do |author|
137
- concat(author.input(:name, :as => :string))
138
- end)
139
- end)
140
- end
141
-
142
- it 'should index the id of the wrapper' do
143
- output_buffer.should have_tag("div#post_author_attributes_3_name_input")
144
- end
145
-
146
- it 'should index the id of the select tag' do
147
- output_buffer.should have_tag("input#post_author_attributes_3_name")
148
- end
149
-
150
- it 'should index the name of the select tag' do
151
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
152
- end
153
-
154
- end
155
-
156
-
157
- describe "when no object is provided" do
158
- before do
159
- concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
160
- concat(builder.input(:title, :as => :string))
161
- end)
162
- end
163
-
164
- it_should_have_label_with_text(/Title/)
165
- it_should_have_label_for("project_title")
166
- it_should_have_input_with_id("project_title")
167
- it_should_have_input_with_type(:text)
168
- it_should_have_input_with_name("project[title]")
169
- end
170
-
171
- describe "when size is nil" do
172
- before do
173
- concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
174
- concat(builder.input(:title, :as => :string, :input_html => {:size => nil}))
175
- end)
176
- end
177
-
178
- it "should have no size attribute" do
179
- output_buffer.should_not have_tag("input[@size]")
180
- end
181
- end
182
-
183
- describe "when required" do
184
-
185
- context "and configured to use HTML5 attribute" do
186
- it "should add the required attribute to the input's html options" do
187
- with_config :use_required_attribute, true do
188
- concat(semantic_form_for(@new_post) do |builder|
189
- concat(builder.input(:title, :as => :string, :required => true))
190
- end)
191
- output_buffer.should have_tag("input[@required]")
192
- end
193
- end
194
- end
195
-
196
- context "and configured to not use HTML5 attribute" do
197
- it "should add the required attribute to the input's html options" do
198
- with_config :use_required_attribute, false do
199
- concat(semantic_form_for(@new_post) do |builder|
200
- concat(builder.input(:title, :as => :string, :required => true))
201
- end)
202
- output_buffer.should_not have_tag("input[@required]")
203
- end
204
- end
205
- end
206
-
207
- end
208
-
209
- end
210
-
@@ -1,188 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'text input' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
-
12
- concat(semantic_form_for(@new_post) do |builder|
13
- concat(builder.input(:body, :as => :text))
14
- end)
15
- end
16
-
17
- it_should_have_bootstrap_horizontal_wrapping
18
- it_should_have_input_wrapper_with_class("text")
19
- it_should_have_input_wrapper_with_class(:input)
20
- it_should_have_input_wrapper_with_id("post_body_input")
21
- it_should_have_label_with_text(/Body/)
22
- it_should_have_label_for("post_body")
23
- it_should_have_textarea_with_id("post_body")
24
- it_should_have_textarea_with_name("post[body]")
25
- it_should_apply_error_logic_for_input_type(:number)
26
-
27
- it 'should use input_html to style inputs' do
28
- output_buffer.replace ''
29
- concat(semantic_form_for(@new_post) do |builder|
30
- concat(builder.input(:title, :as => :text, :input_html => { :class => 'myclass' }))
31
- end)
32
- output_buffer.should have_tag("form div.control-group div.controls textarea.myclass")
33
- end
34
-
35
- it "should have a cols attribute when :cols is a number in :input_html" do
36
- output_buffer.replace ''
37
- concat(semantic_form_for(@new_post) do |builder|
38
- concat(builder.input(:title, :as => :text, :input_html => { :cols => 42 }))
39
- end)
40
- output_buffer.should have_tag("form div.control-group div.controls textarea[@cols='42']")
41
- end
42
-
43
- it "should not have a cols attribute when :cols is nil in :input_html" do
44
- output_buffer.replace ''
45
- concat(semantic_form_for(@new_post) do |builder|
46
- concat(builder.input(:title, :as => :text, :input_html => { :cols => nil }))
47
- end)
48
- output_buffer.should_not have_tag("form div.control-group div.controls textarea[@cols]")
49
- end
50
-
51
- it "should have a rows attribute when :rows is a number in :input_html" do
52
- output_buffer.replace ''
53
- concat(semantic_form_for(@new_post) do |builder|
54
- concat(builder.input(:title, :as => :text, :input_html => { :rows => 42 }))
55
- end)
56
- output_buffer.should have_tag("form div.control-group div.controls textarea[@rows='42']")
57
-
58
- end
59
-
60
- it "should not have a rows attribute when :rows is nil in :input_html" do
61
- output_buffer.replace ''
62
- concat(semantic_form_for(@new_post) do |builder|
63
- concat(builder.input(:title, :as => :text, :input_html => { :rows => nil }))
64
- end)
65
- output_buffer.should_not have_tag("form div.control-group div.controls textarea[@rows]")
66
- end
67
-
68
- describe "when namespace is provided" do
69
-
70
- before do
71
- @output_buffer = ''
72
- mock_everything
73
-
74
- concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
75
- concat(builder.input(:body, :as => :text))
76
- end)
77
- end
78
-
79
- it_should_have_input_wrapper_with_id("context2_post_body_input")
80
- it_should_have_textarea_with_id("context2_post_body")
81
- it_should_have_label_for("context2_post_body")
82
-
83
- end
84
-
85
- describe "when index is provided" do
86
-
87
- before do
88
- @output_buffer = ''
89
- mock_everything
90
-
91
- concat(semantic_form_for(@new_post) do |builder|
92
- concat(builder.fields_for(:author, :index => 3) do |author|
93
- concat(author.input(:name, :as => :text))
94
- end)
95
- end)
96
- end
97
-
98
- it 'should index the id of the control-group' do
99
- output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
100
- end
101
-
102
- it 'should index the id of the select tag' do
103
- output_buffer.should have_tag("textarea#post_author_attributes_3_name")
104
- end
105
-
106
- it 'should index the name of the select tag' do
107
- output_buffer.should have_tag("textarea[@name='post[author_attributes][3][name]']")
108
- end
109
-
110
- end
111
-
112
- context "when required" do
113
- it "should add the required attribute to the input's html options" do
114
- with_config :use_required_attribute, true do
115
- concat(semantic_form_for(@new_post) do |builder|
116
- concat(builder.input(:title, :as => :text, :required => true))
117
- end)
118
- output_buffer.should have_tag("textarea[@required]")
119
- end
120
- end
121
- end
122
-
123
- context "when :autofocus is provided in :input_html" do
124
- before(:each) do
125
- concat(semantic_form_for(@new_post) do |builder|
126
- concat(builder.input(:title, :input_html => {:autofocus => true}))
127
- end)
128
- end
129
-
130
- it_should_have_input_wrapper_with_class("autofocus")
131
-
132
- it "should add the autofocus attribute to the input's html options" do
133
- output_buffer.should have_tag("input[@autofocus]")
134
- end
135
- end
136
-
137
- context "when :rows is missing in :input_html" do
138
- before do
139
- output_buffer.replace ''
140
- end
141
-
142
- it "should have a rows attribute matching default_text_area_height if numeric" do
143
- with_config :default_text_area_height, 12 do
144
- concat(semantic_form_for(@new_post) do |builder|
145
- concat(builder.input(:title, :as => :text))
146
- end)
147
- output_buffer.should have_tag("form div.control-group div.controls textarea[@rows='12']")
148
- end
149
- end
150
-
151
- it "should not have a rows attribute if default_text_area_height is nil" do
152
- with_config :default_text_area_height, nil do
153
- concat(semantic_form_for(@new_post) do |builder|
154
- concat(builder.input(:title, :as => :text))
155
- end)
156
- output_buffer.should_not have_tag("form div.control-group div.controls textarea[@rows]")
157
- end
158
-
159
- end
160
- end
161
-
162
- context "when :cols is missing in :input_html" do
163
- before do
164
- output_buffer.replace ''
165
- end
166
-
167
- it "should have a cols attribute matching default_text_area_width if numeric" do
168
- with_config :default_text_area_width, 10 do
169
- concat(semantic_form_for(@new_post) do |builder|
170
- concat(builder.input(:title, :as => :text))
171
- end)
172
- output_buffer.should have_tag("form div.control-group div.controls textarea[@cols='10']")
173
- end
174
- end
175
-
176
- it "should not have a cols attribute if default_text_area_width is nil" do
177
- with_config :default_text_area_width, nil do
178
- concat(semantic_form_for(@new_post) do |builder|
179
- concat(builder.input(:title, :as => :text))
180
- end)
181
- output_buffer.should_not have_tag("form div.control-group div.controls textarea[@cols]")
182
- end
183
-
184
- end
185
- end
186
-
187
- end
188
-
@@ -1,191 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'time select input' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- describe "general" do
14
- before do
15
- ::I18n.backend.reload!
16
- output_buffer.replace ''
17
- end
18
-
19
- describe "with :ignore_date => true" do
20
- before do
21
- concat(semantic_form_for(@new_post) do |builder|
22
- concat(builder.input(:publish_at, :as => :time_select, :ignore_date => true))
23
- end)
24
- end
25
-
26
- it 'should not have hidden inputs for day, month and year' do
27
- output_buffer.should_not have_tag('input#post_publish_at_1i')
28
- output_buffer.should_not have_tag('input#post_publish_at_2i')
29
- output_buffer.should_not have_tag('input#post_publish_at_3i')
30
- end
31
-
32
- it 'should have an input for hour and minute' do
33
- output_buffer.should have_tag('select#post_publish_at_4i')
34
- output_buffer.should have_tag('select#post_publish_at_5i')
35
- end
36
-
37
- end
38
-
39
- describe "with :ignore_date => false" do
40
- before do
41
- @new_post.stub(:publish_at).and_return(Time.parse('2010-11-07'))
42
- concat(semantic_form_for(@new_post) do |builder|
43
- concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
44
- end)
45
- end
46
-
47
- it 'should have a hidden input for day, month and year' do
48
- output_buffer.should have_tag('input#post_publish_at_1i')
49
- output_buffer.should have_tag('input#post_publish_at_2i')
50
- output_buffer.should have_tag('input#post_publish_at_3i')
51
- output_buffer.should have_tag('input#post_publish_at_1i[@value="2010"]')
52
- output_buffer.should have_tag('input#post_publish_at_2i[@value="11"]')
53
- output_buffer.should have_tag('input#post_publish_at_3i[@value="7"]')
54
- end
55
-
56
- it 'should have an select for hour and minute' do
57
- output_buffer.should have_tag('select#post_publish_at_4i')
58
- output_buffer.should have_tag('select#post_publish_at_5i')
59
- end
60
-
61
- end
62
-
63
- describe "with :ignore_date => false and no initial Time" do
64
- before do
65
- @new_post.stub(:publish_at)
66
- concat(semantic_form_for(@new_post) do |builder|
67
- concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
68
- end)
69
- end
70
-
71
- it 'should have a hidden input for day, month and year' do
72
- output_buffer.should have_tag('input#post_publish_at_1i')
73
- output_buffer.should have_tag('input#post_publish_at_2i')
74
- output_buffer.should have_tag('input#post_publish_at_3i')
75
- end
76
-
77
- it 'should not have values in hidden inputs for day, month and year' do
78
- output_buffer.should have_tag('input#post_publish_at_1i[@value=""]')
79
- output_buffer.should have_tag('input#post_publish_at_2i[@value=""]')
80
- output_buffer.should have_tag('input#post_publish_at_3i[@value=""]')
81
- end
82
-
83
- it 'should have an select for hour and minute' do
84
- output_buffer.should have_tag('select#post_publish_at_4i')
85
- output_buffer.should have_tag('select#post_publish_at_5i')
86
- end
87
-
88
- end
89
-
90
- describe "without seconds" do
91
- before do
92
- concat(semantic_form_for(@new_post) do |builder|
93
- concat(builder.input(:publish_at, :as => :time_select))
94
- end)
95
- end
96
-
97
- it_should_have_bootstrap_horizontal_wrapping
98
- it_should_have_input_wrapper_with_class("time_select")
99
- it_should_have_input_wrapper_with_class(:input)
100
- it_should_have_input_wrapper_with_id("post_publish_at_input")
101
- it_should_apply_error_logic_for_input_type(:time_select)
102
-
103
- it 'should have a legend and label with the label text inside the fieldset' do
104
- output_buffer.should have_tag('form div.control-group.time_select label.control-label', /Publish at/)
105
- end
106
-
107
- it 'should have two selects for hour and minute' do
108
- output_buffer.should have_tag('form div.control-group.time_select div.controls select', :count => 2)
109
- end
110
- end
111
-
112
- describe "with seconds" do
113
- before do
114
- concat(semantic_form_for(@new_post) do |builder|
115
- concat(builder.input(:publish_at, :as => :time_select, :include_seconds => true))
116
- end)
117
- end
118
-
119
- it 'should have three selects for hour, minute and seconds' do
120
- output_buffer.should have_tag('form div.control-group.time_select div.controls select', :count => 3)
121
- end
122
- end
123
- end
124
-
125
- describe ':labels option' do
126
- it "should provide a message that :labels is not supported" do
127
- pending ':labels is not supported'
128
- end
129
- end
130
-
131
- describe ':namespace option' do
132
- before do
133
- concat(semantic_form_for(@new_post, :namespace => 'form2') do |builder|
134
- concat(builder.input(:publish_at, :as => :time_select))
135
- end)
136
- end
137
-
138
- it 'should have a tag matching the namespace' do
139
- output_buffer.should have_tag('#form2_post_publish_at_input')
140
- output_buffer.should have_tag('#form2_post_publish_at_4i')
141
- output_buffer.should have_tag('#form2_post_publish_at_5i')
142
- end
143
- end
144
-
145
- describe "when required" do
146
- it "should add the required attribute to the input's html options" do
147
- with_config :use_required_attribute, true do
148
- concat(semantic_form_for(@new_post) do |builder|
149
- concat(builder.input(:title, :as => :time_select, :required => true))
150
- end)
151
- output_buffer.should have_tag("select[@required]", :count => 2)
152
- end
153
- end
154
- end
155
-
156
- describe "when index is provided" do
157
-
158
- before do
159
- concat(semantic_form_for(@new_post) do |builder|
160
- concat(builder.fields_for(:author, :index => 3) do |author|
161
- concat(author.input(:created_at, :as => :time_select))
162
- end)
163
- end)
164
- end
165
-
166
- it 'should index the id of the control-group' do
167
- output_buffer.should have_tag("div.control-group#post_author_attributes_3_created_at_input")
168
- end
169
-
170
- it 'should index the id of the select tag' do
171
- output_buffer.should have_tag("input#post_author_attributes_3_created_at_1i")
172
- output_buffer.should have_tag("input#post_author_attributes_3_created_at_2i")
173
- output_buffer.should have_tag("input#post_author_attributes_3_created_at_3i")
174
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_4i")
175
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_5i")
176
- end
177
-
178
- it 'should index the name of the select tag' do
179
- output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(1i)]']")
180
- output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(2i)]']")
181
- output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at(3i)]']")
182
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
183
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
184
- end
185
-
186
- end
187
-
188
- end
189
-
190
-
191
-