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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid-embedded-errors (1.0.1)
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.3.7)
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=>[{"5086ec0d421aa94f0f000002"=>{:title=>["can't be blank"], :sections=>[{"5086ec0d421aa94f0f000001"=>{:header=>["can't be blank"]}}]}}]}
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
@@ -2,8 +2,10 @@ require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
4
  desc "Run tests"
5
- task :default => [:ruby]
5
+ task :default => [:test]
6
6
 
7
- task :ruby do
7
+ task :spec => [:test]
8
+
9
+ task :test do
8
10
  system "bundle exec rspec"
9
- end
11
+ end
@@ -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).each do |rel|
21
- errs[name] = {rel.id.to_s => rel.errors.messages} if rel.errors.any?
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
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module EmbeddedErrors
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  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
- invalid_page.id.to_s => {
21
+ 0 => {
22
22
  title: ["can't be blank"],
23
23
  sections: [{
24
- invalid_section.id.to_s => {
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.1
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-11-29 00:00:00.000000000 Z
12
+ date: 2012-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid