Sha256: 2117ffd4c033780b8afd6d81a4bc76c02bcee67f3dba87bafb8514a8bf41ab82
Contents?: true
Size: 1.47 KB
Versions: 9
Compression:
Stored size: 1.47 KB
Contents
require 'spec_helper' describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do it "should call add_relationship" do subject = double("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => []) predicate = double(:klass => double.class, :options=>{:property=>'predicate'}, :class_name=> nil) ActiveFedora::SolrService.stub(:query).and_return([]) ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate) object = double("object", :new_record? => false, :pid => 'object:b', :save => nil) subject.should_receive(:add_relationship).with('predicate', object) ac << object end it "should call add_relationship on subject and object when inverse_of given" do subject = double("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => []) predicate = double(:klass => double.class, :options=>{:property=>'predicate', :inverse_of => 'inverse_predicate'}, :class_name=> nil) ActiveFedora::SolrService.stub(:query).and_return([]) ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate) object = double("object", :new_record? => false, :pid => 'object:b', :save => nil) subject.should_receive(:add_relationship).with('predicate', object) object.should_receive(:add_relationship).with('inverse_predicate', subject) ac << object end end
Version data entries
9 entries across 9 versions & 1 rubygems