-
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
Allow work form to display when wings is disabled #5242
Conversation
When `disable_wings=true`, the `Wings` constant is not defined. As a result, you cannot check directly to see if the metadata adapter is “Wings::Valkyrie::MetadataAdapter”. This check results in a “NameError”. If we check for `disable_wings` first, then it avoids the check of the metadata adapter.
before do | ||
allow(Hyrax).to receive_message_chain(:config, :disable_wings).and_return(true) # rubocop:disable RSpec/MessageChain | ||
hide_const("Wings") # disable_wings=true removes the Wings constant | ||
end |
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.
It already has a test using a non-wings adapter, but it doesn't fully simulate disabled wings. When it is disabled, the Wings
constant doesn't exist. The new before block simulates disable_wings
returning true
and the Wings
constant not existing.
it 'prepopulates as empty before save' do | ||
expect(Hyrax.logger).to receive(:info) | ||
.with(starting_with("trying to prepopulate a lock token for")) |
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.
It isn't a change that the logger adds this info message. This expect line just confirms the message was logged.
self.version = | ||
case Hyrax.metadata_adapter | ||
when Wings::Valkyrie::MetadataAdapter | ||
if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter) |
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 case
statement didn't allow for checking disable_wings
before trying to use the Wings
constant. The change is a simple rewrite of the case
into an if
to allow for the more complex check. The code that is executed for each case is the same.
Description
When
Hyrax.config.disable_wings # true
theWings
constant is not defined. This is the correct behavior, but means that any reference toWings
inapp
needs to check ifdisable_wings #true
before using theWings
constant.This PR addresses a specific instance in
Hyrax::ResourceForm
where there was a check to see if the metadata adapter is wings.This PR includes
Wings
constant so that it provides a failing test for the scenario described in this PRExpected
Dashboard -> Works -> Add new work -> displays the work form
Actual
Dashboard -> Works -> Add new work -> raises an exception
Related Work
There are other places where
Wings
is used without checkingdisable_wings #true
. A cursory review indicates that these locations are places not expected to be encountered when using a non-wings adapter for Valkyrie (e.g. actor stack code, AF forms). It is possible that other locations may be uncovered later that would need a similar approach as applied in this PR.@samvera/hyrax-code-reviewers