Skip to content

Commit

Permalink
changed is_empty_bi to be stored as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Banu Kutlu committed Mar 2, 2022
1 parent 3dce992 commit 432fd1b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/catalog_search_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def restrict_search_to_works_and_collections(solr_parameters)

def exclude_empty_collections(solr_parameters)
solr_parameters[:fq] ||= []
solr_parameters[:fq] << '-is_empty_bi:true'
solr_parameters[:fq] << '-is_empty_bsi:true'
end

def limit_to_public_resources(solr_parameters)
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/collection_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def document
return {} unless resource.respond_to?(:empty?)

{
is_empty_bi: resource.empty?
is_empty_bsi: resource.empty?
}
end
end
14 changes: 8 additions & 6 deletions spec/indexers/work_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
end

context 'when the work belongs to a collection' do
let(:work) { create(:work, has_draft: true) }
let(:work_version) { work.versions[0] }
let(:collection) { create :collection }
let(:work) { create(:work, :with_authorized_access) }
let(:work_version) { create :work_version, :able_to_be_published, work: work }
let(:collection) { create(:collection) }

before do
create :collection_work_membership, collection: collection, work: work
collection.collection_work_memberships.build(work: work)
collection.save!
end

it 'indexes the work collection' do
Expand All @@ -64,9 +65,10 @@

context 'when the collection is empty and only draft work changes state from draft to published' do
it 'indexes the collection as not empty' do
expect(SolrDocument.find(collection.uuid)[:is_empty_bi]).to be(true)
expect(SolrDocument.find(collection.uuid)[:is_empty_bsi]).to be(true)
work_version.publish
expect(SolrDocument.find(collection.uuid)[:is_empty_bi]).to be(false)
work_version.save!
expect(SolrDocument.find(collection.uuid)[:is_empty_bsi]).to be(false)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
thumbnail_url_ssi
auto_generate_thumbnail_tesim
notify_editors_tesim
is_empty_bi
is_empty_bsi
)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end

it 'excludes empty collections' do
expect(parameters['fq']).to include('-is_empty_bi:true')
expect(parameters['fq']).to include('-is_empty_bsi:true')
end
end

Expand All @@ -57,7 +57,7 @@
end

it 'excludes empty collections' do
expect(parameters['fq']).to include('-is_empty_bi:true')
expect(parameters['fq']).to include('-is_empty_bsi:true')
end

it 'restricts to published works' do
Expand All @@ -72,7 +72,7 @@
let(:user) { build(:user, :admin) }

it 'shows all Works and excludes empty Collections' do
expect(parameters['fq']).to contain_exactly('-is_empty_bi:true',
expect(parameters['fq']).to contain_exactly('-is_empty_bsi:true',
'{!terms f=model_ssi}Work,Collection')
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/schemas/collection_schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:resource) { build(:collection) }

its(:document) do
is_expected.to eq(is_empty_bi: true)
is_expected.to eq(is_empty_bsi: true)
end
end

Expand All @@ -22,7 +22,7 @@
end

its(:document) do
is_expected.to eq(is_empty_bi: false)
is_expected.to eq(is_empty_bsi: false)
end
end
end
Expand Down

0 comments on commit 432fd1b

Please sign in to comment.