-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new document and sidecar factories (#615)
and use them in bookmarks feature spec
- Loading branch information
1 parent
6cbc7b3
commit 5391afd
Showing
3 changed files
with
40 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FactoryBot.define do | ||
factory :sidecar, class: Spotlight::SolrDocumentSidecar do | ||
association :document, factory: :solr_document, strategy: :build | ||
association :exhibit | ||
data {} | ||
|
||
transient do | ||
manifest_url { "http://example.com/manifest" } | ||
access_id { nil } | ||
custom_fields { {} } | ||
with_indexed_document { false } | ||
end | ||
|
||
after(:create) do |sidecar, evaluator| | ||
sidecar.data["content_metadata_iiif_manifest_field_ssi"] = evaluator.manifest_url if evaluator.manifest_url | ||
sidecar.data["access_identifier_ssim"] = [evaluator.access_id] if evaluator.access_id | ||
evaluator.custom_fields.each do |k, v| | ||
sidecar.data["exhibit_#{sidecar.exhibit.slug}_#{k}_tesim"] = [v] | ||
end | ||
if evaluator.with_indexed_document | ||
sidecar.document.make_public! sidecar.exhibit | ||
sidecar.document.reindex | ||
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,6 @@ | ||
FactoryBot.define do | ||
factory :solr_document, class: SolrDocument, aliases: [:document] do | ||
sequence(:id) { |n| n.to_s } | ||
initialize_with { new(id: id) } | ||
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