Sha256: 368267a14938e3baed2b45e72bbf60ba14cb0db3eeec478b6bad3a5d09770e21

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "spec_helper"

describe PostWithCommentValidationsForm do

  it "1. 'PostWithCommentValidationsForm' becomes invalid if 'Post' or nested 'Comment's has errors after the #submit method and incorporates its errors." do
    params = {
      post: {
        title: 'First post',
        body: 'post body',
        comments_attributes: {
          "0" => { body: "body1" }
        }
      }
    }

    post_form = PostWithCommentValidationsForm.new(params[:post])
    post_form.valid?.should == true
    
    post_form.save
    
    post_form.should have(1).error_on(:title)
    post_form.errors.size.should == 2
    post_form.comments.first.should have(1).error_on(:body)

    post_form.valid?.should == false
    post_form.should have(1).error_on(:title)
    post_form.errors.size.should == 2
    post_form.comments.first.should have(1).error_on(:body)

    post_form.save

    post_form.should have(1).error_on(:title)
    post_form.errors.size.should == 2
    post_form.comments.first.should have(1).error_on(:body)

    post_form.valid?.should == false
    post_form.should have(1).error_on(:title)
    post_form.errors.size.should == 2
    post_form.comments.first.should have(1).error_on(:body)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
object_attorney-2.5.0 spec/object_attorney/post_with_comment_validations_form_spec.rb