Skip to content

Commit

Permalink
add tests for validates_associated
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Maine & Travis Bell authored and bkeepers committed May 11, 2011
1 parent 12c110f commit e5a9c07
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/functional/test_validations.rb
Expand Up @@ -323,6 +323,34 @@ def action_present
end
end

context "validating associated docs" do
setup do
@child_class = EDoc do
key :name, :required => true
end

@root_class = Doc { }
@root_class.many :children, :class => @child_class
@root_class.validates_associated :children, :message => 'are invalid'
end

should "pass if there are no associated docs" do
doc = @root_class.new
doc.save.should be_true
end

should "pass if the associated doc is valid" do
doc = @root_class.new
doc.children.build(:name => 'Joe')
doc.save.should be_true
end

should "fail if the associated doc is invalid" do
doc = @root_class.new
doc.children.build
doc.should have_error_on(:children, 'are invalid')
end
end
# context "validates uniqueness of with :unique shortcut" do
# should "work" do
# @document = Doc do
Expand Down

0 comments on commit e5a9c07

Please sign in to comment.