Sha256: af6b4bf945e33bebb28cf244ee5dfa3f3db8932c08050d45282602e853cbf323

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

RSpec.describe CurationConcerns::CollectionsService do
  let(:controller) { ::CatalogController.new }

  let(:context) do
    double(current_ability: Ability.new(user),
           repository: controller.repository,
           blacklight_config: controller.blacklight_config)
  end

  let(:service) { described_class.new(context) }
  let(:user) { create(:user) }

  describe "#search_results" do
    subject { service.search_results(access) }
    let!(:collection1) { create(:collection, :public, title: ['foo']) }
    let!(:collection2) { create(:collection, :public, title: ['bar']) }
    let!(:collection3) { create(:collection, :public, edit_users: [user.user_key], title: ['baz']) }
    before do
      create(:admin_set, :public) # this should never be returned.
    end

    context "with read access" do
      let(:access) { :read }
      it "returns three collections" do
        expect(subject.map(&:id)).to match_array [collection1.id, collection2.id, collection3.id]
      end
    end

    context "with edit access" do
      let(:access) { :edit }
      it "returns one collections" do
        expect(subject.map(&:id)).to match_array [collection3.id]
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.7 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-2.0.0 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-2.0.0.rc2 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.6 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.5 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.4 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.3 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.2 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-2.0.0.rc1 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.1 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.0 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.7.0.beta1 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.6.3 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.6.2 spec/services/curation_concerns/collections_service_spec.rb
curation_concerns-1.6.1 spec/services/curation_concerns/collections_service_spec.rb