Sha256: af46b45caa7c4f8f3cf8a7802d06e81a8f5833bf6be01b9ed54eb80ad80099a1

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require "spec_helper"

describe Hydra::Collections::Collectible do
  before do
    class CollectibleThing < ActiveFedora::Base
      include Hydra::Collections::Collectible
    end
  end

  let(:collection1) { FactoryGirl.build(:collection) }
  let(:collection2) { FactoryGirl.create(:collection) }
  let(:collectible) { CollectibleThing.create }

  after do
    Object.send(:remove_const, :CollectibleThing)
  end

  describe "collections associations" do
    before do
      collection1.members << collectible
      collection1.save
      collection2.members << collectible
      collection2.save
    end

    it "queries the members" do
      expect(collectible.reload.collections).to eq [collection1, collection2]
    end

    it "counts the members" do
      expect(collectible.reload.collections.size).to eq 2
    end

    it "queries the ids" do
      expect(collectible.reload.collection_ids).to eq [collection1.id, collection2.id]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-collections-6.0.0.alpha spec/lib/collectible_spec.rb