formtastic-bootstrap 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. data/Gemfile +5 -3
  2. data/Gemfile.lock +72 -60
  3. data/README.md +4 -1
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/formtastic-bootstrap.gemspec +49 -16
  7. data/lib/formtastic-bootstrap/actions/base.rb +22 -0
  8. data/lib/formtastic-bootstrap/actions/button_action.rb +13 -0
  9. data/lib/formtastic-bootstrap/actions/input_action.rb +13 -0
  10. data/lib/formtastic-bootstrap/actions/link_action.rb +12 -0
  11. data/lib/formtastic-bootstrap/actions.rb +10 -0
  12. data/lib/formtastic-bootstrap/form_builder.rb +4 -2
  13. data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
  14. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +24 -0
  15. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +2 -4
  16. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -2
  17. data/lib/formtastic-bootstrap/helpers.rb +6 -8
  18. data/lib/formtastic-bootstrap/inputs/base/choices.rb +6 -35
  19. data/lib/formtastic-bootstrap/inputs/base/collections.rb +9 -0
  20. data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +9 -0
  21. data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
  22. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +14 -3
  23. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +9 -0
  24. data/lib/formtastic-bootstrap/inputs/base/stringish.rb +4 -5
  25. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +38 -18
  26. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +22 -34
  27. data/lib/formtastic-bootstrap/inputs/base.rb +29 -6
  28. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +14 -18
  29. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +16 -11
  30. data/lib/formtastic-bootstrap/inputs/date_input.rb +3 -9
  31. data/lib/formtastic-bootstrap/inputs/date_select_input.rb +8 -0
  32. data/lib/formtastic-bootstrap/inputs/datetime_input.rb +3 -12
  33. data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +8 -0
  34. data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
  35. data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
  36. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
  37. data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
  38. data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
  39. data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
  40. data/lib/formtastic-bootstrap/inputs/radio_input.rb +28 -14
  41. data/lib/formtastic-bootstrap/inputs/range_input.rb +1 -1
  42. data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
  43. data/lib/formtastic-bootstrap/inputs/select_input.rb +3 -1
  44. data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -7
  45. data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
  46. data/lib/formtastic-bootstrap/inputs/time_input.rb +3 -9
  47. data/lib/formtastic-bootstrap/inputs/time_select_input.rb +8 -0
  48. data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
  49. data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
  50. data/lib/formtastic-bootstrap/inputs.rb +30 -23
  51. data/lib/formtastic-bootstrap.rb +16 -1
  52. data/spec/actions/button_action_spec.rb +63 -0
  53. data/spec/actions/input_action_spec.rb +59 -0
  54. data/spec/actions/link_action_spec.rb +92 -0
  55. data/spec/helpers/action_helper_spec.rb +368 -0
  56. data/spec/helpers/actions_helper_spec.rb +147 -0
  57. data/spec/helpers/input_helper_spec.rb +238 -259
  58. data/spec/helpers/inputs_helper_spec.rb +84 -25
  59. data/spec/inputs/boolean_input_spec.rb +108 -75
  60. data/spec/inputs/check_boxes_input_spec.rb +106 -91
  61. data/spec/inputs/date_select_input_spec.rb +164 -0
  62. data/spec/inputs/datetime_select_input_spec.rb +112 -0
  63. data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +48 -0
  64. data/spec/inputs/email_input_spec.rb +30 -3
  65. data/spec/inputs/file_input_spec.rb +31 -4
  66. data/spec/inputs/hidden_input_spec.rb +63 -32
  67. data/spec/inputs/number_input_spec.rb +37 -8
  68. data/spec/inputs/password_input_spec.rb +30 -3
  69. data/spec/inputs/phone_input_spec.rb +30 -3
  70. data/spec/inputs/radio_input_spec.rb +87 -60
  71. data/spec/inputs/range_input_spec.rb +32 -5
  72. data/spec/inputs/search_input_spec.rb +29 -3
  73. data/spec/inputs/select_input_spec.rb +164 -107
  74. data/spec/inputs/string_input_spec.rb +33 -22
  75. data/spec/inputs/text_input_spec.rb +39 -14
  76. data/spec/inputs/time_select_input_spec.rb +191 -0
  77. data/spec/inputs/time_zone_input_spec.rb +17 -19
  78. data/spec/inputs/url_input_spec.rb +30 -3
  79. data/spec/spec_helper.rb +21 -15
  80. data/spec/support/custom_macros.rb +61 -228
  81. data/spec/support/fb_custom_macros.rb +23 -0
  82. metadata +109 -28
  83. data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +0 -52
  84. data/spec/builder/errors_spec.rb +0 -214
  85. data/spec/helpers/buttons_helper_spec.rb +0 -149
  86. data/spec/inputs/date_input_spec.rb +0 -147
  87. data/spec/inputs/datetime_input_spec.rb +0 -101
  88. data/spec/inputs/time_input_spec.rb +0 -206
  89. data/spec/support/depracation.rb +0 -6
  90. data/spec/support/formtastic_spec_helper.rb +0 -382
