Skip to content
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

Unpin Blacklight #5784

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/services/hyrax/collection_member_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ def list_collections
def collection_search_builder
@collection_search_builder ||= ParentCollectionSearchBuilder.new([:include_item_ids, :add_paging_to_solr, :add_access_controls_to_solr_params], self)
end

def search_state_class; end
end
end
4 changes: 4 additions & 0 deletions app/services/hyrax/embargo_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def assets_with_deactivated_embargoes
presenters(builder)
end

def search_state_class
nil
end

private

def presenter_class
Expand Down
4 changes: 4 additions & 0 deletions app/services/hyrax/lease_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def assets_with_deactivated_leases
presenters(builder)
end

def search_state_class
nil
end

private

def presenter_class
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/statistics/depositors/summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def depositors

private

delegate :blacklight_config, to: CatalogController
delegate :blacklight_config, :search_state_class, to: CatalogController
delegate :depositor_field, to: DepositSearchBuilder

# results come from Solr in an array where the first item is the user and
Expand Down
2 changes: 1 addition & 1 deletion hyrax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SUMMARY
spec.add_dependency 'active-fedora', '~> 13.1', '>= 13.1.2'
spec.add_dependency 'almond-rails', '~> 0.1'
spec.add_dependency 'awesome_nested_set', '~> 3.1'
spec.add_dependency 'blacklight', '< 7.25'
spec.add_dependency 'blacklight', '~> 7.25'
spec.add_dependency 'blacklight-gallery', '~> 4.0'
spec.add_dependency 'breadcrumbs_on_rails', '~> 3.0'
spec.add_dependency 'browse-everything', '>= 0.16', '< 2.0'
Expand Down
4 changes: 4 additions & 0 deletions lib/hyrax/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class Engine < ::Rails::Engine
message += "It is UNEXPECTED if you are booting up a Hyrax powered application via `rails server'"
Rails.logger.info(message)
end

# Force CatalogController to use our SearchState class, which has an important
# work-around for some highly suspect SPARQL-gem monkeypatching.
CatalogController.search_state_class = Hyrax::SearchState if CatalogController.search_state_class == Blacklight::SearchState
end

initializer 'requires' do
Expand Down
9 changes: 9 additions & 0 deletions lib/hyrax/search_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ def url_for_document(doc, _options = {})
return [hyrax, doc] if doc.collection?
[main_app, doc]
end

# The SPARQL gem stomps on the Rails definition of deep_dup and gives us a Hash instead of
# a HashWithIndifferentAccess. This is an ugly workaround to get the right contract with
# the upstream class.
# https://github.com/ruby-rdf/sparql/blob/develop/lib/sparql/algebra/extensions.rb#L238-L244
def to_hash
super.with_indifferent_access
end
alias to_h to_hash
end
end
1 change: 1 addition & 0 deletions spec/helpers/hyrax/collections_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
allow(controller).to receive(:blacklight_config).and_return(bl_config)
allow(controller).to receive(:repository).and_return(repository)
allow(controller).to receive(:current_ability).and_return(ability)
allow(controller).to receive(:search_state_class).and_return(nil)
end

it 'gives an empty set for a missing collection' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class Member < ActiveFedora::Base
let(:blacklight_config) { CatalogController.blacklight_config }
let(:repository) { Blacklight::Solr::Repository.new(blacklight_config) }
let(:current_ability) { instance_double(Ability, admin?: true) }
let(:scope) { double('Scope', can?: true, current_ability: current_ability, repository: repository, blacklight_config: blacklight_config) }
let(:scope) { double('Scope', can?: true, current_ability: current_ability, repository: repository, blacklight_config: blacklight_config, search_state_class: nil) }

