Sha256: 1aa9b350ed66843d9f7d47ba457dfb67a39fd156224e792f1c1a2994c4f52997

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

require 'spec_helper'

describe "BelongsToAssociations" do

  class Blog
    include ActiveZuora::ZObject
  end

  class Comment
    include ActiveZuora::Base
    belongs_to :blog
  end

  it "should define a attribute assignment method method for the object" do
    blog = Blog.new :id => "blog1"
    comment = Comment.new :blog => blog
    comment.blog_loaded?.should be_true
    comment.blog.should == blog
    comment.blog_id.should == blog.id
    comment.blog = nil
    comment.blog_loaded?.should be_true
    comment.blog.should be_nil
    comment.blog_id.should be_nil
  end

  it "should define a attribute assignment method for the object id" do
    blog = Blog.new :id => "blog1"
    comment = Comment.new :blog => blog
    comment.blog_loaded?.should be_true
    comment.blog_id = "blog2"
    comment.blog_loaded?.should be_false
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_zuora-2.0.3 spec/belongs_to_associations_spec.rb
active_zuora-2.0.2 spec/belongs_to_associations_spec.rb
active_zuora-2.0.1 spec/belongs_to_associations_spec.rb
active_zuora-2.0.0 spec/belongs_to_associations_spec.rb