Sha256: efcbd322f1695e7559a26a364185a4189d6ba032b8bd70be7d3e7bdb1e237dba

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe SearchBuilder do
  let(:processor_chain) { [:add_access_controls_to_solr_params] }
  let(:context) { double('context') }
  let(:user) { double('user', user_key: 'joe') }
  let(:current_ability) { double('ability', user_groups: [], current_user: user) }
  let(:search_builder) { described_class }

  subject do
    Deprecation.silence(Hydra::SearchBuilder) do
      search_builder.new(processor_chain, context)
    end
  end
  before { subject.current_ability = current_ability }

  it "extends classes with the necessary Hydra modules" do
    expect(Hydra::SearchBuilder.included_modules).to include(Hydra::AccessControlsEnforcement)
  end

  context "when a query is generated" do
    it "triggers add_access_controls_to_solr_params" do
      expect(subject).to receive(:add_access_controls_to_solr_params)
      subject.query
    end
  end

  context "the deprecated Hydra::SearchBuilder" do
    let(:search_builder) { Hydra::SearchBuilder }

    it "extends classes with the necessary Hydra modules" do
      expect(Hydra::SearchBuilder.included_modules).to include(Hydra::AccessControlsEnforcement)
    end

    context "when a query is generated" do
      it "triggers add_access_controls_to_solr_params" do
        expect(subject).to receive(:add_access_controls_to_solr_params)
        subject.query
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hydra-core-9.10.0 spec/search_builders/search_builder_spec.rb
hydra-core-9.9.0 spec/search_builders/search_builder_spec.rb