Sha256: a97a81504096c6ddf2f2a1e278071db6e6d4ff5f359b3a56fc30f33958bf4f8c

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 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.should have(1).error_on(:comments)
    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.should have(1).error_on(:comments)
    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.should have(1).error_on(:comments)
    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.should have(1).error_on(:comments)
    post_form.errors.size.should == 2
    post_form.comments.first.should have(1).error_on(:body)
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
object_attorney-2.10.12 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.11 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.10 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.9 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.7 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.6 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.5 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.3 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.2 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.10.1 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.9.4 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.9.3 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.9.2 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.9.0 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.8.1 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.8.0 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.6.12 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.6.11 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.6.10 spec/object_attorney/post_with_comment_validations_form_spec.rb
object_attorney-2.6.9 spec/object_attorney/post_with_comment_validations_form_spec.rb