mongoid-embedded-errors 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/README.md +6 -1
- data/Rakefile +5 -3
- data/lib/mongoid-embedded-errors.rb +2 -2
- data/lib/mongoid-embedded-errors/version.rb +1 -1
- data/spec/embedded_errors_spec.rb +7 -7
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mongoid-embedded-errors (1.0
|
4
|
+
mongoid-embedded-errors (1.1.0)
|
5
5
|
mongoid (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
origin (~> 1.0)
|
24
24
|
tzinfo (~> 0.3.22)
|
25
25
|
moped (1.2.7)
|
26
|
-
multi_json (1.
|
26
|
+
multi_json (1.4.0)
|
27
27
|
origin (1.0.9)
|
28
28
|
rspec (2.11.0)
|
29
29
|
rspec-core (~> 2.11.0)
|
data/README.md
CHANGED
@@ -84,7 +84,7 @@ article = Article.new(pages: [Page.new(sections: [Section.new])])
|
|
84
84
|
article.valid? # => false
|
85
85
|
|
86
86
|
article.error.messages
|
87
|
-
# => {:name=>["can't be blank"], :summary=>["can't be blank"], :pages=>[{
|
87
|
+
# => {:name=>["can't be blank"], :summary=>["can't be blank"], :pages=>[{0=>{:title=>["can't be blank"], :sections=>[{0=>{:header=>["can't be blank"]}}]}}]}
|
88
88
|
```
|
89
89
|
|
90
90
|
Now, isn't that much nicer? Yeah, I think so to.
|
@@ -96,3 +96,8 @@ Now, isn't that much nicer? Yeah, I think so to.
|
|
96
96
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
97
97
|
4. Push to the branch (`git push origin my-new-feature`)
|
98
98
|
5. Create new Pull Request
|
99
|
+
|
100
|
+
## Contributers
|
101
|
+
|
102
|
+
* Mark Bates
|
103
|
+
* Nick Plante
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ module Mongoid
|
|
17
17
|
self.embedded_relations.each do |name, metadata|
|
18
18
|
if errs[name]
|
19
19
|
errs.delete(name.to_sym)
|
20
|
-
self.send(name).
|
21
|
-
errs[name] = {
|
20
|
+
self.send(name).each_with_index do |rel, i|
|
21
|
+
errs[name] = {i => rel.errors.messages} if rel.errors.any?
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -8,20 +8,20 @@ describe Mongoid::EmbeddedErrors do
|
|
8
8
|
let(:valid_section) { Section.new(header: "My Header") }
|
9
9
|
|
10
10
|
describe "errors" do
|
11
|
-
|
11
|
+
|
12
12
|
it "bubbles up errors from embedded documents" do
|
13
|
+
invalid_page.sections << valid_section
|
13
14
|
invalid_page.sections << invalid_section
|
14
15
|
article.pages << invalid_page
|
15
16
|
article.should_not be_valid
|
16
|
-
puts article.errors.messages
|
17
17
|
article.errors.messages.should eql({
|
18
|
-
name: ["can't be blank"],
|
18
|
+
name: ["can't be blank"],
|
19
19
|
summary: ["can't be blank"],
|
20
20
|
pages: [{
|
21
|
-
|
21
|
+
0 => {
|
22
22
|
title: ["can't be blank"],
|
23
23
|
sections: [{
|
24
|
-
|
24
|
+
1 => {
|
25
25
|
header: ["can't be blank"]
|
26
26
|
}
|
27
27
|
}]
|
@@ -40,7 +40,7 @@ describe Mongoid::EmbeddedErrors do
|
|
40
40
|
article.should_not be_valid
|
41
41
|
article.errors.messages.should eql(name: ["can't be blank"], summary: ["can't be blank"])
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
end
|
45
45
|
|
46
|
-
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-embedded-errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|