Sha256: a69652529467ce1613bb54d3c45f1a2e508d30f528b80a5c5ef33b6c521b1067

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

describe PostForm::GrandSon do

  it "1. Editing a 'Post' with 6 params, only 2 should take place, and only 2 getters should be active" do
    params = {
      post: {
        title: 'altered title', body: 'altered body', user_id: 666, author: 'test', email: 'test@gmail.com', date: '20-10-2010'
      }
    }

    post = Post.create({ title: 'First post', body: 'post body', user_id: 1 })

    post_form = described_class.new(params[:post], post)

    post_form.save.should == true

    Post.all.count.should == 1
    post = Post.first
    post.title.should == 'altered title'
    post.body.should == 'post body'
    post.user_id.should == 666
    post.respond_to?(:author).should == false
    post.respond_to?(:email).should == false
    post.respond_to?(:date).should == false

    post_form.title.should == 'altered title'
    post_form.body.should == 'post body'
    post_form.author.should == 'test'
    post_form.email.should == 'test@gmail.com'
    post_form.date.should == '20-10-2010'
    post_form.respond_to?(:user_id).should == false
    
    data = { id:1, title: "altered title", email: "test@gmail.com", author: "test", body: "post body", date: "20-10-2010" }

    post_form.serializable_hash.symbolize_keys.should == data
    post_form.to_json.should == data.to_json
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
object_attorney-2.10.12 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.11 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.10 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.9 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.7 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.6 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.5 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.3 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.2 spec/object_attorney/serialization_spec.rb
object_attorney-2.10.1 spec/object_attorney/serialization_spec.rb
object_attorney-2.9.4 spec/object_attorney/serialization_spec.rb
object_attorney-2.9.3 spec/object_attorney/serialization_spec.rb
object_attorney-2.9.2 spec/object_attorney/serialization_spec.rb