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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formtastic-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: formtastic
|
16
|
-
requirement: &
|
15
|
+
name: formtastic-bootstrap
|
16
|
+
requirement: &2157952340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,32 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157952340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: formtastic
|
27
|
+
requirement: &2157951260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: '2.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157951260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157950260 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2157950260
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &2157948480 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,65 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157948480
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &2157946680 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2157946680
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
requirement: &2157945240 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2157945240
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rspec_tag_matchers
|
82
|
+
requirement: &2157944560 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2157944560
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: ammeter
|
93
|
+
requirement: &2157943720 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2157943720
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: rspec-rails
|
104
|
+
requirement: &2157923220 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.8.0
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2157923220
|
47
113
|
- !ruby/object:Gem::Dependency
|
48
114
|
name: bundler
|
49
|
-
requirement: &
|
115
|
+
requirement: &2157921660 !ruby/object:Gem::Requirement
|
50
116
|
none: false
|
51
117
|
requirements:
|
52
118
|
- - ! '>='
|
@@ -54,10 +120,10 @@ dependencies:
|
|
54
120
|
version: '0'
|
55
121
|
type: :development
|
56
122
|
prerelease: false
|
57
|
-
version_requirements: *
|
123
|
+
version_requirements: *2157921660
|
58
124
|
- !ruby/object:Gem::Dependency
|
59
125
|
name: jeweler
|
60
|
-
requirement: &
|
126
|
+
requirement: &2157920520 !ruby/object:Gem::Requirement
|
61
127
|
none: false
|
62
128
|
requirements:
|
63
129
|
- - ! '>='
|
@@ -65,10 +131,10 @@ dependencies:
|
|
65
131
|
version: '0'
|
66
132
|
type: :development
|
67
133
|
prerelease: false
|
68
|
-
version_requirements: *
|
134
|
+
version_requirements: *2157920520
|
69
135
|
- !ruby/object:Gem::Dependency
|
70
136
|
name: rcov
|
71
|
-
requirement: &
|
137
|
+
requirement: &2157919740 !ruby/object:Gem::Requirement
|
72
138
|
none: false
|
73
139
|
requirements:
|
74
140
|
- - ! '>='
|
@@ -76,10 +142,10 @@ dependencies:
|
|
76
142
|
version: '0'
|
77
143
|
type: :development
|
78
144
|
prerelease: false
|
79
|
-
version_requirements: *
|
145
|
+
version_requirements: *2157919740
|
80
146
|
- !ruby/object:Gem::Dependency
|
81
147
|
name: rspec_tag_matchers
|
82
|
-
requirement: &
|
148
|
+
requirement: &2157918220 !ruby/object:Gem::Requirement
|
83
149
|
none: false
|
84
150
|
requirements:
|
85
151
|
- - ! '>='
|
@@ -87,7 +153,7 @@ dependencies:
|
|
87
153
|
version: '0'
|
88
154
|
type: :development
|
89
155
|
prerelease: false
|
90
|
-
version_requirements: *
|
156
|
+
version_requirements: *2157918220
|
91
157
|
description: Formtastic form builder to generate Twitter Bootstrap-friendly markup.
|
92
158
|
email: mjbellantoni@yahoo.com
|
93
159
|
executables: []
|
@@ -107,27 +173,38 @@ files:
|
|
107
173
|
- formtastic-bootstrap.gemspec
|
108
174
|
- lib/action_view/helpers/text_field_date_helper.rb
|
109
175
|
- lib/formtastic-bootstrap.rb
|
176
|
+
- lib/formtastic-bootstrap/actions.rb
|
177
|
+
- lib/formtastic-bootstrap/actions/base.rb
|
178
|
+
- lib/formtastic-bootstrap/actions/button_action.rb
|
179
|
+
- lib/formtastic-bootstrap/actions/input_action.rb
|
180
|
+
- lib/formtastic-bootstrap/actions/link_action.rb
|
110
181
|
- lib/formtastic-bootstrap/engine.rb
|
111
182
|
- lib/formtastic-bootstrap/form_builder.rb
|
112
183
|
- lib/formtastic-bootstrap/helpers.rb
|
113
|
-
- lib/formtastic-bootstrap/helpers/
|
184
|
+
- lib/formtastic-bootstrap/helpers/action_helper.rb
|
185
|
+
- lib/formtastic-bootstrap/helpers/actions_helper.rb
|
114
186
|
- lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb
|
115
187
|
- lib/formtastic-bootstrap/helpers/input_helper.rb
|
116
188
|
- lib/formtastic-bootstrap/helpers/inputs_helper.rb
|
117
189
|
- lib/formtastic-bootstrap/inputs.rb
|
118
190
|
- lib/formtastic-bootstrap/inputs/base.rb
|
119
191
|
- lib/formtastic-bootstrap/inputs/base/choices.rb
|
192
|
+
- lib/formtastic-bootstrap/inputs/base/collections.rb
|
120
193
|
- lib/formtastic-bootstrap/inputs/base/errors.rb
|
194
|
+
- lib/formtastic-bootstrap/inputs/base/grouped_collections.rb
|
121
195
|
- lib/formtastic-bootstrap/inputs/base/hints.rb
|
122
196
|
- lib/formtastic-bootstrap/inputs/base/html.rb
|
123
197
|
- lib/formtastic-bootstrap/inputs/base/labelling.rb
|
198
|
+
- lib/formtastic-bootstrap/inputs/base/numeric.rb
|
124
199
|
- lib/formtastic-bootstrap/inputs/base/stringish.rb
|
125
200
|
- lib/formtastic-bootstrap/inputs/base/timeish.rb
|
126
201
|
- lib/formtastic-bootstrap/inputs/base/wrapping.rb
|
127
202
|
- lib/formtastic-bootstrap/inputs/boolean_input.rb
|
128
203
|
- lib/formtastic-bootstrap/inputs/check_boxes_input.rb
|
129
204
|
- lib/formtastic-bootstrap/inputs/date_input.rb
|
205
|
+
- lib/formtastic-bootstrap/inputs/date_select_input.rb
|
130
206
|
- lib/formtastic-bootstrap/inputs/datetime_input.rb
|
207
|
+
- lib/formtastic-bootstrap/inputs/datetime_select_input.rb
|
131
208
|
- lib/formtastic-bootstrap/inputs/email_input.rb
|
132
209
|
- lib/formtastic-bootstrap/inputs/file_input.rb
|
133
210
|
- lib/formtastic-bootstrap/inputs/hidden_input.rb
|
@@ -141,17 +218,22 @@ files:
|
|
141
218
|
- lib/formtastic-bootstrap/inputs/string_input.rb
|
142
219
|
- lib/formtastic-bootstrap/inputs/text_input.rb
|
143
220
|
- lib/formtastic-bootstrap/inputs/time_input.rb
|
221
|
+
- lib/formtastic-bootstrap/inputs/time_select_input.rb
|
144
222
|
- lib/formtastic-bootstrap/inputs/time_zone_input.rb
|
145
223
|
- lib/formtastic-bootstrap/inputs/url_input.rb
|
146
|
-
- spec/
|
224
|
+
- spec/actions/button_action_spec.rb
|
225
|
+
- spec/actions/input_action_spec.rb
|
226
|
+
- spec/actions/link_action_spec.rb
|
147
227
|
- spec/builder/semantic_fields_for_spec.rb
|
148
|
-
- spec/helpers/
|
228
|
+
- spec/helpers/action_helper_spec.rb
|
229
|
+
- spec/helpers/actions_helper_spec.rb
|
149
230
|
- spec/helpers/input_helper_spec.rb
|
150
231
|
- spec/helpers/inputs_helper_spec.rb
|
151
232
|
- spec/inputs/boolean_input_spec.rb
|
152
233
|
- spec/inputs/check_boxes_input_spec.rb
|
153
|
-
- spec/inputs/
|
154
|
-
- spec/inputs/
|
234
|
+
- spec/inputs/date_select_input_spec.rb
|
235
|
+
- spec/inputs/datetime_select_input_spec.rb
|
236
|
+
- spec/inputs/deprecated_time_date_datetime_inputs_spec.rb
|
155
237
|
- spec/inputs/email_input_spec.rb
|
156
238
|
- spec/inputs/file_input_spec.rb
|
157
239
|
- spec/inputs/hidden_input_spec.rb
|
@@ -164,13 +246,12 @@ files:
|
|
164
246
|
- spec/inputs/select_input_spec.rb
|
165
247
|
- spec/inputs/string_input_spec.rb
|
166
248
|
- spec/inputs/text_input_spec.rb
|
167
|
-
- spec/inputs/
|
249
|
+
- spec/inputs/time_select_input_spec.rb
|
168
250
|
- spec/inputs/time_zone_input_spec.rb
|
169
251
|
- spec/inputs/url_input_spec.rb
|
170
252
|
- spec/spec_helper.rb
|
171
253
|
- spec/support/custom_macros.rb
|
172
|
-
- spec/support/
|
173
|
-
- spec/support/formtastic_spec_helper.rb
|
254
|
+
- spec/support/fb_custom_macros.rb
|
174
255
|
- vendor/assets/stylesheets/formtastic-bootstrap.css
|
175
256
|
homepage: http://github.com/mjbellantoni/formtastic-bootstrap
|
176
257
|
licenses:
|
@@ -187,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
268
|
version: '0'
|
188
269
|
segments:
|
189
270
|
- 0
|
190
|
-
hash:
|
271
|
+
hash: 449140475497354542
|
191
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
273
|
none: false
|
193
274
|
requirements:
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module FormtasticBootstrap
|
2
|
-
module Helpers
|
3
|
-
module ButtonsHelper
|
4
|
-
|
5
|
-
include Formtastic::Helpers::ButtonsHelper
|
6
|
-
|
7
|
-
def buttons(*args, &block)
|
8
|
-
|
9
|
-
html_options = args.extract_options!
|
10
|
-
html_options[:class] ||= "actions"
|
11
|
-
|
12
|
-
if html_options.has_key?(:name)
|
13
|
-
ActiveSupport::Deprecation.warn('The :name option is not supported')
|
14
|
-
end
|
15
|
-
|
16
|
-
if block_given?
|
17
|
-
template.content_tag(:div, html_options) do
|
18
|
-
yield
|
19
|
-
end
|
20
|
-
else
|
21
|
-
args = [:commit] if args.empty?
|
22
|
-
contents = args.map { |button_name| send(:"#{button_name}_button") }
|
23
|
-
template.content_tag(:div, html_options.except(:builder, :parent, :name)) do
|
24
|
-
Formtastic::Util.html_safe(contents.join)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def commit_button(*args)
|
31
|
-
options = args.extract_options!
|
32
|
-
text = options.delete(:label) || args.shift
|
33
|
-
|
34
|
-
text = (localized_string(commit_button_i18n_key, text, :action, :model => commit_button_object_name) ||
|
35
|
-
Formtastic::I18n.t(commit_button_i18n_key, :model => commit_button_object_name)) unless text.is_a?(::String)
|
36
|
-
|
37
|
-
button_html = options.delete(:button_html) || {}
|
38
|
-
button_html.merge!(:class => [button_html[:class], "btn commit", commit_button_i18n_key].compact.join(' '))
|
39
|
-
|
40
|
-
# TODO We don't have a wrapper. Add deprecation message.
|
41
|
-
# wrapper_html = options.delete(:wrapper_html) || {}
|
42
|
-
# wrapper_html[:class] = (commit_button_wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')
|
43
|
-
|
44
|
-
accesskey = (options.delete(:accesskey) || default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
|
45
|
-
button_html = button_html.merge(:accesskey => accesskey) if accesskey
|
46
|
-
|
47
|
-
Formtastic::Util.html_safe(submit(text, button_html))
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/spec/builder/errors_spec.rb
DELETED
@@ -1,214 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'Formtastic::FormBuilder#errors_on' do
|
5
|
-
|
6
|
-
include FormtasticSpecHelper
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@output_buffer = ''
|
10
|
-
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
|
-
@title_errors = ['must not be blank', 'must be longer than 10 characters', 'must be awesome']
|
13
|
-
@errors = mock('errors')
|
14
|
-
@new_post.stub!(:errors).and_return(@errors)
|
15
|
-
|
16
|
-
@orig_inline_errors = FormtasticBootstrap::FormBuilder.inline_errors
|
17
|
-
@orig_inline_error_class = FormtasticBootstrap::FormBuilder.default_inline_error_class
|
18
|
-
@orig_error_list_class = FormtasticBootstrap::FormBuilder.default_error_list_class
|
19
|
-
end
|
20
|
-
|
21
|
-
after(:each) do
|
22
|
-
FormtasticBootstrap::FormBuilder.inline_errors = @orig_inline_errors
|
23
|
-
FormtasticBootstrap::FormBuilder.default_inline_error_class = @orig_inline_error_class
|
24
|
-
FormtasticBootstrap::FormBuilder.default_error_list_class = @orig_error_list_class
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'when there are errors' do
|
28
|
-
before do
|
29
|
-
@errors.stub!(:[]).with(:title).and_return(@title_errors)
|
30
|
-
end
|
31
|
-
|
32
|
-
# after do
|
33
|
-
# FormtasticBootstrap::FormBuilder.default_inline_error_class = 'inline-errors'
|
34
|
-
# FormtasticBootstrap::FormBuilder.default_inline_error_class = 'help-inline'
|
35
|
-
# FormtasticBootstrap::FormBuilder.default_error_list_class = 'errors'
|
36
|
-
# end
|
37
|
-
|
38
|
-
it 'should render a paragraph with the errors joined into a sentence when inline_errors config is :sentence' do
|
39
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :sentence
|
40
|
-
concat(semantic_form_for(@new_post) do |builder|
|
41
|
-
builder.input :title
|
42
|
-
end)
|
43
|
-
output_buffer.should have_tag('span.help-inline', @title_errors.to_sentence)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should render a paragraph with a overridden default class' do
|
47
|
-
FormtasticBootstrap::FormBuilder.default_inline_error_class = 'better-errors'
|
48
|
-
concat(semantic_form_for(@new_post) do |builder|
|
49
|
-
builder.input(:title)
|
50
|
-
end)
|
51
|
-
output_buffer.should have_tag('span.better-errors', @title_errors.to_sentence)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should render a paragraph with the errors joined into a sentence when inline_errors config is :sentence with a customized error class' do
|
55
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :sentence
|
56
|
-
concat(semantic_form_for(@new_post) do |builder|
|
57
|
-
builder.input(:title, :error_class => 'better-errors')
|
58
|
-
end)
|
59
|
-
output_buffer.should have_tag('span.better-errors', @title_errors.to_sentence)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should render an unordered list with the class errors when inline_errors config is :list' do
|
63
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :list
|
64
|
-
concat(semantic_form_for(@new_post) do |builder|
|
65
|
-
builder.input(:title)
|
66
|
-
end)
|
67
|
-
output_buffer.should have_tag('ul.errors')
|
68
|
-
@title_errors.each do |error|
|
69
|
-
output_buffer.should have_tag('ul.errors li', error)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should render an unordered list with the class overridden default class' do
|
74
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :list
|
75
|
-
FormtasticBootstrap::FormBuilder.default_error_list_class = "better-errors"
|
76
|
-
concat(semantic_form_for(@new_post) do |builder|
|
77
|
-
builder.input :title
|
78
|
-
end)
|
79
|
-
output_buffer.should have_tag('ul.better-errors')
|
80
|
-
@title_errors.each do |error|
|
81
|
-
output_buffer.should have_tag('ul.better-errors li', error)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should render an unordered list with the class errors when inline_errors config is :list with a customized error class' do
|
86
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :list
|
87
|
-
concat(semantic_form_for(@new_post) do |builder|
|
88
|
-
builder.input :title, :error_class => "better-errors"
|
89
|
-
end)
|
90
|
-
output_buffer.should have_tag('ul.better-errors')
|
91
|
-
@title_errors.each do |error|
|
92
|
-
output_buffer.should have_tag('ul.better-errors li', error)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should render a paragraph with the first error when inline_errors config is :first' do
|
97
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :first
|
98
|
-
concat(semantic_form_for(@new_post) do |builder|
|
99
|
-
builder.input :title
|
100
|
-
end)
|
101
|
-
output_buffer.should have_tag('span.help-inline', @title_errors.first)
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should render a paragraph with the first error when inline_errors config is :first with a customized error class' do
|
105
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :first
|
106
|
-
concat(semantic_form_for(@new_post) do |builder|
|
107
|
-
builder.input :title, :error_class => "better-errors"
|
108
|
-
end)
|
109
|
-
output_buffer.should have_tag('span.better-errors', @title_errors.first)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should return nil when inline_errors config is :none' do
|
113
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :none
|
114
|
-
concat(semantic_form_for(@new_post) do |builder|
|
115
|
-
builder.input :title
|
116
|
-
end)
|
117
|
-
output_buffer.should_not have_tag('span.help-inline')
|
118
|
-
output_buffer.should_not have_tag('span.help-block')
|
119
|
-
output_buffer.should_not have_tag('ul.errors')
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should allow calling deprecated errors_on and inline_errors_for helpers' do
|
123
|
-
FormtasticBootstrap::FormBuilder.inline_errors = :sentence
|
124
|
-
with_deprecation_silenced do
|
125
|
-
concat(semantic_form_for(@new_post) do |builder|
|
126
|
-
builder.errors_on :title
|
127
|
-
builder.inline_errors_for :title
|
128
|
-
end)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe 'when there are no errors (nil)' do
|
134
|
-
before do
|
135
|
-
@errors.stub!(:[]).with(:title).and_return(nil)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should return nil when inline_errors config is :sentence, :list or :none' do
|
139
|
-
with_deprecation_silenced do
|
140
|
-
[:sentence, :list, :none].each do |config|
|
141
|
-
with_config :inline_errors, config do
|
142
|
-
semantic_form_for(@new_post) do |builder|
|
143
|
-
builder.errors_on(:title).should be_nil
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe 'when there are no errors (empty array)' do
|
152
|
-
|
153
|
-
before(:each) do
|
154
|
-
@errors.stub!(:[]).with(:title).and_return([])
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should return nil when inline_errors config is :sentence, :list or :none' do
|
158
|
-
with_deprecation_silenced do
|
159
|
-
[:sentence, :list, :none].each do |config|
|
160
|
-
FormtasticBootstrap::FormBuilder.inline_errors = config
|
161
|
-
semantic_form_for(@new_post) do |builder|
|
162
|
-
builder.errors_on(:title).should be_nil
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe 'when file type columns have errors' do
|
170
|
-
it "should list errors added on metadata fields" do
|
171
|
-
@errors.stub!(:[]).with(:document_file_name).and_return(['must be provided'])
|
172
|
-
@errors.stub!(:[]).with(:document_file_size).and_return(['must be less than 4mb'])
|
173
|
-
@errors.stub!(:[]).with(:document_content_type).and_return(['must be an image'])
|
174
|
-
@errors.stub!(:[]).with(:document).and_return(nil)
|
175
|
-
|
176
|
-
with_config :inline_errors, :sentence do
|
177
|
-
concat(semantic_form_for(@new_post) do |builder|
|
178
|
-
concat(builder.input(:document))
|
179
|
-
end)
|
180
|
-
end
|
181
|
-
output_buffer.should have_tag("div.error")
|
182
|
-
output_buffer.should have_tag('span.help-inline', (['must be an image','must be provided', 'must be less than 4mb']).to_sentence)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe 'when there are errors on the association and column' do
|
187
|
-
|
188
|
-
it "should list all unique errors" do
|
189
|
-
::Post.stub!(:reflections).and_return({:author => mock('reflection', :options => {}, :macro => :belongs_to)})
|
190
|
-
|
191
|
-
@errors.stub!(:[]).with(:author).and_return(['must not be blank'])
|
192
|
-
@errors.stub!(:[]).with(:author_id).and_return(['is already taken', 'must not be blank']) # note the duplicate of association
|
193
|
-
|
194
|
-
with_config :inline_errors, :list do
|
195
|
-
concat(semantic_form_for(@new_post) do |builder|
|
196
|
-
concat(builder.input(:author))
|
197
|
-
end)
|
198
|
-
end
|
199
|
-
output_buffer.should have_tag("ul.errors li", /must not be blank/, :count => 1)
|
200
|
-
output_buffer.should have_tag("ul.errors li", /is already taken/, :count => 1)
|
201
|
-
end
|
202
|
-
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "when there are errors on a has_many association" do
|
206
|
-
it "should include the association ids error messages" do
|
207
|
-
semantic_form_for(@new_post) do |builder|
|
208
|
-
builder.send(:error_keys, :sub_posts, {}).should include(:sub_post_ids)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
|
@@ -1,149 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'Formtastic::FormBuilder#buttons' do
|
5
|
-
|
6
|
-
include FormtasticSpecHelper
|
7
|
-
|
8
|
-
before do
|
9
|
-
@output_buffer = ''
|
10
|
-
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'with a block' do
|
15
|
-
describe 'when no options are provided' do
|
16
|
-
before do
|
17
|
-
concat(semantic_form_for(@new_post) do |builder|
|
18
|
-
buttons = builder.buttons do
|
19
|
-
concat('hello')
|
20
|
-
end
|
21
|
-
concat(buttons)
|
22
|
-
end)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should render a div inside the form, with a class of "actions"' do
|
26
|
-
output_buffer.should have_tag("form div.actions")
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should not render an ol inside the div' do
|
30
|
-
output_buffer.should_not have_tag("form div.actions ol")
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should render the contents of the block inside the input' do
|
34
|
-
output_buffer.should have_tag("form div.actions", /hello/)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should not render a legend inside the div' do
|
38
|
-
output_buffer.should_not have_tag("form div.actions legend")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe 'when other options are provided' do
|
43
|
-
before do
|
44
|
-
@id_option = 'advanced'
|
45
|
-
@class_option = 'wide'
|
46
|
-
|
47
|
-
concat(semantic_form_for(@new_post) do |builder|
|
48
|
-
builder.buttons :id => @id_option, :class => @class_option do
|
49
|
-
end
|
50
|
-
end)
|
51
|
-
end
|
52
|
-
it 'should pass the options into the div tag as attributes' do
|
53
|
-
output_buffer.should have_tag("form div##{@id_option}")
|
54
|
-
output_buffer.should have_tag("form div.#{@class_option}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'without a block' do
|
61
|
-
|
62
|
-
describe 'with no args (default buttons)' do
|
63
|
-
|
64
|
-
before do
|
65
|
-
concat(semantic_form_for(@new_post) do |builder|
|
66
|
-
concat(builder.buttons)
|
67
|
-
end)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should render a form' do
|
71
|
-
output_buffer.should have_tag('form')
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should render a "actions" div inside the form' do
|
75
|
-
output_buffer.should have_tag('form div.actions')
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should not render a legend in the div' do
|
79
|
-
output_buffer.should_not have_tag('form div.actions legend')
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should render an button item in the ol for each default button' do
|
83
|
-
output_buffer.should have_tag('form div.actions input.btn', :count => 1)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should render a commit list item for the commit button' do
|
87
|
-
output_buffer.should have_tag('form div.actions input.commit')
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'with button names as args' do
|
93
|
-
|
94
|
-
before do
|
95
|
-
concat(semantic_form_for(@new_post) do |builder|
|
96
|
-
concat(builder.buttons(:commit))
|
97
|
-
end)
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should render a form with a div containing an input for each button arg' do
|
101
|
-
output_buffer.should have_tag('form > div.actions > input', :count => 1)
|
102
|
-
output_buffer.should have_tag('form > div.actions > input.commit')
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
describe 'with :names' do
|
108
|
-
|
109
|
-
before do
|
110
|
-
ActiveSupport::Deprecation.should_receive(:warn)
|
111
|
-
concat(
|
112
|
-
semantic_form_for(@new_post) do |builder|
|
113
|
-
concat(builder.buttons(:commit, :name => "Now click a button"))
|
114
|
-
end
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should warn that \':name\' is not supported' do
|
119
|
-
# Assertion is above in the before block.
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
describe 'with button names and an options hash' do
|
126
|
-
|
127
|
-
before do
|
128
|
-
concat(
|
129
|
-
semantic_form_for(@new_post) do |builder|
|
130
|
-
concat(builder.buttons(:commit, :id => "my-id"))
|
131
|
-
end
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should render a form with a div containing a input for each button arg' do
|
136
|
-
output_buffer.should have_tag('form > div.actions > input', :count => 1)
|
137
|
-
output_buffer.should have_tag('form > div.actions > input.commit', :count => 1)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'should pass the options down to the div' do
|
141
|
-
output_buffer.should have_tag('form > div#my-id.actions')
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
|