Sha256: d408aa03ed45d5789514c3d114720d75e8276edd0d863c048c6c5ec8dd0ca10c
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Mongoid::EmbeddedErrors do let(:article) { Article.new } let(:invalid_page) { Page.new } let(:invalid_section) { Section.new } let(:valid_section) { Section.new(header: "My Header") } let(:invalid_annotation){ Annotation.new } describe "errors" do it "bubbles up errors from embedded documents" do invalid_page.sections << valid_section invalid_page.sections << invalid_section article.pages << invalid_page article.annotation = invalid_annotation article.should_not be_valid article.errors.messages.should eql({ name: ["can't be blank"], summary: ["can't be blank"], :"pages[0].title" => ["can't be blank"], :"pages[0].sections[1].header" => ["can't be blank"], :"annotation.text" => ["can't be blank"] }) end it "save works as before" do article.save.should be_false article.should_not be_persisted article.errors.messages.should eql(name: ["can't be blank"], summary: ["can't be blank"]) end it "handles errors on the main object" do article.should_not be_valid article.errors.messages.should eql(name: ["can't be blank"], summary: ["can't be blank"]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-embedded-errors-2.0.1 | spec/embedded_errors_spec.rb |