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.6.0 spec/belongs_to_associations_spec.rb
active_zuora-2.5.4 spec/belongs_to_associations_spec.rb
active_zuora-2.5.3 spec/belongs_to_associations_spec.rb
active_zuora-2.5.2 spec/belongs_to_associations_spec.rb
active_zuora-2.5.1 spec/belongs_to_associations_spec.rb
active_zuora-2.5.0 spec/belongs_to_associations_spec.rb
active_zuora-2.4.1 spec/belongs_to_associations_spec.rb
active_zuora-2.4.0 spec/belongs_to_associations_spec.rb
active_zuora-2.3.1 spec/belongs_to_associations_spec.rb
active_zuora-2.3.0 spec/belongs_to_associations_spec.rb
active_zuora-2.2.7 spec/belongs_to_associations_spec.rb
active_zuora-2.2.6 spec/belongs_to_associations_spec.rb
active_zuora-2.2.5 spec/belongs_to_associations_spec.rb
active_zuora-2.2.4 spec/belongs_to_associations_spec.rb
active_zuora-2.2.3 spec/belongs_to_associations_spec.rb
active_zuora-2.2.2 spec/belongs_to_associations_spec.rb
active_zuora-2.2.1 spec/belongs_to_associations_spec.rb
active_zuora-2.2.0 spec/belongs_to_associations_spec.rb
active_zuora-2.1.4 spec/belongs_to_associations_spec.rb
active_zuora-2.1.3 spec/belongs_to_associations_spec.rb