simple_form 2.0.0 → 3.5.1
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.
Potentially problematic release.
This version of simple_form might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +97 -198
- data/MIT-LICENSE +1 -1
- data/README.md +572 -296
- data/lib/generators/simple_form/install_generator.rb +17 -7
- data/lib/generators/simple_form/templates/README +3 -4
- data/lib/generators/simple_form/templates/_form.html.erb +1 -0
- data/lib/generators/simple_form/templates/_form.html.haml +1 -0
- data/lib/generators/simple_form/templates/config/initializers/{simple_form.rb.tt → simple_form.rb} +57 -63
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +155 -0
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +111 -0
- data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +14 -7
- data/lib/simple_form/action_view_extensions/builder.rb +5 -305
- data/lib/simple_form/action_view_extensions/form_helper.rb +18 -20
- data/lib/simple_form/components/errors.rb +30 -3
- data/lib/simple_form/components/hints.rb +10 -3
- data/lib/simple_form/components/html5.rb +17 -3
- data/lib/simple_form/components/label_input.rb +21 -2
- data/lib/simple_form/components/labels.rb +16 -11
- data/lib/simple_form/components/maxlength.rb +19 -12
- data/lib/simple_form/components/min_max.rb +4 -2
- data/lib/simple_form/components/minlength.rb +48 -0
- data/lib/simple_form/components/pattern.rb +5 -4
- data/lib/simple_form/components/placeholders.rb +3 -2
- data/lib/simple_form/components/readonly.rb +3 -2
- data/lib/simple_form/components.rb +15 -11
- data/lib/simple_form/error_notification.rb +4 -3
- data/lib/simple_form/form_builder.rb +283 -105
- data/lib/simple_form/helpers/autofocus.rb +1 -0
- data/lib/simple_form/helpers/disabled.rb +1 -0
- data/lib/simple_form/helpers/readonly.rb +1 -0
- data/lib/simple_form/helpers/required.rb +1 -0
- data/lib/simple_form/helpers/validators.rb +4 -3
- data/lib/simple_form/helpers.rb +7 -6
- data/lib/simple_form/i18n_cache.rb +1 -0
- data/lib/simple_form/inputs/base.rb +76 -23
- data/lib/simple_form/inputs/block_input.rb +3 -2
- data/lib/simple_form/inputs/boolean_input.rb +55 -16
- data/lib/simple_form/inputs/collection_check_boxes_input.rb +2 -1
- data/lib/simple_form/inputs/collection_input.rb +41 -18
- data/lib/simple_form/inputs/collection_radio_buttons_input.rb +11 -19
- data/lib/simple_form/inputs/collection_select_input.rb +5 -2
- data/lib/simple_form/inputs/date_time_input.rb +23 -12
- data/lib/simple_form/inputs/file_input.rb +5 -2
- data/lib/simple_form/inputs/grouped_collection_select_input.rb +16 -3
- data/lib/simple_form/inputs/hidden_input.rb +5 -2
- data/lib/simple_form/inputs/numeric_input.rb +4 -8
- data/lib/simple_form/inputs/password_input.rb +6 -4
- data/lib/simple_form/inputs/priority_input.rb +5 -2
- data/lib/simple_form/inputs/range_input.rb +2 -1
- data/lib/simple_form/inputs/string_input.rb +6 -4
- data/lib/simple_form/inputs/text_input.rb +6 -3
- data/lib/simple_form/inputs.rb +20 -17
- data/lib/simple_form/map_type.rb +1 -0
- data/lib/simple_form/railtie.rb +15 -0
- data/lib/simple_form/tags.rb +69 -0
- data/lib/simple_form/version.rb +2 -1
- data/lib/simple_form/wrappers/builder.rb +12 -35
- data/lib/simple_form/wrappers/leaf.rb +29 -0
- data/lib/simple_form/wrappers/many.rb +12 -7
- data/lib/simple_form/wrappers/root.rb +7 -4
- data/lib/simple_form/wrappers/single.rb +12 -3
- data/lib/simple_form/wrappers.rb +3 -1
- data/lib/simple_form.rb +118 -63
- data/test/action_view_extensions/builder_test.rb +230 -164
- data/test/action_view_extensions/form_helper_test.rb +107 -39
- data/test/components/label_test.rb +105 -87
- data/test/form_builder/association_test.rb +131 -62
- data/test/form_builder/button_test.rb +15 -14
- data/test/form_builder/error_notification_test.rb +11 -10
- data/test/form_builder/error_test.rb +188 -34
- data/test/form_builder/general_test.rb +247 -102
- data/test/form_builder/hint_test.rb +59 -32
- data/test/form_builder/input_field_test.rb +138 -25
- data/test/form_builder/label_test.rb +84 -13
- data/test/form_builder/wrapper_test.rb +236 -33
- data/test/generators/simple_form_generator_test.rb +15 -4
- data/test/inputs/boolean_input_test.rb +147 -13
- data/test/inputs/collection_check_boxes_input_test.rb +166 -71
- data/test/inputs/collection_radio_buttons_input_test.rb +229 -113
- data/test/inputs/collection_select_input_test.rb +222 -85
- data/test/inputs/datetime_input_test.rb +134 -47
- data/test/inputs/disabled_test.rb +62 -21
- data/test/inputs/discovery_test.rb +70 -10
- data/test/inputs/file_input_test.rb +4 -3
- data/test/inputs/general_test.rb +90 -26
- data/test/inputs/grouped_collection_select_input_test.rb +88 -23
- data/test/inputs/hidden_input_test.rb +7 -5
- data/test/inputs/numeric_input_test.rb +56 -46
- data/test/inputs/priority_input_test.rb +31 -16
- data/test/inputs/readonly_test.rb +68 -27
- data/test/inputs/required_test.rb +63 -18
- data/test/inputs/string_input_test.rb +76 -51
- data/test/inputs/text_input_test.rb +21 -8
- data/test/simple_form_test.rb +9 -0
- data/test/support/discovery_inputs.rb +39 -2
- data/test/support/misc_helpers.rb +176 -20
- data/test/support/mock_controller.rb +13 -7
- data/test/support/models.rb +187 -71
- data/test/test_helper.rb +38 -39
- metadata +53 -39
- data/lib/simple_form/core_ext/hash.rb +0 -16
- data/test/support/mock_response.rb +0 -14
data/test/test_helper.rb
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
require 'bundler/setup'
|
|
3
3
|
|
|
4
|
-
require '
|
|
5
|
-
require 'mocha'
|
|
4
|
+
require 'minitest/autorun'
|
|
6
5
|
|
|
7
6
|
require 'active_model'
|
|
8
7
|
require 'action_controller'
|
|
9
8
|
require 'action_view'
|
|
9
|
+
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
|
|
10
|
+
|
|
10
11
|
require 'action_view/template'
|
|
11
12
|
|
|
12
|
-
# Rails 3.0.4 is missing this "deprecation" require.
|
|
13
|
-
require 'active_support/core_ext/module/deprecation'
|
|
14
13
|
require 'action_view/test_case'
|
|
15
14
|
|
|
16
15
|
module Rails
|
|
@@ -32,50 +31,45 @@ I18n.default_locale = :en
|
|
|
32
31
|
|
|
33
32
|
require 'country_select'
|
|
34
33
|
|
|
34
|
+
if defined?(HTMLSelector::NO_STRIP)
|
|
35
|
+
HTMLSelector::NO_STRIP << "label"
|
|
36
|
+
else
|
|
37
|
+
ActionDispatch::Assertions::NO_STRIP << "label"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if ActiveSupport::TestCase.respond_to?(:test_order=)
|
|
41
|
+
ActiveSupport::TestCase.test_order = :random
|
|
42
|
+
end
|
|
43
|
+
|
|
35
44
|
class ActionView::TestCase
|
|
36
45
|
include MiscHelpers
|
|
37
46
|
include SimpleForm::ActionViewExtensions::FormHelper
|
|
38
47
|
|
|
39
48
|
setup :set_controller
|
|
40
|
-
setup :
|
|
41
|
-
setup :setup_new_user
|
|
49
|
+
setup :setup_users
|
|
42
50
|
|
|
43
51
|
def set_controller
|
|
44
52
|
@controller = MockController.new
|
|
45
53
|
end
|
|
46
54
|
|
|
47
|
-
def
|
|
48
|
-
@
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
:
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
:
|
|
63
|
-
:
|
|
64
|
-
|
|
65
|
-
:age => 19,
|
|
66
|
-
:amount => 15,
|
|
67
|
-
:attempts => 1,
|
|
68
|
-
:company => [1]
|
|
69
|
-
}.merge(options))
|
|
70
|
-
|
|
71
|
-
@other_validating_user = OtherValidatingUser.new({
|
|
72
|
-
:id => 1,
|
|
73
|
-
:name => 'New in SimpleForm!',
|
|
74
|
-
:description => 'Hello!',
|
|
75
|
-
:created_at => Time.now,
|
|
76
|
-
:age => 19,
|
|
77
|
-
:company => 1
|
|
78
|
-
}.merge(options))
|
|
55
|
+
def setup_users(extra_attributes = {})
|
|
56
|
+
@user = User.build(extra_attributes)
|
|
57
|
+
@decorated_user = Decorator.new(@user)
|
|
58
|
+
|
|
59
|
+
@validating_user = ValidatingUser.build({
|
|
60
|
+
name: 'Tester McTesterson',
|
|
61
|
+
description: 'A test user of the most distinguised caliber',
|
|
62
|
+
home_picture: 'Home picture',
|
|
63
|
+
age: 19,
|
|
64
|
+
amount: 15,
|
|
65
|
+
attempts: 1,
|
|
66
|
+
company: [1]
|
|
67
|
+
}.merge!(extra_attributes))
|
|
68
|
+
|
|
69
|
+
@other_validating_user = OtherValidatingUser.build({
|
|
70
|
+
age: 19,
|
|
71
|
+
company: 1
|
|
72
|
+
}.merge!(extra_attributes))
|
|
79
73
|
end
|
|
80
74
|
|
|
81
75
|
def protect_against_forgery?
|
|
@@ -85,6 +79,11 @@ class ActionView::TestCase
|
|
|
85
79
|
def user_path(*args)
|
|
86
80
|
'/users'
|
|
87
81
|
end
|
|
82
|
+
|
|
83
|
+
def company_user_path(*args)
|
|
84
|
+
'/company/users'
|
|
85
|
+
end
|
|
86
|
+
|
|
88
87
|
alias :users_path :user_path
|
|
89
88
|
alias :super_user_path :user_path
|
|
90
89
|
alias :validating_user_path :user_path
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 3.5.1
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- José Valim
|
|
@@ -11,32 +10,50 @@ authors:
|
|
|
11
10
|
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
13
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
|
15
14
|
dependencies:
|
|
16
15
|
- !ruby/object:Gem::Dependency
|
|
17
16
|
name: activemodel
|
|
18
|
-
requirement:
|
|
19
|
-
none: false
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
20
18
|
requirements:
|
|
21
|
-
- -
|
|
19
|
+
- - ">"
|
|
22
20
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: '
|
|
21
|
+
version: '4'
|
|
22
|
+
- - "<"
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: '5.2'
|
|
24
25
|
type: :runtime
|
|
25
26
|
prerelease: false
|
|
26
|
-
version_requirements:
|
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '4'
|
|
32
|
+
- - "<"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '5.2'
|
|
27
35
|
- !ruby/object:Gem::Dependency
|
|
28
36
|
name: actionpack
|
|
29
|
-
requirement:
|
|
30
|
-
none: false
|
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
38
|
requirements:
|
|
32
|
-
- -
|
|
39
|
+
- - ">"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '4'
|
|
42
|
+
- - "<"
|
|
33
43
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
44
|
+
version: '5.2'
|
|
35
45
|
type: :runtime
|
|
36
46
|
prerelease: false
|
|
37
|
-
version_requirements:
|
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - ">"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '4'
|
|
52
|
+
- - "<"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.2'
|
|
38
55
|
description: Forms made easy!
|
|
39
|
-
email:
|
|
56
|
+
email: opensource@plataformatec.com.br
|
|
40
57
|
executables: []
|
|
41
58
|
extensions: []
|
|
42
59
|
extra_rdoc_files: []
|
|
@@ -44,16 +61,20 @@ files:
|
|
|
44
61
|
- CHANGELOG.md
|
|
45
62
|
- MIT-LICENSE
|
|
46
63
|
- README.md
|
|
64
|
+
- lib/generators/simple_form/USAGE
|
|
47
65
|
- lib/generators/simple_form/install_generator.rb
|
|
66
|
+
- lib/generators/simple_form/templates/README
|
|
48
67
|
- lib/generators/simple_form/templates/_form.html.erb
|
|
49
68
|
- lib/generators/simple_form/templates/_form.html.haml
|
|
50
69
|
- lib/generators/simple_form/templates/_form.html.slim
|
|
51
|
-
- lib/generators/simple_form/templates/config/initializers/simple_form.rb
|
|
70
|
+
- lib/generators/simple_form/templates/config/initializers/simple_form.rb
|
|
71
|
+
- lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
|
|
72
|
+
- lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
|
|
52
73
|
- lib/generators/simple_form/templates/config/locales/simple_form.en.yml
|
|
53
|
-
- lib/
|
|
54
|
-
- lib/generators/simple_form/USAGE
|
|
74
|
+
- lib/simple_form.rb
|
|
55
75
|
- lib/simple_form/action_view_extensions/builder.rb
|
|
56
76
|
- lib/simple_form/action_view_extensions/form_helper.rb
|
|
77
|
+
- lib/simple_form/components.rb
|
|
57
78
|
- lib/simple_form/components/errors.rb
|
|
58
79
|
- lib/simple_form/components/hints.rb
|
|
59
80
|
- lib/simple_form/components/html5.rb
|
|
@@ -61,20 +82,20 @@ files:
|
|
|
61
82
|
- lib/simple_form/components/labels.rb
|
|
62
83
|
- lib/simple_form/components/maxlength.rb
|
|
63
84
|
- lib/simple_form/components/min_max.rb
|
|
85
|
+
- lib/simple_form/components/minlength.rb
|
|
64
86
|
- lib/simple_form/components/pattern.rb
|
|
65
87
|
- lib/simple_form/components/placeholders.rb
|
|
66
88
|
- lib/simple_form/components/readonly.rb
|
|
67
|
-
- lib/simple_form/components.rb
|
|
68
|
-
- lib/simple_form/core_ext/hash.rb
|
|
69
89
|
- lib/simple_form/error_notification.rb
|
|
70
90
|
- lib/simple_form/form_builder.rb
|
|
91
|
+
- lib/simple_form/helpers.rb
|
|
71
92
|
- lib/simple_form/helpers/autofocus.rb
|
|
72
93
|
- lib/simple_form/helpers/disabled.rb
|
|
73
94
|
- lib/simple_form/helpers/readonly.rb
|
|
74
95
|
- lib/simple_form/helpers/required.rb
|
|
75
96
|
- lib/simple_form/helpers/validators.rb
|
|
76
|
-
- lib/simple_form/helpers.rb
|
|
77
97
|
- lib/simple_form/i18n_cache.rb
|
|
98
|
+
- lib/simple_form/inputs.rb
|
|
78
99
|
- lib/simple_form/inputs/base.rb
|
|
79
100
|
- lib/simple_form/inputs/block_input.rb
|
|
80
101
|
- lib/simple_form/inputs/boolean_input.rb
|
|
@@ -92,15 +113,16 @@ files:
|
|
|
92
113
|
- lib/simple_form/inputs/range_input.rb
|
|
93
114
|
- lib/simple_form/inputs/string_input.rb
|
|
94
115
|
- lib/simple_form/inputs/text_input.rb
|
|
95
|
-
- lib/simple_form/inputs.rb
|
|
96
116
|
- lib/simple_form/map_type.rb
|
|
117
|
+
- lib/simple_form/railtie.rb
|
|
118
|
+
- lib/simple_form/tags.rb
|
|
97
119
|
- lib/simple_form/version.rb
|
|
120
|
+
- lib/simple_form/wrappers.rb
|
|
98
121
|
- lib/simple_form/wrappers/builder.rb
|
|
122
|
+
- lib/simple_form/wrappers/leaf.rb
|
|
99
123
|
- lib/simple_form/wrappers/many.rb
|
|
100
124
|
- lib/simple_form/wrappers/root.rb
|
|
101
125
|
- lib/simple_form/wrappers/single.rb
|
|
102
|
-
- lib/simple_form/wrappers.rb
|
|
103
|
-
- lib/simple_form.rb
|
|
104
126
|
- test/action_view_extensions/builder_test.rb
|
|
105
127
|
- test/action_view_extensions/form_helper_test.rb
|
|
106
128
|
- test/components/label_test.rb
|
|
@@ -135,38 +157,31 @@ files:
|
|
|
135
157
|
- test/support/discovery_inputs.rb
|
|
136
158
|
- test/support/misc_helpers.rb
|
|
137
159
|
- test/support/mock_controller.rb
|
|
138
|
-
- test/support/mock_response.rb
|
|
139
160
|
- test/support/models.rb
|
|
140
161
|
- test/test_helper.rb
|
|
141
|
-
homepage:
|
|
142
|
-
licenses:
|
|
162
|
+
homepage: https://github.com/plataformatec/simple_form
|
|
163
|
+
licenses:
|
|
164
|
+
- MIT
|
|
165
|
+
metadata: {}
|
|
143
166
|
post_install_message:
|
|
144
167
|
rdoc_options: []
|
|
145
168
|
require_paths:
|
|
146
169
|
- lib
|
|
147
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
|
-
none: false
|
|
149
171
|
requirements:
|
|
150
|
-
- -
|
|
172
|
+
- - ">="
|
|
151
173
|
- !ruby/object:Gem::Version
|
|
152
174
|
version: '0'
|
|
153
|
-
segments:
|
|
154
|
-
- 0
|
|
155
|
-
hash: 284620577294605378
|
|
156
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
|
-
none: false
|
|
158
176
|
requirements:
|
|
159
|
-
- -
|
|
177
|
+
- - ">="
|
|
160
178
|
- !ruby/object:Gem::Version
|
|
161
179
|
version: '0'
|
|
162
|
-
segments:
|
|
163
|
-
- 0
|
|
164
|
-
hash: 284620577294605378
|
|
165
180
|
requirements: []
|
|
166
181
|
rubyforge_project: simple_form
|
|
167
|
-
rubygems_version:
|
|
182
|
+
rubygems_version: 2.6.11
|
|
168
183
|
signing_key:
|
|
169
|
-
specification_version:
|
|
184
|
+
specification_version: 4
|
|
170
185
|
summary: Forms made easy!
|
|
171
186
|
test_files:
|
|
172
187
|
- test/action_view_extensions/builder_test.rb
|
|
@@ -203,6 +218,5 @@ test_files:
|
|
|
203
218
|
- test/support/discovery_inputs.rb
|
|
204
219
|
- test/support/misc_helpers.rb
|
|
205
220
|
- test/support/mock_controller.rb
|
|
206
|
-
- test/support/mock_response.rb
|
|
207
221
|
- test/support/models.rb
|
|
208
222
|
- test/test_helper.rb
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# TODO: Delete this file when we drop support for Rails 3.0
|
|
2
|
-
# This method is already implemented in active_support 3.1
|
|
3
|
-
|
|
4
|
-
unless Hash.new.respond_to?(:deep_dup)
|
|
5
|
-
class Hash
|
|
6
|
-
# Returns a deep copy of hash.
|
|
7
|
-
def deep_dup
|
|
8
|
-
duplicate = self.dup
|
|
9
|
-
duplicate.each_pair do |k,v|
|
|
10
|
-
tv = duplicate[k]
|
|
11
|
-
duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
|
|
12
|
-
end
|
|
13
|
-
duplicate
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|