Sha256: 076a5262ab9c70c6854fecc5307f388f67451331ae995540c21d6f3a9b227d4f

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

require 'hyrax/collections_migration'

RSpec.describe Hyrax::CollectionsMigration do
  let(:collection1) { create(:collection, id: 'alien', title: ['alien movies']) }
  let(:collection2) { create(:collection, id: 'predator', title: ['predator movies']) }
  let(:work1) { create(:work, title: ['alien resurrection']) }
  let(:work2) { create(:work, title: ['the predator']) }
  let(:work3) { create(:work, title: ['alien vs. predator']) }

  before do
    collection1.members = [work1, work3]
    collection2.members = [work2, work3]
  end

  describe '.run' do
    it 'moves relationship from collection#members to curation_concern#member_of_collections' do
      expect(collection1.members.to_a.size).to eq 2
      expect(collection2.members.to_a.size).to eq 2
      expect(work1.member_of_collections.to_a.size).to eq 0
      expect(work2.member_of_collections.to_a.size).to eq 0
      expect(work3.member_of_collections.to_a.size).to eq 0
      described_class.run
      expect(collection1.reload.members.to_a.size).to eq 0
      expect(collection2.reload.members.to_a.size).to eq 0
      expect(work1.reload.member_of_collections.to_a.size).to eq 1
      expect(work1.member_of_collection_ids.first).to eq 'alien'
      expect(work2.reload.member_of_collections.to_a.size).to eq 1
      expect(work2.member_of_collection_ids.first).to eq 'predator'
      expect(work3.reload.member_of_collections.to_a.size).to eq 2
      expect(work3.member_of_collection_ids).to include 'predator'
      expect(work3.member_of_collection_ids).to include 'alien'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyrax-1.1.1 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.1.0 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.5 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.4 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.3 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.2 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.1 spec/lib/hyrax/collections_migration_spec.rb
hyrax-1.0.0.rc2 spec/lib/hyrax/collections_migration_spec.rb