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.
- data/Gemfile +5 -3
- data/Gemfile.lock +72 -60
- data/README.md +4 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +49 -16
- data/lib/formtastic-bootstrap/actions/base.rb +22 -0
- data/lib/formtastic-bootstrap/actions/button_action.rb +13 -0
- data/lib/formtastic-bootstrap/actions/input_action.rb +13 -0
- data/lib/formtastic-bootstrap/actions/link_action.rb +12 -0
- data/lib/formtastic-bootstrap/actions.rb +10 -0
- data/lib/formtastic-bootstrap/form_builder.rb +4 -2
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +24 -0
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +2 -4
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -2
- data/lib/formtastic-bootstrap/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +6 -35
- data/lib/formtastic-bootstrap/inputs/base/collections.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +14 -3
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +9 -0
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +4 -5
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +38 -18
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +22 -34
- data/lib/formtastic-bootstrap/inputs/base.rb +29 -6
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +14 -18
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +16 -11
- data/lib/formtastic-bootstrap/inputs/date_input.rb +3 -9
- data/lib/formtastic-bootstrap/inputs/date_select_input.rb +8 -0
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +3 -12
- data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +8 -0
- 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 +28 -14
- data/lib/formtastic-bootstrap/inputs/range_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/select_input.rb +3 -1
- data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -7
- data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_input.rb +3 -9
- data/lib/formtastic-bootstrap/inputs/time_select_input.rb +8 -0
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs.rb +30 -23
- data/lib/formtastic-bootstrap.rb +16 -1
- data/spec/actions/button_action_spec.rb +63 -0
- data/spec/actions/input_action_spec.rb +59 -0
- data/spec/actions/link_action_spec.rb +92 -0
- data/spec/helpers/action_helper_spec.rb +368 -0
- data/spec/helpers/actions_helper_spec.rb +147 -0
- data/spec/helpers/input_helper_spec.rb +238 -259
- data/spec/helpers/inputs_helper_spec.rb +84 -25
- data/spec/inputs/boolean_input_spec.rb +108 -75
- data/spec/inputs/check_boxes_input_spec.rb +106 -91
- data/spec/inputs/date_select_input_spec.rb +164 -0
- data/spec/inputs/datetime_select_input_spec.rb +112 -0
- data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +48 -0
- data/spec/inputs/email_input_spec.rb +30 -3
- data/spec/inputs/file_input_spec.rb +31 -4
- data/spec/inputs/hidden_input_spec.rb +63 -32
- data/spec/inputs/number_input_spec.rb +37 -8
- data/spec/inputs/password_input_spec.rb +30 -3
- data/spec/inputs/phone_input_spec.rb +30 -3
- data/spec/inputs/radio_input_spec.rb +87 -60
- data/spec/inputs/range_input_spec.rb +32 -5
- data/spec/inputs/search_input_spec.rb +29 -3
- data/spec/inputs/select_input_spec.rb +164 -107
- data/spec/inputs/string_input_spec.rb +33 -22
- data/spec/inputs/text_input_spec.rb +39 -14
- data/spec/inputs/time_select_input_spec.rb +191 -0
- data/spec/inputs/time_zone_input_spec.rb +17 -19
- data/spec/inputs/url_input_spec.rb +30 -3
- data/spec/spec_helper.rb +21 -15
- data/spec/support/custom_macros.rb +61 -228
- data/spec/support/fb_custom_macros.rb +23 -0
- metadata +109 -28
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +0 -52
- data/spec/builder/errors_spec.rb +0 -214
- data/spec/helpers/buttons_helper_spec.rb +0 -149
- data/spec/inputs/date_input_spec.rb +0 -147
- data/spec/inputs/datetime_input_spec.rb +0 -101
- data/spec/inputs/time_input_spec.rb +0 -206
- data/spec/support/depracation.rb +0 -6
- 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
|
+
|