Sha256: 07dd53d7dc7b22ab20bf6f3cce85e05074ea1e96aab865d5bef37c780a66a48e

Contents?: true

Size: 894 Bytes

Versions: 26

Compression:

Stored size: 894 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
    expect(comment.blog_loaded?).to be_truthy
    expect(comment.blog).to eq(blog)
    expect(comment.blog_id).to eq(blog.id)
    comment.blog = nil
    expect(comment.blog_loaded?).to be_truthy
    expect(comment.blog).to be_nil
    expect(comment.blog_id).to 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
    expect(comment.blog_loaded?).to be_truthy
    comment.blog_id = "blog2"
    expect(comment.blog_loaded?).to be_falsey
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
active_zuora-2.1.2 spec/belongs_to_associations_spec.rb
active_zuora-2.1.1 spec/belongs_to_associations_spec.rb
active_zuora-2.0.6 spec/belongs_to_associations_spec.rb
active_zuora-2.1.0 spec/belongs_to_associations_spec.rb
active_zuora-2.0.5 spec/belongs_to_associations_spec.rb
active_zuora-2.0.4 spec/belongs_to_associations_spec.rb