Sha256: 7c572abd80c09a7919c4f2c3e31856661a2eca2fe2db1fc8131726e609de9ac6

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe Hyrax::Collections::SearchService do
  let(:login) { 'vanessa' }
  let(:session) { { history: [17, 14, 12, 9] } }
  let(:service) { described_class.new(session, login) }

  it "gets the documents for the first history entry" do
    expect(Search).to receive(:find).with(17).and_return(Search.new(query_params: { q: "World Peace" }))
    expect(service).to receive(:get_search_results).and_return([:one, [:doc1, :doc2]])
    expect(service.last_search_documents).to eq([:doc1, :doc2])
  end

  describe 'apply_gated_search' do
    before do
      allow(::User.group_service).to receive(:roles).with(login).and_return(['umg/test.group.1'])
    end

    let(:params) { service.apply_gated_search({}, {}) }
    let(:group_query) { params[:fq].first.split(' OR ')[1] }

    it "escapes slashes in groups" do
      expect(group_query).to eq('edit_access_group_ssim:umg\/test.group.1')
    end

    context "when Solr's access control suffix is overridden" do
      let(:service) { described_class.new({}, '') }
      it "uses the overriden value" do
        allow(service).to receive(:solr_access_control_suffix).and_return("edit_group_customfield")
        params = service.apply_gated_search({}, {})
        public_query = params[:fq].first.split(' OR ')[0]
        expect(public_query).to eq('edit_group_customfield:public')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.1.0 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.5 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.4 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.3 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.2 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.1 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.0.rc2 spec/lib/hyrax/collections/search_service_spec.rb
hyrax-1.0.0.rc1 spec/lib/hyrax/collections/search_service_spec.rb
test_hyrax-0.0.1.alpha spec/lib/hyrax/collections/search_service_spec.rb