Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2560 from pulibrary/no_nested_objects
Don't index nested objects
- Loading branch information
Showing
6 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
require "valkyrie/specs/shared_specs" | ||
|
||
RSpec.describe ParentIssueIndexer do | ||
it_behaves_like "a Valkyrie::Persistence::Solr::Indexer" | ||
describe "#to_solr" do | ||
context "when given a not-coin" do | ||
it "returns an empty hash" do | ||
indexer = described_class.new(resource: ScannedResource.new) | ||
|
||
expect(indexer.to_solr).to eq({}) | ||
end | ||
end | ||
context "when given a resource without parents" do | ||
it "returns an empty hash" do | ||
coin = FactoryBot.create_for_repository(:coin) | ||
indexer = described_class.new(resource: coin) | ||
|
||
expect(indexer.to_solr).to eq({}) | ||
end | ||
end | ||
context "when given a coin with an issue" do | ||
it "returns issue properties" do | ||
coin = FactoryBot.create_for_repository(:coin) | ||
FactoryBot.create_for_repository(:numismatic_issue, member_ids: coin.id) | ||
indexer = described_class.new(resource: coin) | ||
|
||
expect(indexer.to_solr).to eq( | ||
"issue_denomination_tesim" => ["$1"], | ||
"issue_issue_number_tesim" => ["1"], | ||
"issue_rights_statement_tesim" => [RightsStatements.no_known_copyright] | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
require "valkyrie/specs/shared_specs" | ||
|
||
RSpec.describe SortingIndexer do | ||
it_behaves_like "a Valkyrie::Persistence::Solr::Indexer" | ||
describe "#to_solr" do | ||
context "when given a resource with a sort title" do | ||
it "indexes it" do | ||
resource = instance_double(ScannedResource, sort_title: "Sort") | ||
indexer = described_class.new(resource: resource) | ||
|
||
expect(indexer.to_solr).to eq(title_ssort: "Sort") | ||
end | ||
end | ||
context "when given a resource with a title" do | ||
it "indexes the first title downcased" do | ||
resource = instance_double(ScannedResource, title: ["Sort"]) | ||
indexer = described_class.new(resource: resource) | ||
|
||
expect(indexer.to_solr).to eq(title_ssort: "sort") | ||
end | ||
end | ||
context "when there's no titles" do | ||
it "defaults to the id of the resource" do | ||
resource = instance_double(ScannedResource, id: Valkyrie::ID.new("sort")) | ||
indexer = described_class.new(resource: resource) | ||
|
||
expect(indexer.to_solr).to eq(title_ssort: "sort") | ||
end | ||
end | ||
end | ||
end |