@@ -0,0 +1,147 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'FormtasticBootstrap::FormBuilder#actions' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+ end
12
+
13
+ describe 'with a block' do
14
+ describe 'when no options are provided' do
15
+ before do
16
+ concat(semantic_form_for(@new_post) do |builder|
17
+ concat(builder.actions do
18
+ concat('hello')
19
+ end)
20
+ end)
21
+ end
22
+
23
+ it 'should render a fieldset inside the form, with a class of "actions"' do
24
+ output_buffer.should have_tag("form fieldset.form-actions")
25
+ end
26
+
27
+ it 'should not render an ol inside the fieldset' do
28
+ output_buffer.should_not have_tag("form fieldset.form-actions ol")
29
+ end
30
+
31
+ it 'should render the contents of the block inside the fieldset' do
32
+ output_buffer.should have_tag("form fieldset.form-actions", /hello/)
33
+ end
34
+
35
+ it 'should not render a legend inside the fieldset' do
36
+ output_buffer.should_not have_tag("form fieldset.form-actions legend")
37
+ end
38
+ end
39
+
40
+ describe 'when a :name option is provided' do
41
+ before do
42
+ @legend_text = "Advanced options"
43
+
44
+ concat(semantic_form_for(@new_post) do |builder|
45
+ builder.actions :name => @legend_text do
46
+ end
47
+ end)
48
+ end
49
+ it 'should render a fieldset inside the form' do
50
+ output_buffer.should have_tag("form fieldset.form-actions legend", /#{@legend_text}/)
51
+ end
52
+ end
53
+
54
+ describe 'when other options are provided' do
55
+ before do
56
+ @id_option = 'advanced'
57
+ @class_option = 'wide'
58
+
59
+ concat(semantic_form_for(@new_post) do |builder|
60
+ builder.actions :id => @id_option, :class => @class_option do
61
+ end
62
+ end)
63
+ end
64
+ it 'should pass the options into the fieldset tag as attributes' do
65
+ output_buffer.should have_tag("form fieldset##{@id_option}")
66
+ output_buffer.should have_tag("form fieldset.#{@class_option}")
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ describe 'without a block' do
73
+
74
+ describe 'with no args (default buttons)' do
75
+
76
+ before do
77
+ concat(semantic_form_for(@new_post) do |builder|
78
+ concat(builder.actions)
79
+ end)
80
+ end
81
+
82
+ it 'should render a form' do
83
+ output_buffer.should have_tag('form')
84
+ end
85
+
86
+ it 'should render an actions fieldset inside the form' do
87
+ output_buffer.should have_tag('form fieldset.form-actions')
88
+ end
89
+
90
+ it 'should not render a legend in the fieldset' do
91
+ output_buffer.should_not have_tag('form fieldset.form-actions legend')
92
+ end
93
+
94
+ it 'should not render an ol in the fieldset' do
95
+ output_buffer.should_not have_tag('form fieldset.form-actions ol')
96
+ end
97
+
98
+ it 'should render a button in the fieldset for each default action' do
99
+ output_buffer.should have_tag('form fieldset.form-actions input.btn', :count => 1)
100
+ end
101
+
102
+ end
103
+
104
+ describe 'with button names as args' do
105
+
106
+ before do
107
+ concat(semantic_form_for(@new_post) do |builder|
108
+ concat(builder.actions(:submit, :cancel, :reset))
109
+ end)
110
+ end
111
+
112
+ it 'should not render a form with a fieldset containing a list item for each button arg' do
113
+ output_buffer.should_not have_tag('form > fieldset.form-actions > ol > li.action', :count => 3)
114
+ end
115
+
116
+ it 'should render a form with a fieldset containing each button arg' do
117
+ output_buffer.should_not have_tag('form > fieldset.form-actions > input.btn', :count => 3)
118
+ end
119
+
120
+ end
121
+
122
+ describe 'with button names as args and an options hash' do
123
+
124
+ before do
125
+ concat(semantic_form_for(@new_post) do |builder|
126
+ concat(builder.actions(:submit, :cancel, :reset, :name => "Now click a button", :id => "my-id"))
127
+ end)
128
+ end
129
+
130
+ it 'should render a form with a fieldset containing each button arg' do
131
+ output_buffer.should have_tag('form > fieldset.form-actions > .btn', :count => 3)
132
+ end
133
+
134
+ it 'should pass the options down to the fieldset' do
135
+ output_buffer.should have_tag('form > fieldset#my-id.form-actions')
136
+ end
137
+
138
+ it 'should use the special :name option as a text for the legend tag' do
139
+ output_buffer.should have_tag('form > fieldset#my-id.form-actions > legend', /Now click a button/)
140
+ end
141
+
142
+ end
143
+
144
+ end
145
+
146
+ end
147
+