Skip to content

Commit

Permalink
Merge pull request WGBH-MLA#570 from WGBH-MLA/add-spec-for-solr-doc-r…
Browse files Browse the repository at this point in the history
…eturning-more-than-10-children

Adds spec for SolrDocument#members
  • Loading branch information
foglabs authored May 11, 2021
2 parents 88c1d2c + 8670d1e commit f9b3984
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
let(:asset) { create(:asset, :with_physical_digital_and_essence_track) }
let(:asset_solr_doc) { SolrDocument.find(asset.id) }

let(:all_member_ids) { asset.all_members.map(&:id) }


describe '#title' do
context 'when other titles are present' do
let(:other_titles) do
Expand Down Expand Up @@ -141,4 +138,31 @@
expect(asset_solr_doc.all_members.map(&:id).to_set).to eq(asset.all_members.map(&:id).to_set)
end
end

describe '#members' do
context 'with > 10 members (i.e. the default row limit)' do
let(:asset) {
create(:asset, ordered_members: [
# 11 members across 3 different types
create_list(:contribution, 9),
create(:digital_instantiation),
create(:digital_instantiation)
].flatten)
}

let(:expected_member_ids) {[
asset.contributions.map(&:id),
asset.digital_instantiations.map(&:id),
asset.physical_instantiations.map(&:id)
].flatten

}

it 'returns them all' do
expect(asset_solr_doc.members.map(&:id).to_set).to eq expected_member_ids.to_set
end
end
end


end

0 comments on commit f9b3984

Please sign in to comment.