-
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.
Fix up polymorphism for core model types (#5)
* Fix up polymorphism for core model types Previously the manuscript, holding, and record classes weren't doing much. They were added with an eye toward polymorphism, but the ExportRepresenter was converting all item hashes unconditionally to a generic DsItem object with methods applicable to all three. This change gets ExportRepresenter working as intended so that Holding, Manuscript, and Record objects are created by ExportRepresenter where appropriate. DsItem is removed as no longer needed, and all unused methods of the core model types are removed as well. The spec helper export hash is also updated to accommodate these changes. Addresses comment on #3 * Apply suggestions from code review Co-authored-by: emeryr-upenn <[email protected]> * Revive DsItem, add instance_of method * cleanup --------- Co-authored-by: emeryr-upenn <[email protected]>
- Loading branch information
1 parent
c32abe1
commit 694c65d
Showing
12 changed files
with
73 additions
and
194 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
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
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 |
---|---|---|
@@ -1,34 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'wikibase_representable' | ||
|
||
module DigitalScriptorium | ||
include WikibaseRepresentable::Model | ||
include WikibaseRepresentable::Representers | ||
|
||
RSpec.describe ExportRepresenter do | ||
let(:holding_json) { read_fixture('items/Q542_holding_example.json') } | ||
let(:manuscript_json) { read_fixture('items/Q543_manuscript_example.json') } | ||
let(:record_json) { read_fixture('items/Q544_record_example.json') } | ||
let(:property_json) { read_fixture('properties/P16_instance_of.json') } | ||
let(:export) do | ||
described_class.new(Export.new).from_json("[#{holding_json},#{manuscript_json},#{record_json},#{property_json}]") | ||
it 'deserializes holding as a Holding' do | ||
expect(export_hash.fetch('Q542')).to be_instance_of Holding | ||
end | ||
|
||
it 'deserializes holding as a DsItem' do | ||
expect(export[0]).to be_instance_of DsItem | ||
it 'deserializes manuscript as a Manuscript' do | ||
expect(export_hash.fetch('Q543')).to be_instance_of Manuscript | ||
end | ||
|
||
it 'deserializes manuscript as a DsItem' do | ||
expect(export[1]).to be_instance_of DsItem | ||
it 'deserializes record as a Record' do | ||
expect(export_hash.fetch('Q544')).to be_instance_of Record | ||
end | ||
|
||
it 'deserializes record as a DsItem' do | ||
expect(export[2]).to be_instance_of DsItem | ||
it 'deserializes property as a Property' do | ||
expect(export_hash.fetch('P16')).to be_instance_of Property | ||
end | ||
|
||
it 'deserializes property as a Property' do | ||
expect(export[3]).to be_instance_of Property | ||
it 'deserializes non-core item as a DsItem' do | ||
expect(export_hash.fetch('Q129')).to be_instance_of DsItem | ||
end | ||
end | ||
end |
Oops, something went wrong.