Skip to content

Commit

Permalink
Merge pull request #6516 from samvera/updates_collection_member_searc…
Browse files Browse the repository at this point in the history
…h_builder_spec

Adds active_fedora tag to AF-specific tests in collection_member_search_builder_spec and refactors.
  • Loading branch information
dlpierce authored Dec 8, 2023
2 parents 387a439 + a675bb7 commit 855424c
Showing 1 changed file with 13 additions and 40 deletions.
53 changes: 13 additions & 40 deletions spec/search_builders/hyrax/collection_member_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@
let(:context) { double("context", blacklight_config: CatalogController.blacklight_config, search_state_class: nil) }
let(:solr_params) { { fq: [] } }
let(:include_models) { :both }
let(:collection) { build(:collection_lw, id: '12345') }

describe ".default_processor_chain" do
subject { builder.default_processor_chain }

it { is_expected.to include :member_of_collection }
it { is_expected.to include :filter_models }
end

context 'with a valkyrie collection' do
let(:collection) { build(:hyrax_collection, id: '12345') }

shared_examples('tests for #member_of_collection and #filter_models') do
describe '#member_of_collection' do
it 'updates solr_parameters[:fq]' do
expect { builder.member_of_collection(solr_params) }
Expand Down Expand Up @@ -53,39 +43,22 @@
end
end

describe '#member_of_collection' do
it 'updates solr_parameters[:fq]' do
expect { builder.member_of_collection(solr_params) }
.to change { solr_params[:fq] }
.to include("#{builder.collection_membership_field}:#{collection.id}")
end
end
context 'with an ActiveFedora collection', :active_fedora do
let(:collection) { build(:collection_lw, id: '12345') }

describe '#filter_models' do
it 'updates solr_parameters[:fq] to include both works and collections' do
expect { builder.filter_models(solr_params) }
.to change { solr_params[:fq].first }
.to include('f=has_model_ssim', 'GenericWork', 'Collection')
end
describe ".default_processor_chain" do
subject { builder.default_processor_chain }

context 'when limiting to works' do
let(:include_models) { :works }

it 'updates solr_parameters[:fq] to include only works' do
expect { builder.filter_models(solr_params) }
.to change { solr_params[:fq].first }
.to include('f=has_model_ssim', 'GenericWork')
end
it { is_expected.to include :member_of_collection }
it { is_expected.to include :filter_models }
end

context 'when limiting to collections' do
let(:include_models) { :collections }
include_examples 'tests for #member_of_collection and #filter_models'
end

it 'updates solr_parameters[:fq] to include only collections' do
expect { builder.filter_models(solr_params) }
.to change { solr_params[:fq].first }
.to include('f=has_model_ssim', 'Collection')
end
end
context 'with a valkyrie collection' do
let(:collection) { build(:hyrax_collection, id: '12345') }

include_examples 'tests for #member_of_collection and #filter_models'
end
end

0 comments on commit 855424c

Please sign in to comment.