Sha256: 07259c21bdef44464d8a6573d84bb20de79e51f35b5d45f91ca523314256c09b

Contents?: true

Size: 1.33 KB

Versions: 20

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"

describe PostValidationsForm do

  it "1. 'PostValidationsForm' becomes invalid if 'Post' 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 = PostValidationsForm.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_validations_form_spec.rb
object_attorney-2.10.11 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.10 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.9 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.7 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.6 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.5 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.3 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.2 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.10.1 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.9.4 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.9.3 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.9.2 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.9.0 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.8.1 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.8.0 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.6.12 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.6.11 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.6.10 spec/object_attorney/post_validations_form_spec.rb
object_attorney-2.6.9 spec/object_attorney/post_validations_form_spec.rb