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