Sha256: fab65f65fc0cf31098d26e1d9c8493e7c880c844f3806fc2fb0abe1e29a3d291

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require "spec_helper"
class CollectibleThing < ActiveFedora::Base
  include Hydra::Collections::Collectible
end

describe Hydra::Collections::Collectible do
  before do
    @collection1 = FactoryGirl.create(:collection)
    @collection2 = FactoryGirl.create(:collection)
    @collectible = CollectibleThing.new
  end
  describe "collections associations" do
    it "should allow adding and removing" do
      @collectible.save
      @collection1.members << @collectible
      @collection1.save
      @collectible.collections << @collection2
      reloaded = CollectibleThing.find(@collectible.pid)
      expect(@collection2.reload.members).to eq([@collectible])
      expect(reloaded.collections).to eq([@collection1, @collection2])
    end
  end
  describe "index_collection_pids" do
    it "should add pids for all associated collections" do
      @collectible.save
      @collectible.collections << @collection1
      @collectible.collections << @collection2
      expect(@collectible.index_collection_pids["collection_sim"]).to eq([@collection1.pid, @collection2.pid])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-collections-3.0.0.beta3 spec/lib/collectible_spec.rb
hydra-collections-2.0.5 spec/lib/collectible_spec.rb
hydra-collections-2.0.4 spec/lib/collectible_spec.rb