Sha256: 87b75fb256b4fa422fc3526163018f74aa5f17afa435bc155303bd9dfa8d23c9

Contents?: true

Size: 1.33 KB

Versions: 26

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe ActiveFedora::Associations::HasManyAssociation do
  it "should be able to replace the collection" do
    @owner = stub(:new_record? => false, :to_ary => nil, :internal_uri => 'info:fedora/changeme:99')
    @reflection = stub(:klass => Mocha::Mock, :options=>{:property=>'predicate'})
    #ac = ActiveFedora::Associations::AssociationCollection.new(@owner, @reflection)
    ac = ActiveFedora::Associations::HasManyAssociation.new(@owner, @reflection)
    @target = [stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true)]
    ac.target = @target 

    @expected1 = stub(:new_record? => false, :add_relationship=>true, :save=>true, :to_ary => nil)
    @expected2 = stub(:new_record? => false, :add_relationship=>true, :save=>true, :to_ary => nil)
    ac.replace([@expected1, @expected2])
    ac.target.should == [@expected1, @expected2]

  end

  it "should build" do
    @owner = stub(:new_record? => false, :internal_uri => 'info:fedora/changeme:99')
    @reflection = stub(:klass => Mocha::Mock, :options=>{:property=>'predicate'})
    @assoc = ActiveFedora::Associations::HasManyAssociation.new(@owner, @reflection)
    @assoc.should respond_to :build
      
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
active-fedora-4.0.0.rc20 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc19 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc18 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc17 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc16 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc15 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc14 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc13 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc12 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc11 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc10 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc9 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc8 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc7 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc6 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc5 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc4 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc3 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc2 spec/unit/has_many_collection_spec.rb
active-fedora-4.0.0.rc1 spec/unit/has_many_collection_spec.rb