Sha256: 467e821d1ac1358756bb7dcc7eb8a474208b687b4b0142cdedd91e2a693a49c7

Contents?: true

Size: 1.13 KB

Versions: 23

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

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

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

  end

  it "should build" do
    class Foo; end
    @owner = stub(:new_record? => false)
    @assoc = ActiveFedora::Associations::HasManyAssociation.new(@owner, @reflection)
    @assoc.should respond_to :build
    Object.send(:remove_const, :Foo)
      
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active-fedora-3.1.4 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.3 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.2 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.1 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.rc4 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.rc3 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.rc2 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.rc1 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre14 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre13 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre12 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre11 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre10 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre9 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre8 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre7 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre6 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre5 spec/unit/has_many_collection_spec.rb
active-fedora-3.1.0.pre4 spec/unit/has_many_collection_spec.rb