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.
- data/README.md +11 -2
- data/VERSION +1 -1
- data/vendor/assets/stylesheets/formtastic-bootstrap.css +4 -0
- metadata +51 -154
- data/.rspec +0 -1
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -131
- data/Rakefile +0 -49
- data/formtastic-bootstrap.gemspec +0 -166
- data/lib/action_view/helpers/text_field_date_helper.rb +0 -166
- data/lib/formtastic-bootstrap/actions.rb +0 -10
- data/lib/formtastic-bootstrap/actions/base.rb +0 -22
- data/lib/formtastic-bootstrap/actions/button_action.rb +0 -13
- data/lib/formtastic-bootstrap/actions/input_action.rb +0 -13
- data/lib/formtastic-bootstrap/actions/link_action.rb +0 -12
- data/lib/formtastic-bootstrap/engine.rb +0 -4
- data/lib/formtastic-bootstrap/form_builder.rb +0 -40
- data/lib/formtastic-bootstrap/helpers.rb +0 -17
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +0 -12
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +0 -24
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +0 -35
- data/lib/formtastic-bootstrap/helpers/input_helper.rb +0 -12
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +0 -34
- data/lib/formtastic-bootstrap/inputs.rb +0 -36
- data/lib/formtastic-bootstrap/inputs/base.rb +0 -45
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +0 -20
- data/lib/formtastic-bootstrap/inputs/base/collections.rb +0 -9
- data/lib/formtastic-bootstrap/inputs/base/errors.rb +0 -48
- data/lib/formtastic-bootstrap/inputs/base/grouped_collections.rb +0 -9
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +0 -27
- data/lib/formtastic-bootstrap/inputs/base/html.rb +0 -21
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +0 -29
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +0 -9
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +0 -17
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +0 -55
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +0 -55
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +0 -29
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +0 -40
- data/lib/formtastic-bootstrap/inputs/date_input.rb +0 -10
- data/lib/formtastic-bootstrap/inputs/date_select_input.rb +0 -8
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +0 -10
- data/lib/formtastic-bootstrap/inputs/datetime_select_input.rb +0 -8
- data/lib/formtastic-bootstrap/inputs/email_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/file_input.rb +0 -14
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +0 -12
- data/lib/formtastic-bootstrap/inputs/number_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/password_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +0 -46
- data/lib/formtastic-bootstrap/inputs/range_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/search_input.rb +0 -15
- data/lib/formtastic-bootstrap/inputs/select_input.rb +0 -16
- data/lib/formtastic-bootstrap/inputs/string_input.rb +0 -8
- data/lib/formtastic-bootstrap/inputs/text_input.rb +0 -14
- data/lib/formtastic-bootstrap/inputs/time_input.rb +0 -10
- data/lib/formtastic-bootstrap/inputs/time_select_input.rb +0 -8
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +0 -14
- data/lib/formtastic-bootstrap/inputs/url_input.rb +0 -14
- data/spec/actions/button_action_spec.rb +0 -63
- data/spec/actions/input_action_spec.rb +0 -59
- data/spec/actions/link_action_spec.rb +0 -92
- data/spec/builder/semantic_fields_for_spec.rb +0 -130
- data/spec/helpers/action_helper_spec.rb +0 -368
- data/spec/helpers/actions_helper_spec.rb +0 -147
- data/spec/helpers/input_helper_spec.rb +0 -935
- data/spec/helpers/inputs_helper_spec.rb +0 -636
- data/spec/inputs/boolean_input_spec.rb +0 -226
- data/spec/inputs/check_boxes_input_spec.rb +0 -454
- data/spec/inputs/date_select_input_spec.rb +0 -164
- data/spec/inputs/datetime_select_input_spec.rb +0 -112
- data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +0 -48
- data/spec/inputs/email_input_spec.rb +0 -86
- data/spec/inputs/file_input_spec.rb +0 -90
- data/spec/inputs/hidden_input_spec.rb +0 -153
- data/spec/inputs/number_input_spec.rb +0 -816
- data/spec/inputs/password_input_spec.rb +0 -100
- data/spec/inputs/phone_input_spec.rb +0 -86
- data/spec/inputs/radio_input_spec.rb +0 -267
- data/spec/inputs/range_input_spec.rb +0 -506
- data/spec/inputs/search_input_spec.rb +0 -85
- data/spec/inputs/select_input_spec.rb +0 -624
- data/spec/inputs/string_input_spec.rb +0 -210
- data/spec/inputs/text_input_spec.rb +0 -188
- data/spec/inputs/time_select_input_spec.rb +0 -191
- data/spec/inputs/time_zone_input_spec.rb +0 -118
- data/spec/inputs/url_input_spec.rb +0 -86
- data/spec/spec_helper.rb +0 -30
- data/spec/support/custom_macros.rb +0 -537
- data/spec/support/fb_custom_macros.rb +0 -23
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe 'range 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(@bob) do |builder|
|
|
16
|
-
concat(builder.input(:age, :as => :range))
|
|
17
|
-
end)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it_should_have_bootstrap_horizontal_wrapping
|
|
21
|
-
it_should_have_input_wrapper_with_class(:range)
|
|
22
|
-
it_should_have_input_wrapper_with_class(:input)
|
|
23
|
-
it_should_have_input_wrapper_with_class(:numeric)
|
|
24
|
-
it_should_have_input_wrapper_with_class(:stringish)
|
|
25
|
-
it_should_have_input_wrapper_with_id("author_age_input")
|
|
26
|
-
it_should_have_label_with_text(/Age/)
|
|
27
|
-
it_should_have_label_for("author_age")
|
|
28
|
-
it_should_have_input_with_id("author_age")
|
|
29
|
-
it_should_have_input_with_type(:range)
|
|
30
|
-
it_should_have_input_with_name("author[age]")
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe "when namespace is provided" do
|
|
35
|
-
|
|
36
|
-
before do
|
|
37
|
-
concat(semantic_form_for(@james, :namespace => "context2") do |builder|
|
|
38
|
-
concat(builder.input(:age, :as => :range))
|
|
39
|
-
end)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it_should_have_input_wrapper_with_id("context2_author_age_input")
|
|
43
|
-
it_should_have_label_and_input_with_id("context2_author_age")
|
|
44
|
-
|
|
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 => :range))
|
|
56
|
-
end)
|
|
57
|
-
end)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it 'should index the id of the control-group' do
|
|
61
|
-
output_buffer.should have_tag("div.control-group#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
|
-
|
|
74
|
-
|
|
75
|
-
describe "when validations require a minimum value (:greater_than)" do
|
|
76
|
-
before do
|
|
77
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
78
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
|
|
79
|
-
])
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "should allow :input_html to override :min" do
|
|
83
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
84
|
-
builder.input(:title, :as => :range, :input_html => { :min => 5 })
|
|
85
|
-
end)
|
|
86
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should allow :input_html to override :min through :in" do
|
|
90
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
91
|
-
builder.input(:title, :as => :range, :input_html => { :in => 5..102 })
|
|
92
|
-
end)
|
|
93
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should allow options to override :min" do
|
|
97
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
98
|
-
builder.input(:title, :as => :range, :min => 5)
|
|
99
|
-
end)
|
|
100
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "should allow options to override :min through :in" do
|
|
104
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
105
|
-
builder.input(:title, :as => :range, :in => 5..102)
|
|
106
|
-
end)
|
|
107
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
describe "and the column is an integer" do
|
|
111
|
-
before do
|
|
112
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "should add a min attribute to the input one greater than the validation" do
|
|
116
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
117
|
-
builder.input(:title, :as => :range)
|
|
118
|
-
end)
|
|
119
|
-
output_buffer.should have_tag('input[@min="3"]')
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
describe "and the column is a float" do
|
|
124
|
-
before do
|
|
125
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "should raise an error" do
|
|
129
|
-
lambda {
|
|
130
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
131
|
-
builder.input(:title, :as => :range)
|
|
132
|
-
end)
|
|
133
|
-
}.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
describe "and the column is a big decimal" do
|
|
138
|
-
before do
|
|
139
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "should raise an error" do
|
|
143
|
-
lambda {
|
|
144
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
145
|
-
builder.input(:title, :as => :range)
|
|
146
|
-
end)
|
|
147
|
-
}.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
describe "when validations require a minimum value (:greater_than_or_equal_to)" do
|
|
154
|
-
before do
|
|
155
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
156
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=>2})
|
|
157
|
-
])
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "should allow :input_html to override :min" do
|
|
161
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
162
|
-
builder.input(:title, :as => :range, :input_html => { :min => 5 })
|
|
163
|
-
end)
|
|
164
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it "should allow options to override :min" do
|
|
168
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
169
|
-
builder.input(:title, :as => :range, :min => 5)
|
|
170
|
-
end)
|
|
171
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "should allow :input_html to override :min with :in" do
|
|
175
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
176
|
-
builder.input(:title, :as => :range, :input_html => { :in => 5..102 })
|
|
177
|
-
end)
|
|
178
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
it "should allow options to override :min with :in" do
|
|
182
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
183
|
-
builder.input(:title, :as => :range, :in => 5..102)
|
|
184
|
-
end)
|
|
185
|
-
output_buffer.should have_tag('input[@min="5"]')
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
[:integer, :decimal, :float].each do |column_type|
|
|
190
|
-
describe "and the column is a #{column_type}" do
|
|
191
|
-
before do
|
|
192
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it "should add a max attribute to the input equal to the validation" do
|
|
196
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
197
|
-
builder.input(:title, :as => :range)
|
|
198
|
-
end)
|
|
199
|
-
output_buffer.should have_tag('input[@min="2"]')
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
describe "and there is no column" do
|
|
205
|
-
before do
|
|
206
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "should add a max attribute to the input equal to the validation" do
|
|
210
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
211
|
-
builder.input(:title, :as => :range)
|
|
212
|
-
end)
|
|
213
|
-
output_buffer.should have_tag('input[@min="2"]')
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
describe "when validations do not require a minimum value" do
|
|
219
|
-
|
|
220
|
-
it "should default to 1" do
|
|
221
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
222
|
-
builder.input(:title, :as => :range)
|
|
223
|
-
end)
|
|
224
|
-
output_buffer.should have_tag('input[@min="1"]')
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
describe "when validations require a maximum value (:less_than)" do
|
|
230
|
-
before do
|
|
231
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
232
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=>20})
|
|
233
|
-
])
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it "should allow :input_html to override :max" do
|
|
237
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
238
|
-
builder.input(:title, :as => :range, :input_html => { :max => 102 })
|
|
239
|
-
end)
|
|
240
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it "should allow option to override :max" do
|
|
244
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
245
|
-
builder.input(:title, :as => :range, :max => 102)
|
|
246
|
-
end)
|
|
247
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it "should allow :input_html to override :max with :in" do
|
|
251
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
252
|
-
builder.input(:title, :as => :range, :input_html => { :in => 1..102 })
|
|
253
|
-
end)
|
|
254
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
it "should allow option to override :max with :in" do
|
|
258
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
259
|
-
builder.input(:title, :as => :range, :in => 1..102)
|
|
260
|
-
end)
|
|
261
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
describe "and the column is an integer" do
|
|
265
|
-
before do
|
|
266
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
it "should add a max attribute to the input one greater than the validation" do
|
|
270
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
271
|
-
builder.input(:title, :as => :range)
|
|
272
|
-
end)
|
|
273
|
-
output_buffer.should have_tag('input[@max="19"]')
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
describe "and the column is a float" do
|
|
278
|
-
before do
|
|
279
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
it "should raise an error" do
|
|
283
|
-
lambda {
|
|
284
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
285
|
-
builder.input(:title, :as => :range)
|
|
286
|
-
end)
|
|
287
|
-
}.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
describe "and the column is a big decimal" do
|
|
292
|
-
before do
|
|
293
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
it "should raise an error" do
|
|
297
|
-
lambda {
|
|
298
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
299
|
-
builder.input(:title, :as => :range)
|
|
300
|
-
end)
|
|
301
|
-
}.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
|
|
302
|
-
end
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
describe "when validations require a maximum value (:less_than_or_equal_to)" do
|
|
308
|
-
before do
|
|
309
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
310
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=>20})
|
|
311
|
-
])
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
it "should allow :input_html to override :max" do
|
|
315
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
316
|
-
builder.input(:title, :as => :range, :input_html => { :max => 102 })
|
|
317
|
-
end)
|
|
318
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it "should allow options to override :max" do
|
|
322
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
323
|
-
builder.input(:title, :as => :range, :max => 102)
|
|
324
|
-
end)
|
|
325
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
it "should allow :input_html to override :max with :in" do
|
|
329
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
330
|
-
builder.input(:title, :as => :range, :input_html => { :in => 1..102 })
|
|
331
|
-
end)
|
|
332
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
it "should allow options to override :max with :in" do
|
|
336
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
337
|
-
builder.input(:title, :as => :range, :in => 1..102)
|
|
338
|
-
end)
|
|
339
|
-
output_buffer.should have_tag('input[@max="102"]')
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
[:integer, :decimal, :float].each do |column_type|
|
|
343
|
-
describe "and the column is a #{column_type}" do
|
|
344
|
-
before do
|
|
345
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
it "should add a max attribute to the input equal to the validation" do
|
|
349
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
350
|
-
builder.input(:title, :as => :range)
|
|
351
|
-
end)
|
|
352
|
-
output_buffer.should have_tag('input[@max="20"]')
|
|
353
|
-
end
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
describe "and there is no column" do
|
|
358
|
-
before do
|
|
359
|
-
@new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
it "should add a max attribute to the input equal to the validation" do
|
|
363
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
364
|
-
builder.input(:title, :as => :range)
|
|
365
|
-
end)
|
|
366
|
-
output_buffer.should have_tag('input[@max="20"]')
|
|
367
|
-
end
|
|
368
|
-
end
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
describe "when validations do not require a maximum value" do
|
|
372
|
-
|
|
373
|
-
it "should default to 1" do
|
|
374
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
375
|
-
builder.input(:title, :as => :range)
|
|
376
|
-
end)
|
|
377
|
-
output_buffer.should have_tag('input[@max="100"]')
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
describe "when validations require conflicting minimum values (:greater_than, :greater_than_or_equal_to)" do
|
|
383
|
-
before do
|
|
384
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
385
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than => 20, :greater_than_or_equal_to=>2})
|
|
386
|
-
])
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
it "should add a max attribute to the input equal to the :greater_than_or_equal_to validation" do
|
|
390
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
391
|
-
builder.input(:title, :as => :range)
|
|
392
|
-
end)
|
|
393
|
-
output_buffer.should have_tag('input[@min="2"]')
|
|
394
|
-
end
|
|
395
|
-
end
|
|
396
|
-
|
|
397
|
-
describe "when validations require conflicting maximum values (:less_than, :less_than_or_equal_to)" do
|
|
398
|
-
before do
|
|
399
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
400
|
-
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than => 20, :less_than_or_equal_to=>2})
|
|
401
|
-
])
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
it "should add a max attribute to the input equal to the :greater_than_or_equal_to validation" do
|
|
405
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
406
|
-
builder.input(:title, :as => :range)
|
|
407
|
-
end)
|
|
408
|
-
output_buffer.should have_tag('input[@max="2"]')
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
describe "when validations require only an integer (:only_integer)" do
|
|
413
|
-
|
|
414
|
-
before do
|
|
415
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
416
|
-
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true})
|
|
417
|
-
])
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
it "should add a step=1 attribute to the input to signify that only whole numbers are allowed" do
|
|
421
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
422
|
-
builder.input(:title, :as => :range)
|
|
423
|
-
end)
|
|
424
|
-
output_buffer.should have_tag('input[@step="1"]')
|
|
425
|
-
end
|
|
426
|
-
|
|
427
|
-
it "should let input_html override :step" do
|
|
428
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
429
|
-
builder.input(:title, :as => :range, :input_html => { :step => 3 })
|
|
430
|
-
end)
|
|
431
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
it "should let options override :step" do
|
|
435
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
436
|
-
builder.input(:title, :as => :range, :step => 3)
|
|
437
|
-
end)
|
|
438
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
end
|
|
442
|
-
|
|
443
|
-
describe "when validations require a :step (non standard)" do
|
|
444
|
-
|
|
445
|
-
before do
|
|
446
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
447
|
-
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true, :step=>2})
|
|
448
|
-
])
|
|
449
|
-
end
|
|
450
|
-
|
|
451
|
-
it "should add a step=1 attribute to the input to signify that only whole numbers are allowed" do
|
|
452
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
453
|
-
builder.input(:title, :as => :range)
|
|
454
|
-
end)
|
|
455
|
-
output_buffer.should have_tag('input[@step="2"]')
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
it "should let input_html override :step" do
|
|
459
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
460
|
-
builder.input(:title, :as => :range, :input_html => { :step => 3 })
|
|
461
|
-
end)
|
|
462
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
it "should let options override :step" do
|
|
466
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
467
|
-
builder.input(:title, :as => :range, :step => 3)
|
|
468
|
-
end)
|
|
469
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
end
|
|
473
|
-
|
|
474
|
-
describe "when validations do not specify :step (non standard) or :only_integer" do
|
|
475
|
-
|
|
476
|
-
before do
|
|
477
|
-
@new_post.class.stub!(:validators_on).with(:title).and_return([
|
|
478
|
-
active_model_numericality_validator([:title], {:allow_nil=>false})
|
|
479
|
-
])
|
|
480
|
-
end
|
|
481
|
-
|
|
482
|
-
it "should default step to 1" do
|
|
483
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
484
|
-
builder.input(:title, :as => :range)
|
|
485
|
-
end)
|
|
486
|
-
output_buffer.should have_tag('input[@step="1"]')
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
it "should let input_html set :step" do
|
|
490
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
491
|
-
builder.input(:title, :as => :range, :input_html => { :step => 3 })
|
|
492
|
-
end)
|
|
493
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
it "should let options set :step" do
|
|
497
|
-
concat(semantic_form_for(@new_post) do |builder|
|
|
498
|
-
builder.input(:title, :as => :range, :step => 3)
|
|
499
|
-
end)
|
|
500
|
-
output_buffer.should have_tag('input[@step="3"]')
|
|
501
|
-
end
|
|
502
|
-
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
end
|
|
506
|
-
|