simple_form 3.1.0 → 3.5.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.
Potentially problematic release.
This version of simple_form might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +67 -0
- data/MIT-LICENSE +1 -1
- data/README.md +70 -31
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +5 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +19 -1
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +5 -2
- data/lib/simple_form/action_view_extensions/form_helper.rb +3 -1
- data/lib/simple_form/components/html5.rb +14 -4
- data/lib/simple_form/components/labels.rb +1 -1
- data/lib/simple_form/components/maxlength.rb +17 -4
- data/lib/simple_form/components/minlength.rb +47 -0
- data/lib/simple_form/components.rb +1 -0
- data/lib/simple_form/form_builder.rb +17 -9
- data/lib/simple_form/inputs/base.rb +12 -10
- data/lib/simple_form/inputs/boolean_input.rb +11 -2
- data/lib/simple_form/inputs/collection_input.rb +4 -3
- data/lib/simple_form/inputs/collection_radio_buttons_input.rb +1 -1
- data/lib/simple_form/inputs/date_time_input.rb +12 -8
- data/lib/simple_form/inputs/password_input.rb +1 -1
- data/lib/simple_form/inputs/string_input.rb +1 -1
- data/lib/simple_form/inputs/text_input.rb +1 -1
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form.rb +1 -4
- data/test/form_builder/error_test.rb +32 -9
- data/test/form_builder/general_test.rb +40 -8
- data/test/form_builder/input_field_test.rb +53 -67
- data/test/form_builder/label_test.rb +19 -2
- data/test/form_builder/wrapper_test.rb +43 -11
- data/test/inputs/boolean_input_test.rb +18 -0
- data/test/inputs/datetime_input_test.rb +15 -2
- data/test/inputs/discovery_test.rb +1 -0
- data/test/inputs/numeric_input_test.rb +3 -0
- data/test/inputs/priority_input_test.rb +10 -2
- data/test/inputs/required_test.rb +44 -0
- data/test/inputs/string_input_test.rb +20 -12
- data/test/inputs/text_input_test.rb +12 -0
- data/test/support/misc_helpers.rb +22 -1
- data/test/support/mock_controller.rb +3 -1
- data/test/support/models.rb +41 -7
- data/test/test_helper.rb +6 -0
- metadata +24 -11
@@ -46,7 +46,7 @@ module MiscHelpers
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def swap_wrapper(name = :default, wrapper =
|
49
|
+
def swap_wrapper(name = :default, wrapper = custom_wrapper)
|
50
50
|
old = SimpleForm.wrappers[name.to_s]
|
51
51
|
SimpleForm.wrappers[name.to_s] = wrapper
|
52
52
|
yield
|
@@ -91,6 +91,20 @@ module MiscHelpers
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
def custom_wrapper_with_input_data_modal
|
95
|
+
SimpleForm.build tag: :div, class: "custom_wrapper" do |b|
|
96
|
+
b.use :label
|
97
|
+
b.use :input, data: { modal: 'data-modal', wrapper: 'data-wrapper' }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def custom_wrapper_with_input_aria_modal
|
102
|
+
SimpleForm.build tag: :div, class: "custom_wrapper" do |b|
|
103
|
+
b.use :label
|
104
|
+
b.use :input, aria: { modal: 'aria-modal', wrapper: 'aria-wrapper' }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
94
108
|
def custom_wrapper_with_label_class
|
95
109
|
SimpleForm.build tag: :div, class: "custom_wrapper" do |b|
|
96
110
|
b.use :label, class: 'inline-class'
|
@@ -184,6 +198,13 @@ module MiscHelpers
|
|
184
198
|
end
|
185
199
|
end
|
186
200
|
|
201
|
+
def custom_wrapper_with_required_input
|
202
|
+
SimpleForm.build tag: :span, class: 'custom_wrapper' do |b|
|
203
|
+
b.use :html5
|
204
|
+
b.use :input, required: true
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
187
208
|
def custom_form_for(object, *args, &block)
|
188
209
|
simple_form_for(object, *args, { builder: CustomFormBuilder }, &block)
|
189
210
|
end
|
@@ -9,7 +9,7 @@ class MockController
|
|
9
9
|
defined?(@action_name) ? @action_name : "edit"
|
10
10
|
end
|
11
11
|
|
12
|
-
def url_for(*
|
12
|
+
def url_for(*)
|
13
13
|
"http://example.com"
|
14
14
|
end
|
15
15
|
|
@@ -17,6 +17,8 @@ class MockController
|
|
17
17
|
{}
|
18
18
|
end
|
19
19
|
|
20
|
+
def polymorphic_mappings(*); {}; end
|
21
|
+
|
20
22
|
def hash_for_user_path(*); end
|
21
23
|
def hash_for_validating_user_path(*); end
|
22
24
|
def hash_for_other_validating_user_path(*); end
|
data/test/support/models.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
Association = Struct.new(:klass, :name, :macro, :scope, :options)
|
2
2
|
|
3
3
|
Column = Struct.new(:name, :type, :limit) do
|
4
|
-
# Returns +true+ if the column is either of type integer, float or decimal.
|
5
|
-
def number?
|
6
|
-
type == :integer || type == :float || type == :decimal
|
7
|
-
end
|
8
4
|
end
|
9
5
|
|
10
6
|
Relation = Struct.new(:records) do
|
@@ -130,6 +126,42 @@ class User
|
|
130
126
|
Column.new(attribute, column_type, limit)
|
131
127
|
end
|
132
128
|
|
129
|
+
begin
|
130
|
+
require 'active_model/type'
|
131
|
+
begin
|
132
|
+
ActiveModel::Type.lookup(:text)
|
133
|
+
rescue ArgumentError # :text is no longer an ActiveModel::Type
|
134
|
+
# But we don't want our tests to depend on ActiveRecord
|
135
|
+
class ::ActiveModel::Type::Text < ActiveModel::Type::String
|
136
|
+
def type; :text; end
|
137
|
+
end
|
138
|
+
ActiveModel::Type.register(:text, ActiveModel::Type::Text)
|
139
|
+
end
|
140
|
+
def type_for_attribute(attribute)
|
141
|
+
column_type, limit = case attribute
|
142
|
+
when 'name', 'status', 'password' then [:string, 100]
|
143
|
+
when 'description' then [:text, 200]
|
144
|
+
when 'age' then :integer
|
145
|
+
when 'credit_limit' then [:decimal, 15]
|
146
|
+
when 'active' then :boolean
|
147
|
+
when 'born_at' then :date
|
148
|
+
when 'delivery_time' then :time
|
149
|
+
when 'created_at' then :datetime
|
150
|
+
when 'updated_at' then :datetime
|
151
|
+
when 'lock_version' then :integer
|
152
|
+
when 'home_picture' then :string
|
153
|
+
when 'amount' then :integer
|
154
|
+
when 'attempts' then :integer
|
155
|
+
when 'action' then :string
|
156
|
+
when 'credit_card' then :string
|
157
|
+
when 'uuid' then :string
|
158
|
+
end
|
159
|
+
|
160
|
+
ActiveModel::Type.lookup(column_type, limit: limit)
|
161
|
+
end
|
162
|
+
rescue LoadError
|
163
|
+
end
|
164
|
+
|
133
165
|
def has_attribute?(attribute)
|
134
166
|
case attribute.to_sym
|
135
167
|
when :name, :status, :password, :description, :age,
|
@@ -213,9 +245,11 @@ class ValidatingUser < User
|
|
213
245
|
greater_than_or_equal_to: :min_attempts,
|
214
246
|
less_than_or_equal_to: :max_attempts,
|
215
247
|
only_integer: true
|
216
|
-
validates_length_of :name, maximum: 25
|
217
|
-
validates_length_of :description,
|
218
|
-
|
248
|
+
validates_length_of :name, maximum: 25, minimum: 5
|
249
|
+
validates_length_of :description, in: 15..50
|
250
|
+
if ActionPack::VERSION::STRING < '5'
|
251
|
+
validates_length_of :action, maximum: 10, tokenizer: lambda { |str| str.scan(/\w+/) }
|
252
|
+
end
|
219
253
|
validates_length_of :home_picture, is: 12
|
220
254
|
|
221
255
|
def min_amount
|
data/test/test_helper.rb
CHANGED
@@ -36,6 +36,10 @@ else
|
|
36
36
|
ActionDispatch::Assertions::NO_STRIP << "label"
|
37
37
|
end
|
38
38
|
|
39
|
+
if ActiveSupport::TestCase.respond_to?(:test_order=)
|
40
|
+
ActiveSupport::TestCase.test_order = :random
|
41
|
+
end
|
42
|
+
|
39
43
|
class ActionView::TestCase
|
40
44
|
include MiscHelpers
|
41
45
|
include SimpleForm::ActionViewExtensions::FormHelper
|
@@ -51,6 +55,8 @@ class ActionView::TestCase
|
|
51
55
|
@user = User.build(extra_attributes)
|
52
56
|
|
53
57
|
@validating_user = ValidatingUser.build({
|
58
|
+
name: 'Tester McTesterson',
|
59
|
+
description: 'A test user of the most distinguised caliber',
|
54
60
|
home_picture: 'Home picture',
|
55
61
|
age: 19,
|
56
62
|
amount: 15,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -10,36 +10,48 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '4
|
21
|
+
version: '4'
|
22
|
+
- - "<"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '5.2'
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
|
-
- - "
|
29
|
+
- - ">"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '4'
|
32
|
+
- - "<"
|
27
33
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
34
|
+
version: '5.2'
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: actionpack
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
|
-
- - "
|
39
|
+
- - ">"
|
34
40
|
- !ruby/object:Gem::Version
|
35
|
-
version: '4
|
41
|
+
version: '4'
|
42
|
+
- - "<"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '5.2'
|
36
45
|
type: :runtime
|
37
46
|
prerelease: false
|
38
47
|
version_requirements: !ruby/object:Gem::Requirement
|
39
48
|
requirements:
|
40
|
-
- - "
|
49
|
+
- - ">"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '4'
|
52
|
+
- - "<"
|
41
53
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
54
|
+
version: '5.2'
|
43
55
|
description: Forms made easy!
|
44
56
|
email: opensource@plataformatec.com.br
|
45
57
|
executables: []
|
@@ -70,6 +82,7 @@ files:
|
|
70
82
|
- lib/simple_form/components/labels.rb
|
71
83
|
- lib/simple_form/components/maxlength.rb
|
72
84
|
- lib/simple_form/components/min_max.rb
|
85
|
+
- lib/simple_form/components/minlength.rb
|
73
86
|
- lib/simple_form/components/pattern.rb
|
74
87
|
- lib/simple_form/components/placeholders.rb
|
75
88
|
- lib/simple_form/components/readonly.rb
|
@@ -166,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
179
|
version: '0'
|
167
180
|
requirements: []
|
168
181
|
rubyforge_project: simple_form
|
169
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.6.10
|
170
183
|
signing_key:
|
171
184
|
specification_version: 4
|
172
185
|
summary: Forms made easy!
|