Sha256: 4f9096134247c74184f4dfbe9c4310a0c8a626f5f656f9470f9286140f184805

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

# make sure a collection by another name still assigns the @collection variable
describe OtherCollectionsController, :type => :controller do
  before(:all) do
    class OtherCollection < ActiveFedora::Base
      include Hydra::Collection
    end

    class Member < ActiveFedora::Base
      include Hydra::Works::WorkBehavior
      include Hydra::AccessControls::Permissions
    end
  end

  after(:all) do
    Object.send(:remove_const, :Member)
    Object.send(:remove_const, :OtherCollection)
  end

  let(:user) { FactoryGirl.create(:user) }

  before do
    allow(controller).to receive(:has_access?).and_return(true)
    sign_in user
  end

  describe "#show" do
    let(:asset1) { Member.create!(read_users: [user.user_key]) }
    let(:asset2) { Member.create!(read_users: [user.user_key]) }
    let(:asset3) { Member.create!(read_users: [user.user_key]) }
    let(:collection) do
      OtherCollection.create(id: 'foo123', title: "My collection",
                             members: [asset1, asset2, asset3]) do |collection|
        collection.apply_depositor_metadata(user.user_key)
      end
    end

    before do
      allow(controller).to receive(:apply_gated_search)
    end

    it "shows the collections" do
      get :show, id: collection
      expect(assigns[:collection].title).to eq collection.title
      ids = assigns[:member_docs].map(&:id)
      expect(ids).to include(asset1.id, asset2.id, asset3.id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-collections-7.0.0 spec/controllers/other_collections_controller_spec.rb
hydra-collections-6.0.0 spec/controllers/other_collections_controller_spec.rb
hydra-collections-6.0.0.rc2 spec/controllers/other_collections_controller_spec.rb