formtastic-bootstrap 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,100 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'password 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(:title, :as => :password))
14
- end)
15
- end
16
-
17
- it_should_have_bootstrap_horizontal_wrapping
18
- it_should_have_input_wrapper_with_class(:password)
19
- it_should_have_input_wrapper_with_class(:input)
20
- it_should_have_input_wrapper_with_class(:stringish)
21
- it_should_have_input_wrapper_with_id("post_title_input")
22
- it_should_have_label_with_text(/Title/)
23
- it_should_have_label_for("post_title")
24
- it_should_have_input_with_id("post_title")
25
- it_should_have_input_with_type(:password)
26
- it_should_have_input_with_name("post[title]")
27
- it_should_have_maxlength_matching_column_limit
28
- it_should_use_default_text_field_size_when_not_nil(:string)
29
- it_should_not_use_default_text_field_size_when_nil(:string)
30
- it_should_apply_custom_input_attributes_when_input_html_provided(:string)
31
- it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
32
- it_should_apply_error_logic_for_input_type(:password)
33
-
34
- describe "when no object is provided" do
35
- before do
36
- concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
37
- concat(builder.input(:title, :as => :password))
38
- end)
39
- end
40
-
41
- it_should_have_label_with_text(/Title/)
42
- it_should_have_label_for("project_title")
43
- it_should_have_input_with_id("project_title")
44
- it_should_have_input_with_type(:password)
45
- it_should_have_input_with_name("project[title]")
46
- end
47
-
48
- describe "when namespace is provided" do
49
-
50
- before do
51
- concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
52
- concat(builder.input(:title, :as => :password))
53
- end)
54
- end
55
-
56
- it_should_have_input_wrapper_with_id("context2_post_title_input")
57
- it_should_have_label_and_input_with_id("context2_post_title")
58
-
59
- end
60
-
61
- describe "when index is provided" do
62
-
63
- before do
64
- @output_buffer = ''
65
- mock_everything
66
-
67
- concat(semantic_form_for(@new_post) do |builder|
68
- concat(builder.fields_for(:author, :index => 3) do |author|
69
- concat(author.input(:name, :as => :password))
70
- end)
71
- end)
72
- end
73
-
74
- it 'should index the id of the control-group' do
75
- output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
76
- end
77
-
78
- it 'should index the id of the select tag' do
79
- output_buffer.should have_tag("input#post_author_attributes_3_name")
80
- end
81
-
82
- it 'should index the name of the select tag' do
83
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
84
- end
85
-
86
- end
87
-
88
-
89
- describe "when required" do
90
- it "should add the required attribute to the input's html options" do
91
- with_config :use_required_attribute, true do
92
- concat(semantic_form_for(@new_post) do |builder|
93
- concat(builder.input(:title, :as => :password, :required => true))
94
- end)
95
- output_buffer.should have_tag("input[@required]")
96
- end
97
- end
98
- end
99
-
100
- end
@@ -1,86 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'phone 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(:phone))
17
- end)
18
- end
19
-
20
- it_should_have_bootstrap_horizontal_wrapping
21
- it_should_have_input_wrapper_with_class(:phone)
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_phone_input")
25
- it_should_have_label_with_text(/Phone/)
26
- it_should_have_label_for("post_phone")
27
- it_should_have_input_with_id("post_phone")
28
- it_should_have_input_with_type(:tel)
29
- it_should_have_input_with_name("post[phone]")
30
-
31
- end
32
-
33
- describe "when namespace is provided" do
34
-
35
- before do
36
- concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
37
- concat(builder.input(:phone))
38
- end)
39
- end
40
-
41
- it_should_have_input_wrapper_with_id("context2_post_phone_input")
42
- it_should_have_label_and_input_with_id("context2_post_phone")
43
-
44
- end
45
-
46
- describe "when index is provided" do
47
-
48
- before do
49
- @output_buffer = ''
50
- mock_everything
51
-
52
- concat(semantic_form_for(@new_post) do |builder|
53
- concat(builder.fields_for(:author, :index => 3) do |author|
54
- concat(author.input(:name, :as => :phone))
55
- end)
56
- end)
57
- end
58
-
59
- it 'should index the id of the control group' do
60
- output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
61
- end
62
-
63
- it 'should index the id of the select tag' do
64
- output_buffer.should have_tag("input#post_author_attributes_3_name")
65
- end
66
-
67
- it 'should index the name of the select tag' do
68
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
69
- end
70
-
71
- end
72
-
73
-
74
- describe "when required" do
75
- it "should add the required attribute to the input's html options" do
76
- with_config :use_required_attribute, true do
77
- concat(semantic_form_for(@new_post) do |builder|
78
- concat(builder.input(:title, :as => :phone, :required => true))
79
- end)
80
- output_buffer.should have_tag("input[@required]")
81
- end
82
- end
83
- end
84
-
85
- end
86
-
@@ -1,267 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'radio input' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- describe 'for belongs_to association' do
14
- before do
15
- concat(semantic_form_for(@new_post) do |builder|
16
- concat(builder.input(:author, :as => :radio, :value_as_class => true, :required => true))
17
- end)
18
- end
19
-
20
- it_should_have_bootstrap_horizontal_wrapping
21
- it_should_have_input_wrapper_with_class("radio_buttons")
22
- it_should_have_input_wrapper_with_class(:input)
23
- it_should_have_input_wrapper_with_id("post_author_input")
24
- # it_should_have_a_nested_fieldset
25
- # it_should_have_a_nested_fieldset_with_class('choices')
26
- # it_should_have_a_nested_ordered_list_with_class('choices-group')
27
- it_should_apply_error_logic_for_input_type(:radio)
28
- it_should_use_the_collection_when_provided(:radio, 'input')
29
-
30
- it 'should generate a control label with text for the input' do
31
- output_buffer.should have_tag('form div.control-group > label.control-label')
32
- output_buffer.should have_tag('form div.control-group > label.control-label', /Author/)
33
- end
34
-
35
- it 'should have one option with a "checked" attribute' do
36
- output_buffer.should have_tag('form div.control-group div.controls input[@checked]', :count => 1)
37
- end
38
-
39
- describe "each choice" do
40
-
41
- it 'should not give the choice label the .label class' do
42
- output_buffer.should_not have_tag('div.controls label.label')
43
- end
44
-
45
- it 'should not add the required attribute to each input' do
46
- output_buffer.should_not have_tag('div.controls input[@required]')
47
- end
48
-
49
-
50
- it 'should contain a label for the radio input with a nested input and label text' do
51
- ::Author.all.each do |author|
52
- output_buffer.should have_tag('form div.control-group div.controls label', /#{author.to_label}/)
53
- output_buffer.should have_tag("form div.control-group div.controls label[@for='post_author_id_#{author.id}']")
54
- end
55
- end
56
-
57
- it 'should use values as li.class when value_as_class is true' do
58
- ::Author.all.each do |author|
59
- output_buffer.should have_tag("form div.control-group div.controls label.author_#{author.id}")
60
- end
61
- end
62
-
63
- it "should have a radio input" do
64
- ::Author.all.each do |author|
65
- output_buffer.should have_tag("form div.control-group div.controls label input#post_author_id_#{author.id}")
66
- output_buffer.should have_tag("form div.control-group div.controls label input[@type='radio']")
67
- output_buffer.should have_tag("form div.control-group div.controls label input[@value='#{author.id}']")
68
- output_buffer.should have_tag("form div.control-group div.controls label input[@name='post[author_id]']")
69
- end
70
- end
71
-
72
- it "should mark input as checked if it's the the existing choice" do
73
- @new_post.author_id.should == @bob.id
74
- @new_post.author.id.should == @bob.id
75
- @new_post.author.should == @bob
76
-
77
- concat(semantic_form_for(@new_post) do |builder|
78
- concat(builder.input(:author, :as => :radio))
79
- end)
80
-
81
- output_buffer.should have_tag("form div.control-group div.controls label input[@checked='checked']")
82
- end
83
-
84
- it "should mark the input as disabled if options attached for disabling" do
85
- concat(semantic_form_for(@new_post) do |builder|
86
- concat(builder.input(:author, :as => :radio, :collection => [["Test", 'test'], ["Try", "try", {:disabled => true}]]))
87
- end)
88
-
89
- output_buffer.should_not have_tag("form div.control-group div.controls label input[@value='test'][@disabled='disabled']")
90
- output_buffer.should have_tag("form div.control-group div.controls label input[@value='try'][@disabled='disabled']")
91
- end
92
-
93
- it "should not contain invalid HTML attributes" do
94
-
95
- concat(semantic_form_for(@new_post) do |builder|
96
- concat(builder.input(:author, :as => :radio))
97
- end)
98
-
99
- output_buffer.should_not have_tag("form li fieldset ol li input[@find_options]")
100
- end
101
-
102
- end
103
-
104
- describe 'and no object is given' do
105
- before(:each) do
106
- output_buffer.replace ''
107
- concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
108
- concat(builder.input(:author_id, :as => :radio, :collection => ::Author.all))
109
- end)
110
- end
111
-
112
- it 'should generate labels for each item' do
113
- ::Author.all.each do |author|
114
- output_buffer.should have_tag('form div.control-group div.controls label', /#{author.to_label}/)
115
- output_buffer.should have_tag("form div.control-group div.controls label[@for='project_author_id_#{author.id}']")
116
- end
117
- end
118
-
119
- it 'should html escape the label string' do
120
- concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
121
- concat(builder.input(:author_id, :as => :radio, :collection => [["<b>Item 1</b>", 1], ["<b>Item 2</b>", 2]]))
122
- end)
123
- output_buffer.should have_tag('form div.control-group div.controls label') do |label|
124
- label.body.should match /&lt;b&gt;Item [12]&lt;\/b&gt;$/
125
- end
126
- end
127
-
128
- it 'should generate inputs for each item' do
129
- ::Author.all.each do |author|
130
- output_buffer.should have_tag("form div.control-group div.controls label input#project_author_id_#{author.id}")
131
- output_buffer.should have_tag("form div.control-group div.controls label input[@type='radio']")
132
- output_buffer.should have_tag("form div.control-group div.controls label input[@value='#{author.id}']")
133
- output_buffer.should have_tag("form div.control-group div.controls label input[@name='project[author_id]']")
134
- end
135
- end
136
- end
137
- end
138
-
139
- describe "with i18n of the legend label" do
140
-
141
- before do
142
- ::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
143
-
144
- with_config :i18n_lookups_by_default, true do
145
- @new_post.stub!(:author_ids).and_return(nil)
146
- concat(semantic_form_for(@new_post) do |builder|
147
- concat(builder.input(:authors, :as => :radio))
148
- end)
149
- end
150
- end
151
-
152
- after do
153
- ::I18n.backend.reload!
154
- end
155
-
156
- it "should do foo" do
157
- output_buffer.should have_tag("label.control-label", /Translated/)
158
- end
159
-
160
- end
161
-
162
- describe "when :label option is set" do
163
- before do
164
- @new_post.stub!(:author_ids).and_return(nil)
165
- concat(semantic_form_for(@new_post) do |builder|
166
- concat(builder.input(:authors, :as => :radio, :label => 'The authors'))
167
- end)
168
- end
169
-
170
- it "should output the correct label title" do
171
- output_buffer.should have_tag("label.control-label", /The authors/)
172
- end
173
- end
174
-
175
- describe "when :label option is false" do
176
- before do
177
- @output_buffer = ''
178
- @new_post.stub!(:author_ids).and_return(nil)
179
- concat(semantic_form_for(@new_post) do |builder|
180
- concat(builder.input(:authors, :as => :radio, :label => false))
181
- end)
182
- end
183
-
184
- it "should not output the legend" do
185
- # TODO I think this is not supported in FB.
186
- output_buffer.should_not have_tag("label.control-label")
187
- output_buffer.should_not include("&gt;")
188
- end
189
-
190
- it "should not cause escaped HTML" do
191
- output_buffer.should_not include("&gt;")
192
- end
193
- end
194
-
195
- describe "when :required option is true" do
196
- before do
197
- @new_post.stub!(:author_ids).and_return(nil)
198
- concat(semantic_form_for(@new_post) do |builder|
199
- concat(builder.input(:authors, :as => :radio, :required => true))
200
- end)
201
- end
202
-
203
- it "should output the correct label title" do
204
- output_buffer.should have_tag("label.control-label abbr")
205
- end
206
- end
207
-
208
- describe "when :namespace is given on form" do
209
- before do
210
- @output_buffer = ''
211
- @new_post.stub!(:author_ids).and_return(nil)
212
- concat(semantic_form_for(@new_post, :namespace => "custom_prefix") do |builder|
213
- concat(builder.input(:authors, :as => :radio, :label => ''))
214
- end)
215
-
216
- output_buffer.should match(/for="custom_prefix_post_author_ids_(\d+)"/)
217
- output_buffer.should match(/id="custom_prefix_post_author_ids_(\d+)"/)
218
- end
219
- it_should_have_input_wrapper_with_id("custom_prefix_post_authors_input")
220
- end
221
-
222
- describe "when index is provided" do
223
-
224
- before do
225
- @output_buffer = ''
226
- mock_everything
227
-
228
- concat(semantic_form_for(@new_post) do |builder|
229
- concat(builder.fields_for(:author, :index => 3) do |author|
230
- concat(author.input(:name, :as => :radio))
231
- end)
232
- end)
233
- end
234
-
235
- it 'should index the id of the control-group' do
236
- output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
237
- end
238
-
239
- it 'should index the id of the select tag' do
240
- output_buffer.should have_tag("input#post_author_attributes_3_name_true")
241
- output_buffer.should have_tag("input#post_author_attributes_3_name_false")
242
- end
243
-
244
- it 'should index the name of the select tag' do
245
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
246
- end
247
-
248
- end
249
-
250
- describe "when collection contains integers" do
251
- before do
252
- @output_buffer = ''
253
- mock_everything
254
-
255
- concat(semantic_form_for(:project) do |builder|
256
- concat(builder.input(:author_id, :as => :radio, :collection => [1, 2, 3]))
257
- end)
258
- end
259
-
260
- it 'should output the correct labels' do
261
- output_buffer.should have_tag("div.controls label", /1/)
262
- output_buffer.should have_tag("div.controls label", /2/)
263
- output_buffer.should have_tag("div.controls label", /3/)
264
- end
265
- end
266
-
267
- end