Skip to content

Commit

Permalink
Ensuring that Collections are faceted and indexed between exhibits
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Apr 26, 2018
1 parent 04025b0 commit 82e54fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def unique_custom_fields
config.add_sort_field 'sort_author', sort: 'sort_author_ssi asc, sort_title_ssi asc', label: 'Author'

config.add_facet_field 'spotlight_resource_type_ssim'
config.add_facet_field 'readonly_collections_ssim', label: 'Collections'
config.add_index_field 'readonly_collections_ssim', label: 'Collections'
config.index.thumbnail_field = 'thumbnail_ssim'

config.add_facet_fields_to_solr_request!
Expand Down
27 changes: 26 additions & 1 deletion spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,33 @@

expect(document_ids.length).to eq 1
expect(assigns[:response][:response][:numFound]).to eq 1
expect(assigns[:response]["facet_counts"]["facet_fields"]).to eq("readonly_language_ssim" => [], "readonly_subject_ssim" => [])
expect(assigns[:response]["facet_counts"]["facet_fields"]).to include "readonly_language_ssim" => []
expect(assigns[:response]["facet_counts"]["facet_fields"]).to include "readonly_subject_ssim" => []
end

describe '#index' do
before do
index.add(id: '3',
full_title_ssim: ['Item B'],
readonly_title_ssim: ['Item B'],
spotlight_resource_type_ssim: ['iiif_resources'],
readonly_collections_ssim: ['Collection A', 'Collection B'])
index.commit

get :index, params: { q: '' }
end

it 'facets upon collections' do
expect(assigns[:response][:facet_counts][:facet_fields]).not_to be_empty
expect(assigns[:response][:facet_counts][:facet_fields]).to include readonly_collections_ssim: ['Collection A', 1, 'Collection B', 1]
end

it 'indexes collections' do
expect(assigns[:response][:response][:docs]).not_to be_empty
expect(assigns[:response][:response][:docs].first).to include readonly_collections_ssim: ['Collection A', 'Collection B']
end
end

it "can get a single record by its access identifier" do
index.add(id: "1",
access_identifier_ssim: "123")
Expand Down

0 comments on commit 82e54fd

Please sign in to comment.