context 'when building a collection' do
let(:coll123) do
Expand Down
3 changes: 2 additions & 1 deletion spec/search_builders/hyrax/admin_set_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
RSpec.describe Hyrax::AdminSetSearchBuilder do
let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability)
current_ability: ability,
search_state_class: nil)
end
let(:ability) do
::Ability.new(user)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Hyrax::CollectionMemberSearchBuilder do
subject(:builder) { described_class.new(scope: context, collection: collection, search_includes_models: include_models) }
let(:context) { double("context", blacklight_config: CatalogController.blacklight_config) }
let(:context) { double("context", blacklight_config: CatalogController.blacklight_config, search_state_class: nil) }
let(:solr_params) { { fq: [] } }
let(:include_models) { :both }
let(:collection) { build(:collection_lw, id: '12345') }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability,
current_user: user)
current_user: user,
search_state_class: nil)
end
let(:ability) do
::Ability.new(user)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.describe Hyrax::Dashboard::NestedCollectionsSearchBuilder do
let(:scope) { double(current_ability: ability, blacklight_config: CatalogController.blacklight_config) }
let(:scope) { double(current_ability: ability, blacklight_config: CatalogController.blacklight_config, search_state_class: nil) }
let(:access) { :read }
let(:user) { create(:user) }
let(:ability) { ::Ability.new(user) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability,
current_user: user)
current_user: user,
search_state_class: nil)
end
let(:ability) do
::Ability.new(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability,
current_user: user)
current_user: user,
search_state_class: nil)
end
let(:ability) do
::Ability.new(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let(:solr_params) { { fq: [] } }
let(:item) { double(id: '12345', member_of_collection_ids: ['col1']) }
let(:builder) { described_class.new(solr_params, context) }
let(:context) { double("context", blacklight_config: CatalogController.blacklight_config, item: item) }
let(:context) { double("context", blacklight_config: CatalogController.blacklight_config, item: item, search_state_class: nil) }

describe '#include_item_ids' do
let(:subject) { builder.include_item_ids(solr_params) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
let(:ability) { instance_double(Ability, admin?: true) }
let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability)
current_ability: ability,
search_state_class: nil)
end
let(:builder) { described_class.new(context) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

let(:context) do
double(blacklight_config: CatalogController.blacklight_config,
current_ability: ability)
current_ability: ability,
search_state_class: nil)
end

let(:ability) do
Expand Down
3 changes: 2 additions & 1 deletion spec/services/hyrax/admin_set_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
let(:context) do
double(current_ability: Ability.new(user),
repository: controller.repository,
blacklight_config: controller.blacklight_config)
blacklight_config: controller.blacklight_config,
search_state_class: nil)
end
let(:service) { described_class.new(context) }
let(:user) { create(:user) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:user) { create(:user) }
let(:ability) { ::Ability.new(user) }
let(:current_ability) { ability }
let(:scope) { double('Scope', can?: true, current_ability: current_ability, repository: repository, blacklight_config: blacklight_config) }
let(:scope) { double('Scope', can?: true, current_ability: current_ability, repository: repository, blacklight_config: blacklight_config, search_state_class: nil) }

let(:collection_type) { create(:collection_type) }
let(:another_collection_type) { create(:collection_type) }
Expand Down
8 changes: 6 additions & 2 deletions spec/support/fakes/fake_search_builder_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# - +#current_user+
# - +#params+
# - +#repository+
# - +#search_state_class+
#
# This provides a fake scope with more control than a generic RSpec double.
class FakeSearchBuilderScope
Expand All @@ -24,17 +25,20 @@ class FakeSearchBuilderScope
# @return [Hash]
# @!attribute [r] repository
# @return [Blacklight::AbstractRepository]
attr_reader :blacklight_config, :current_ability, :current_user, :params, :repository
# @!attribute [r] search_state_class
# @return [Blacklight::SearchState, nil]
attr_reader :blacklight_config, :current_ability, :current_user, :params, :repository, :search_state_class

##
# @param [Blacklight::Configuration] blacklight_config
# @param [::Ability, nil] current_ability
# @param [::User, nil] current_user
def initialize(blacklight_config: CatalogController.blacklight_config, current_ability: nil, current_user: nil, params: {})
def initialize(blacklight_config: CatalogController.blacklight_config, current_ability: nil, current_user: nil, params: {}, search_state_class: nil)
@blacklight_config = blacklight_config
@current_user = current_user
@current_ability = current_ability || ::Ability.new(current_user)
@params = params
@repository = Blacklight::Solr::Repository.new(blacklight_config)
@search_state_class = search_state_class
end
end