Sha256: 2e9f2ed0226b81a5afaab7993ed11da8348c71554e62c73d348610a812b8cd6a

Contents?: true

Size: 903 Bytes

Versions: 25

Compression:

Stored size: 903 Bytes

Contents

require 'spec_helper'

describe ActiveFedora::Associations::HasManyAssociation do
  before do 
    class Book < ActiveFedora::Base
    end
    class Page < ActiveFedora::Base
    end
  end

  after do
    Object.send(:remove_const, :Book)
    Object.send(:remove_const, :Page)
  end

  subject { Book.new(pid: 'subject:a') }
  before {
    subject.stub(:new_record? => false, save: true)
  }

  it "should call add_relationship" do
    reflection = Book.create_reflection(:has_many, 'pages', {:property=>'predicate'}, Book)
    ActiveFedora::SolrService.stub(:query).and_return([])
    ac = ActiveFedora::Associations::HasManyAssociation.new(subject, reflection)
    ac.should_receive(:callback).twice
    object = Page.new(:pid => 'object:b')
    object.stub(:new_record? => false, save: true)
  
    object.should_receive(:add_relationship).with('predicate', subject)
 
    ac << object

  end
  
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
active-fedora-7.3.1 spec/unit/has_many_collection_spec.rb
active-fedora-7.3.0 spec/unit/has_many_collection_spec.rb
active-fedora-8.2.1 spec/unit/has_many_collection_spec.rb
active-fedora-8.2.0 spec/unit/has_many_collection_spec.rb
active-fedora-7.2.0 spec/unit/has_many_collection_spec.rb
active-fedora-8.1.0 spec/unit/has_many_collection_spec.rb
active-fedora-8.0.1 spec/unit/has_many_collection_spec.rb
active-fedora-8.0.0 spec/unit/has_many_collection_spec.rb
active-fedora-8.0.0.rc3 spec/unit/has_many_collection_spec.rb
active-fedora-8.0.0.rc2 spec/unit/has_many_collection_spec.rb
active-fedora-8.0.0.rc1 spec/unit/has_many_collection_spec.rb
active-fedora-7.1.2 spec/unit/has_many_collection_spec.rb
active-fedora-7.1.1 spec/unit/has_many_collection_spec.rb
active-fedora-7.1.0 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.4 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.3 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.2 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.1 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.0 spec/unit/has_many_collection_spec.rb
active-fedora-7.0.0.rc3 spec/unit/has_many_collection_spec.rb