-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable editing Valkyrie resources with children #5516
Merged
+169
−60
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Hyrax::PcdmMemberPresenterFactory, index_adapter: :solr_index, valkyrie_adapter: :test_adapter do | ||
RSpec.describe Hyrax::PcdmMemberPresenterFactory do | ||
subject(:factory) { described_class.new(solr_doc, ability) } | ||
let(:ability) { :FAKE_ABILITY } | ||
let(:ids) { [] } | ||
|
@@ -9,8 +9,7 @@ | |
RSpec::Matchers.define :be_presenter_for do |expected| | ||
match do |actual| | ||
actual.id == expected.id && | ||
(actual.solr_document['has_model_ssim'].first == | ||
expected.class.name) | ||
actual.model_name.name == expected.model_name.name | ||
end | ||
end | ||
|
||
|
@@ -33,92 +32,186 @@ | |
end | ||
end | ||
|
||
describe '#file_set_presenters' do | ||
it 'is empty' do | ||
expect(factory.file_set_presenters.to_a).to be_empty | ||
context 'with ActiveFedora index adapter' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to see this tested with both AF and Valkyrie. |
||
describe '#file_set_presenters' do | ||
it 'is empty' do | ||
expect(factory.file_set_presenters.to_a).to be_empty | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'builds only file_set presenters' do | ||
expect(factory.file_set_presenters) | ||
.to contain_exactly(*file_sets.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.file_set_presenters.map(&:id)).to eq file_sets.map(&:id) | ||
end | ||
end | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
describe '#member_presenters' do | ||
it 'is empty' do | ||
expect(factory.member_presenters.to_a).to be_empty | ||
end | ||
|
||
it 'builds only file_set presenters' do | ||
expect(factory.file_set_presenters) | ||
.to contain_exactly(*file_sets.map { |fs| be_presenter_for(fs) }) | ||
it 'accepts bespoke member ids' do | ||
fs = FactoryBot.valkyrie_create(:hyrax_file_set) | ||
Hyrax.index_adapter.save(resource: fs) | ||
|
||
expect(factory.member_presenters([fs.id]).to_a) | ||
.to contain_exactly(be_presenter_for(fs)) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.file_set_presenters.map(&:id)).to eq file_sets.map(&:id) | ||
it 'raises an error if given an unindexed id' do | ||
expect { factory.member_presenters(['FAKE_ID']).to_a } | ||
.to raise_error ArgumentError | ||
end | ||
end | ||
end | ||
|
||
describe '#member_presenters' do | ||
it 'is empty' do | ||
expect(factory.member_presenters.to_a).to be_empty | ||
end | ||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'accepts bespoke member ids' do | ||
fs = FactoryBot.valkyrie_create(:hyrax_file_set) | ||
Hyrax.index_adapter.save(resource: fs) | ||
it 'builds all member presenters' do | ||
members = file_sets + works | ||
|
||
expect(factory.member_presenters([fs.id]).to_a) | ||
.to contain_exactly(be_presenter_for(fs)) | ||
end | ||
expect(factory.member_presenters) | ||
.to contain_exactly(*members.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'raises an error if given an unindexed id' do | ||
expect { factory.member_presenters(['FAKE_ID']).to_a } | ||
.to raise_error ArgumentError | ||
it 'builds member presenters with appropriate classes' do | ||
expect(factory.member_presenters) | ||
.to contain_exactly(an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter)) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.member_presenters.map(&:id)).to eq ids | ||
end | ||
end | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
describe '#ordered_ids' do | ||
its(:ordered_ids) { is_expected.to eq ids } | ||
|
||
it 'builds all member presenters' do | ||
members = file_sets + works | ||
context 'with members' do | ||
include_context 'with members' | ||
|
||
expect(factory.member_presenters) | ||
.to contain_exactly(*members.map { |fs| be_presenter_for(fs) }) | ||
its(:ordered_ids) { is_expected.to eq ids } | ||
end | ||
end | ||
|
||
it 'builds member presenters with appropriate classes' do | ||
expect(factory.member_presenters) | ||
.to contain_exactly(an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter)) | ||
describe '#work_presenters' do | ||
it 'is empty' do | ||
expect(factory.work_presenters.to_a).to be_empty | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.member_presenters.map(&:id)).to eq ids | ||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'builds only work presenters' do | ||
expect(factory.work_presenters) | ||
.to contain_exactly(*works.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.work_presenters.map(&:id)).to eq works.map(&:id) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe '#ordered_ids' do | ||
its(:ordered_ids) { is_expected.to eq ids } | ||
context 'with Valkyrie index adapter', index_adapter: :solr_index, valkyrie_adapter: :test_adapter do | ||
describe '#file_set_presenters' do | ||
it 'is empty' do | ||
expect(factory.file_set_presenters.to_a).to be_empty | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
context 'with members' do | ||
include_context 'with members' | ||
|
||
its(:ordered_ids) { is_expected.to eq ids } | ||
it 'builds only file_set presenters' do | ||
expect(factory.file_set_presenters) | ||
.to contain_exactly(*file_sets.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.file_set_presenters.map(&:id)).to eq file_sets.map(&:id) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe '#work_presenters' do | ||
it 'is empty' do | ||
expect(factory.work_presenters.to_a).to be_empty | ||
describe '#member_presenters' do | ||
it 'is empty' do | ||
expect(factory.member_presenters.to_a).to be_empty | ||
end | ||
|
||
it 'accepts bespoke member ids' do | ||
fs = FactoryBot.valkyrie_create(:hyrax_file_set) | ||
Hyrax.index_adapter.save(resource: fs) | ||
|
||
expect(factory.member_presenters([fs.id]).to_a) | ||
.to contain_exactly(be_presenter_for(fs)) | ||
end | ||
|
||
it 'raises an error if given an unindexed id' do | ||
expect { factory.member_presenters(['FAKE_ID']).to_a } | ||
.to raise_error ArgumentError | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'builds all member presenters' do | ||
members = file_sets + works | ||
|
||
expect(factory.member_presenters) | ||
.to contain_exactly(*members.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'builds member presenters with appropriate classes' do | ||
expect(factory.member_presenters) | ||
.to contain_exactly(an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::WorkShowPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter), | ||
an_instance_of(Hyrax::FileSetPresenter)) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.member_presenters.map(&:id)).to eq ids | ||
end | ||
end | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
describe '#ordered_ids' do | ||
its(:ordered_ids) { is_expected.to eq ids } | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'builds only work presenters' do | ||
expect(factory.work_presenters) | ||
.to contain_exactly(*works.map { |fs| be_presenter_for(fs) }) | ||
its(:ordered_ids) { is_expected.to eq ids } | ||
end | ||
end | ||
|
||
describe '#work_presenters' do | ||
it 'is empty' do | ||
expect(factory.work_presenters.to_a).to be_empty | ||
end | ||
|
||
context 'with members' do | ||
include_context 'with members' | ||
|
||
it 'builds only work presenters' do | ||
expect(factory.work_presenters) | ||
.to contain_exactly(*works.map { |fs| be_presenter_for(fs) }) | ||
end | ||
|
||
it 'gives members in order' do | ||
expect(factory.work_presenters.map(&:id)).to eq works.map(&:id) | ||
it 'gives members in order' do | ||
expect(factory.work_presenters.map(&:id)).to eq works.map(&:id) | ||
end | ||
end | ||
end | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
generic_type
field is used inPcdmMemberPresenterFactory
. This is called from:Hyrax::WorkShowPresenter #member_presenter_factory
which only calls it forValkyrie::Resource
Hyrax::WorkFormHelper #form_file_set_select_for(parent:)
which is called from several views.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with Main and with this PR's branch. The behavior for GenericWork is the same for both branches. GenericWork uses a different member_presenter_factory that does not depend on
generic_type_si
, so the addition of this index field has no impact on non-valkyrie works.