Sha256: c8d8edbbf80581abf501fbee660f6fed1ea6af5cf2f698d27c559c5c063e6712
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 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") } 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.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"] }) 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.0 | spec/embedded_errors_spec.rb |