simple_form 2.1.1 → 2.1.2
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 +5 -0
- data/lib/simple_form/components/errors.rb +7 -1
- data/lib/simple_form/inputs/base.rb +1 -1
- data/lib/simple_form/version.rb +1 -1
- data/test/form_builder/error_test.rb +49 -7
- data/test/form_builder/general_test.rb +2 -2
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f641b8e74ebf64e3fb7fe4ebe925c64713eb13
|
4
|
+
data.tar.gz: e74db71fa1d985a906d520673cf82504470c16dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc974c636d805808f4b5fd47e9eec4c656ae53b680113f03eea075dac24a7607c773e1243ceff8201bced0fc849c752def0130efefe5b9d7a24c6e85fc4e176a
|
7
|
+
data.tar.gz: f7a7f67d9ce616e8f7697558ca957cf2701641c0a149eb06b0dab2b60ba17833f432f7bdeeaf29312ff7606acf70971dea86b8ec4f19198ff6420aa7421d646e
|
data/CHANGELOG.md
CHANGED
@@ -12,7 +12,9 @@ module SimpleForm
|
|
12
12
|
protected
|
13
13
|
|
14
14
|
def error_text
|
15
|
-
|
15
|
+
text = has_error_in_options? ? options[:error] : errors.send(error_method)
|
16
|
+
|
17
|
+
"#{html_escape(options[:error_prefix])} #{html_escape(text)}".lstrip.html_safe
|
16
18
|
end
|
17
19
|
|
18
20
|
def error_method
|
@@ -30,6 +32,10 @@ module SimpleForm
|
|
30
32
|
def errors_on_association
|
31
33
|
reflection ? object.errors[reflection.name] : []
|
32
34
|
end
|
35
|
+
|
36
|
+
def has_error_in_options?
|
37
|
+
options[:error] && !options[:error].nil?
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
data/lib/simple_form/version.rb
CHANGED
@@ -14,6 +14,10 @@ class ErrorTest < ActionView::TestCase
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def with_custom_error_for(object, *args)
|
18
|
+
with_form_for(object, *args)
|
19
|
+
end
|
20
|
+
|
17
21
|
test 'error should not generate content for attribute without errors' do
|
18
22
|
with_error_for @user, :active
|
19
23
|
assert_no_select 'span.error'
|
@@ -32,7 +36,7 @@ class ErrorTest < ActionView::TestCase
|
|
32
36
|
|
33
37
|
test 'error should generate messages for attribute with single error' do
|
34
38
|
with_error_for @user, :name
|
35
|
-
assert_select 'span.error', "can
|
39
|
+
assert_select 'span.error', "can't be blank"
|
36
40
|
end
|
37
41
|
|
38
42
|
test 'error should generate messages for attribute with one error when using first' do
|
@@ -82,12 +86,21 @@ class ErrorTest < ActionView::TestCase
|
|
82
86
|
|
83
87
|
test 'error should escape error prefix text' do
|
84
88
|
with_error_for @user, :name, :error_prefix => '<b>Name</b>'
|
85
|
-
assert_select 'span.error', "<b>Name</b> can
|
89
|
+
assert_select 'span.error', "<b>Name</b> can't be blank"
|
90
|
+
end
|
91
|
+
|
92
|
+
test 'error escapes error text' do
|
93
|
+
@user.errors.merge!(:action => ['must not contain <b>markup</b>'])
|
94
|
+
|
95
|
+
with_error_for @user, :action
|
96
|
+
|
97
|
+
assert_select 'span.error'
|
98
|
+
assert_no_select 'span.error b', 'markup'
|
86
99
|
end
|
87
100
|
|
88
101
|
test 'error should generate an error message with raw HTML tags' do
|
89
102
|
with_error_for @user, :name, :error_prefix => '<b>Name</b>'.html_safe
|
90
|
-
assert_select 'span.error', "Name can
|
103
|
+
assert_select 'span.error', "Name can't be blank"
|
91
104
|
assert_select 'span.error b', "Name"
|
92
105
|
end
|
93
106
|
|
@@ -95,7 +108,7 @@ class ErrorTest < ActionView::TestCase
|
|
95
108
|
|
96
109
|
test 'full error should generate an full error tag for the attribute' do
|
97
110
|
with_full_error_for @user, :name
|
98
|
-
assert_select 'span.error', "Super User Name! can
|
111
|
+
assert_select 'span.error', "Super User Name! can't be blank"
|
99
112
|
end
|
100
113
|
|
101
114
|
test 'full error should generate an full error tag with a clean HTML' do
|
@@ -105,13 +118,13 @@ class ErrorTest < ActionView::TestCase
|
|
105
118
|
|
106
119
|
test 'full error should allow passing options to full error tag' do
|
107
120
|
with_full_error_for @user, :name, :id => 'name_error', :error_prefix => "Your name"
|
108
|
-
assert_select 'span.error#name_error', "Your name can
|
121
|
+
assert_select 'span.error#name_error', "Your name can't be blank"
|
109
122
|
end
|
110
123
|
|
111
124
|
test 'full error should not modify the options hash' do
|
112
125
|
options = { :id => 'name_error' }
|
113
126
|
with_full_error_for @user, :name, options
|
114
|
-
assert_select 'span.error#name_error', "Super User Name! can
|
127
|
+
assert_select 'span.error#name_error', "Super User Name! can't be blank"
|
115
128
|
assert_equal({ :id => 'name_error' }, options)
|
116
129
|
end
|
117
130
|
|
@@ -120,7 +133,36 @@ class ErrorTest < ActionView::TestCase
|
|
120
133
|
test 'error with custom wrappers works' do
|
121
134
|
swap_wrapper do
|
122
135
|
with_error_for @user, :name
|
123
|
-
assert_select 'span.omg_error', "can
|
136
|
+
assert_select 'span.omg_error', "can't be blank"
|
124
137
|
end
|
125
138
|
end
|
139
|
+
|
140
|
+
# CUSTOM ERRORS
|
141
|
+
|
142
|
+
test 'input with custom error works' do
|
143
|
+
with_custom_error_for(@user, :name, :error => "Super User Name! can't be blank")
|
144
|
+
|
145
|
+
assert_select 'span.error', "Super User Name! can't be blank"
|
146
|
+
end
|
147
|
+
|
148
|
+
test 'input with custom error does not generate the error if there is no error on the attribute' do
|
149
|
+
error_text = "Super User Active! can't be blank"
|
150
|
+
with_form_for @user, :active, :error => error_text
|
151
|
+
|
152
|
+
assert_no_select 'span.error'
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'input with custom error escapes the error text' do
|
156
|
+
with_form_for @user, :name, :error => 'error must not contain <b>markup</b>'
|
157
|
+
|
158
|
+
assert_select 'span.error'
|
159
|
+
assert_no_select 'span.error b', 'markup'
|
160
|
+
end
|
161
|
+
|
162
|
+
test 'input with custom error does not escape the error text if it is safe' do
|
163
|
+
with_form_for @user, :name, :error => 'error must contain <b>markup</b>'.html_safe
|
164
|
+
|
165
|
+
assert_select 'span.error'
|
166
|
+
assert_select 'span.error b', 'markup'
|
167
|
+
end
|
126
168
|
end
|
@@ -283,7 +283,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
283
283
|
|
284
284
|
test 'builder should generate errors for attribute with errors' do
|
285
285
|
with_form_for @user, :name
|
286
|
-
assert_select 'span.error', "can
|
286
|
+
assert_select 'span.error', "can't be blank"
|
287
287
|
end
|
288
288
|
|
289
289
|
test 'builder should be able to disable showing errors for a input' do
|
@@ -293,7 +293,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
293
293
|
|
294
294
|
test 'builder should pass options to errors' do
|
295
295
|
with_form_for @user, :name, :error_html => { :id => "cool" }
|
296
|
-
assert_select 'span.error#cool', "can
|
296
|
+
assert_select 'span.error#cool', "can't be blank"
|
297
297
|
end
|
298
298
|
|
299
299
|
test 'placeholder should not be generated when set to false' do
|
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: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -10,34 +10,34 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-11-25 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
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: actionpack
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '3.0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '3.0'
|
43
43
|
description: Forms made easy!
|
@@ -49,7 +49,9 @@ files:
|
|
49
49
|
- CHANGELOG.md
|
50
50
|
- MIT-LICENSE
|
51
51
|
- README.md
|
52
|
+
- lib/generators/simple_form/USAGE
|
52
53
|
- lib/generators/simple_form/install_generator.rb
|
54
|
+
- lib/generators/simple_form/templates/README
|
53
55
|
- lib/generators/simple_form/templates/_form.html.erb
|
54
56
|
- lib/generators/simple_form/templates/_form.html.haml
|
55
57
|
- lib/generators/simple_form/templates/_form.html.slim
|
@@ -57,10 +59,10 @@ files:
|
|
57
59
|
- lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
|
58
60
|
- lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
|
59
61
|
- lib/generators/simple_form/templates/config/locales/simple_form.en.yml
|
60
|
-
- lib/
|
61
|
-
- lib/generators/simple_form/USAGE
|
62
|
+
- lib/simple_form.rb
|
62
63
|
- lib/simple_form/action_view_extensions/builder.rb
|
63
64
|
- lib/simple_form/action_view_extensions/form_helper.rb
|
65
|
+
- lib/simple_form/components.rb
|
64
66
|
- lib/simple_form/components/errors.rb
|
65
67
|
- lib/simple_form/components/hints.rb
|
66
68
|
- lib/simple_form/components/html5.rb
|
@@ -71,17 +73,17 @@ files:
|
|
71
73
|
- lib/simple_form/components/pattern.rb
|
72
74
|
- lib/simple_form/components/placeholders.rb
|
73
75
|
- lib/simple_form/components/readonly.rb
|
74
|
-
- lib/simple_form/components.rb
|
75
76
|
- lib/simple_form/core_ext/hash.rb
|
76
77
|
- lib/simple_form/error_notification.rb
|
77
78
|
- lib/simple_form/form_builder.rb
|
79
|
+
- lib/simple_form/helpers.rb
|
78
80
|
- lib/simple_form/helpers/autofocus.rb
|
79
81
|
- lib/simple_form/helpers/disabled.rb
|
80
82
|
- lib/simple_form/helpers/readonly.rb
|
81
83
|
- lib/simple_form/helpers/required.rb
|
82
84
|
- lib/simple_form/helpers/validators.rb
|
83
|
-
- lib/simple_form/helpers.rb
|
84
85
|
- lib/simple_form/i18n_cache.rb
|
86
|
+
- lib/simple_form/inputs.rb
|
85
87
|
- lib/simple_form/inputs/base.rb
|
86
88
|
- lib/simple_form/inputs/block_input.rb
|
87
89
|
- lib/simple_form/inputs/boolean_input.rb
|
@@ -99,15 +101,13 @@ files:
|
|
99
101
|
- lib/simple_form/inputs/range_input.rb
|
100
102
|
- lib/simple_form/inputs/string_input.rb
|
101
103
|
- lib/simple_form/inputs/text_input.rb
|
102
|
-
- lib/simple_form/inputs.rb
|
103
104
|
- lib/simple_form/map_type.rb
|
104
105
|
- lib/simple_form/version.rb
|
106
|
+
- lib/simple_form/wrappers.rb
|
105
107
|
- lib/simple_form/wrappers/builder.rb
|
106
108
|
- lib/simple_form/wrappers/many.rb
|
107
109
|
- lib/simple_form/wrappers/root.rb
|
108
110
|
- lib/simple_form/wrappers/single.rb
|
109
|
-
- lib/simple_form/wrappers.rb
|
110
|
-
- lib/simple_form.rb
|
111
111
|
- test/action_view_extensions/builder_test.rb
|
112
112
|
- test/action_view_extensions/form_helper_test.rb
|
113
113
|
- test/components/label_test.rb
|
@@ -153,17 +153,17 @@ require_paths:
|
|
153
153
|
- lib
|
154
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
|
-
- -
|
156
|
+
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- -
|
161
|
+
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project: simple_form
|
166
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.2.2
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Forms made easy!
|