model_error_messages 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 007df75f1595da7a658b842cd21ee696b1fd528f
|
4
|
+
data.tar.gz: dcb48d29502d70d33764934b945d64c5ada1b061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 075734aaecb95dbc036310aeeef7dce016568075b6b7d5af236ae314502fce8e70ad576e02671469d8b5c774b83d54c1ebc78f6f2197c3d83f471852212dbb59
|
7
|
+
data.tar.gz: 757313149b18469716c470b4fc7090994625aab782a48746d8560f88ccce6624dbe09af67ae8a479e4c7d108d7ab73e5de0957d8dd721c9c30cc14defa360ee2
|
data/Gemfile.lock
CHANGED
@@ -37,11 +37,11 @@ module ModelErrorMessages
|
|
37
37
|
messages = model.errors.full_messages
|
38
38
|
|
39
39
|
if messages.count == 1 && config.single_error_in_paragraph
|
40
|
-
return tag(:p, messages.first)
|
40
|
+
return tag(:p, CGI.escapeHTML(messages.first))
|
41
41
|
end
|
42
42
|
|
43
43
|
ul_string = messages.map do |message|
|
44
|
-
tag(:li, message)
|
44
|
+
tag(:li, CGI.escapeHTML(message))
|
45
45
|
end.join.html_safe
|
46
46
|
|
47
47
|
tag(:ul, ul_string)
|
@@ -61,8 +61,9 @@ module ModelErrorMessages
|
|
61
61
|
attrs << %( #{pair.first}="#{CGI.escapeHTML(pair.last.to_s)}")
|
62
62
|
end
|
63
63
|
attrs
|
64
|
-
end
|
65
|
-
|
64
|
+
end.html_safe
|
65
|
+
|
66
|
+
"<#{name}#{string_attributes}>#{value}</#{name}>".html_safe
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -10,7 +10,7 @@ end
|
|
10
10
|
def mock_model_full_messages(errors_count)
|
11
11
|
case errors_count
|
12
12
|
when 0 then []
|
13
|
-
when 1 then ['Title is missing']
|
13
|
+
when 1 then ['Title is -> missing']
|
14
14
|
when 2 then ['Please select an author', 'Content is missing']
|
15
15
|
else
|
16
16
|
raise 'Please enter a valid `errors` count.'
|
@@ -27,7 +27,6 @@ end
|
|
27
27
|
describe 'Helpers' do
|
28
28
|
describe '#model_error_messages' do
|
29
29
|
include ModelErrorMessages::Helpers
|
30
|
-
attr_accessor :output_buffer
|
31
30
|
|
32
31
|
subject { model_error_messages(mock_model) }
|
33
32
|
|
@@ -46,7 +45,7 @@ describe 'Helpers' do
|
|
46
45
|
result = model_error_messages(mock_model(errors: 1))
|
47
46
|
expect(result).to eql(
|
48
47
|
'<div class="alert alert-danger model-error-messages">' \
|
49
|
-
'<p>Title is missing</p>' \
|
48
|
+
'<p>Title is -> missing</p>' \
|
50
49
|
'</div>'
|
51
50
|
)
|
52
51
|
end
|
@@ -60,6 +59,11 @@ describe 'Helpers' do
|
|
60
59
|
'</div>'
|
61
60
|
)
|
62
61
|
end
|
62
|
+
|
63
|
+
it 'returns a safe string' do
|
64
|
+
result = model_error_messages(mock_model(errors: 1))
|
65
|
+
expect(result.html_safe?).to eql(true)
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
context 'with a custom configuration' do
|
@@ -78,7 +82,7 @@ describe 'Helpers' do
|
|
78
82
|
expect(result).to eql(
|
79
83
|
'<div class="model-foo bar">' \
|
80
84
|
'<h1>An error occurred</h1>' \
|
81
|
-
'<ul><li>Title is missing</li></ul>' \
|
85
|
+
'<ul><li>Title is -> missing</li></ul>' \
|
82
86
|
'<p>Please try again.</p>' \
|
83
87
|
'</div>'
|
84
88
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_error_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Maximin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|