From d5b8a61010ab108107714e41afcc7361f2acb302 Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Mon, 27 Mar 2023 17:07:21 -0400 Subject: [PATCH] Cleanup use of removed compatibility methods --- app/controllers/concerns/hyrax/controller.rb | 2 +- app/controllers/concerns/hyrax/works_controller_behavior.rb | 1 + app/controllers/hyrax/dashboard/collections_controller.rb | 2 +- app/controllers/hyrax/file_sets_controller.rb | 2 +- app/helpers/hyrax/hyrax_helper_behavior.rb | 2 +- app/services/hyrax/admin_set_service.rb | 2 +- .../hyrax/collections/nested_collection_query_service.rb | 4 ++-- app/services/hyrax/restriction_service.rb | 2 +- .../hyrax/dashboard/nest_collections_controller_spec.rb | 2 +- spec/controllers/hyrax/dashboard/works_controller_spec.rb | 2 +- spec/controllers/hyrax/my/collections_controller_spec.rb | 2 +- spec/controllers/hyrax/my/works_controller_spec.rb | 2 +- spec/forms/hyrax/forms/admin_set_form_spec.rb | 2 +- spec/forms/hyrax/forms/collection_form_spec.rb | 2 +- spec/helpers/hyrax_helper_spec.rb | 3 ++- spec/services/hyrax/admin_set_service_spec.rb | 2 +- spec/services/hyrax/collections_service_spec.rb | 2 +- spec/views/hyrax/base/_form.html.erb_spec.rb | 2 +- spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb | 2 +- 19 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/controllers/concerns/hyrax/controller.rb b/app/controllers/concerns/hyrax/controller.rb index e8de37f936..6004c14825 100644 --- a/app/controllers/concerns/hyrax/controller.rb +++ b/app/controllers/concerns/hyrax/controller.rb @@ -47,7 +47,7 @@ def search_service(**search_params) search_service_class.new(config: blacklight_config, scope: self, user_params: search_params, - search_builder_class: search_builder_class) + search_builder_class: blacklight_config.search_builder_class) end private diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 9adc098ac4..b73be04ca7 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -13,6 +13,7 @@ module WorksControllerBehavior before_action do blacklight_config.track_search_session = false + blacklight_config.search_builder_class = search_builder_class end class_attribute :_curation_concern_type, :show_presenter, :work_form_service, :search_builder_class diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index eac9890a7a..52e81d2a5f 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -513,7 +513,7 @@ def form form.prepopulate! form else - form_class.new(@collection, current_ability, repository) + form_class.new(@collection, current_ability, blacklight_config.repository) end end diff --git a/app/controllers/hyrax/file_sets_controller.rb b/app/controllers/hyrax/file_sets_controller.rb index e0f7eeb934..39576753af 100644 --- a/app/controllers/hyrax/file_sets_controller.rb +++ b/app/controllers/hyrax/file_sets_controller.rb @@ -243,7 +243,7 @@ def curation_concern_document end def single_item_search_service - Hyrax::SearchService.new(config: blacklight_config, user_params: params.except(:q, :page), scope: self, search_builder_class: search_builder_class) + Hyrax::SearchService.new(config: blacklight_config, user_params: params.except(:q, :page), scope: self, search_builder_class: blacklight_config.search_builder_class) end def wants_to_revert? diff --git a/app/helpers/hyrax/hyrax_helper_behavior.rb b/app/helpers/hyrax/hyrax_helper_behavior.rb index 4924ecb073..b7d75bc479 100644 --- a/app/helpers/hyrax/hyrax_helper_behavior.rb +++ b/app/helpers/hyrax/hyrax_helper_behavior.rb @@ -289,7 +289,7 @@ def collection_thumbnail(_document, _image_options = {}, _url_options = {}) end def collection_title_by_id(id) - solr_docs = controller.repository.find(id).docs + solr_docs = controller.blacklight_config.repository.find(id).docs return nil if solr_docs.empty? solr_field = solr_docs.first["title_tesim"] return nil if solr_field.nil? diff --git a/app/services/hyrax/admin_set_service.rb b/app/services/hyrax/admin_set_service.rb index 062ab34c99..9baa6d5de7 100644 --- a/app/services/hyrax/admin_set_service.rb +++ b/app/services/hyrax/admin_set_service.rb @@ -15,7 +15,7 @@ def initialize(context, search_builder = default_search_builder) # @param [Symbol] access :deposit, :read or :edit def search_results(access) - response = context.repository.search(builder(access)) + response = context.blacklight_config.repository.search(builder(access)) response.documents end diff --git a/app/services/hyrax/collections/nested_collection_query_service.rb b/app/services/hyrax/collections/nested_collection_query_service.rb index 2d96bf1b9a..892b3d82c2 100644 --- a/app/services/hyrax/collections/nested_collection_query_service.rb +++ b/app/services/hyrax/collections/nested_collection_query_service.rb @@ -51,7 +51,7 @@ def self.available_parent_collections(child:, scope:, limit_to_id: nil) def self.parent_collections(child:, scope:, page: 1) return [] unless nestable?(collection: child) query_builder = Hyrax::NestedCollectionsParentSearchBuilder.new(scope: scope, child: child, page: page) - scope.repository.search(query_builder.query) + scope.blacklight_config.repository.search(query_builder.query) end ## @@ -73,7 +73,7 @@ def self.query_solr(collection:, access:, scope:, limit_to_id:, nest_direction:) ) query_builder.where(id: limit_to_id.to_s) if limit_to_id - scope.repository.search(query_builder.query) + scope.blacklight_config.repository.search(query_builder.query) end private_class_method :query_solr diff --git a/app/services/hyrax/restriction_service.rb b/app/services/hyrax/restriction_service.rb index 92a3130785..d2a7d93630 100644 --- a/app/services/hyrax/restriction_service.rb +++ b/app/services/hyrax/restriction_service.rb @@ -18,7 +18,7 @@ def presenters(builder) end def repository - config.repository + config.blacklight_config.repository end def config diff --git a/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb b/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb index 771e9600b6..3e1cd1521e 100644 --- a/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb @@ -15,7 +15,7 @@ before { sign_in(user) } its(:blacklight_config) { is_expected.to be_a(Blacklight::Configuration) } - its(:repository) { is_expected.to be_a(Blacklight::Solr::Repository) } + its('blacklight_config.repository') { is_expected.to be_a(Blacklight::Solr::Repository) } let(:form_class_base) do Class.new do diff --git a/spec/controllers/hyrax/dashboard/works_controller_spec.rb b/spec/controllers/hyrax/dashboard/works_controller_spec.rb index 26955bc6a1..2175881d46 100644 --- a/spec/controllers/hyrax/dashboard/works_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/works_controller_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Hyrax::Dashboard::WorksController, type: :controller do describe "#search_builder_class" do - subject { controller.search_builder_class } + subject { controller.blacklight_config.search_builder_class } it { is_expected.to eq Hyrax::Dashboard::WorksSearchBuilder } end diff --git a/spec/controllers/hyrax/my/collections_controller_spec.rb b/spec/controllers/hyrax/my/collections_controller_spec.rb index b8d1f2e110..b55de45645 100644 --- a/spec/controllers/hyrax/my/collections_controller_spec.rb +++ b/spec/controllers/hyrax/my/collections_controller_spec.rb @@ -30,7 +30,7 @@ end describe "#search_builder_class" do - subject { controller.search_builder_class } + subject { controller.blacklight_config.search_builder_class } it { is_expected.to eq Hyrax::My::CollectionsSearchBuilder } end diff --git a/spec/controllers/hyrax/my/works_controller_spec.rb b/spec/controllers/hyrax/my/works_controller_spec.rb index 60933c556c..de1863a2bb 100644 --- a/spec/controllers/hyrax/my/works_controller_spec.rb +++ b/spec/controllers/hyrax/my/works_controller_spec.rb @@ -29,7 +29,7 @@ end describe "#search_builder_class" do - subject { controller.search_builder_class } + subject { controller.blacklight_config.search_builder_class } it { is_expected.to eq Hyrax::My::WorksSearchBuilder } end diff --git a/spec/forms/hyrax/forms/admin_set_form_spec.rb b/spec/forms/hyrax/forms/admin_set_form_spec.rb index cfdf6ccc0b..8e137bfe9a 100644 --- a/spec/forms/hyrax/forms/admin_set_form_spec.rb +++ b/spec/forms/hyrax/forms/admin_set_form_spec.rb @@ -65,7 +65,7 @@ describe '#select_files' do subject { form.select_files } - let(:repository) { Hyrax::CollectionsController.new.repository } + let(:repository) { Hyrax::CollectionsController.new.blacklight_config.repository } context 'without any works/files attached' do let(:model) { create(:admin_set) } diff --git a/spec/forms/hyrax/forms/collection_form_spec.rb b/spec/forms/hyrax/forms/collection_form_spec.rb index a9c122a904..65cf7d0719 100644 --- a/spec/forms/hyrax/forms/collection_form_spec.rb +++ b/spec/forms/hyrax/forms/collection_form_spec.rb @@ -157,7 +157,7 @@ subject { form.select_files } let(:collection) { create(:collection) } - let(:repository) { Hyrax::CollectionsController.new.repository } + let(:repository) { Hyrax::CollectionsController.new.blacklight_config.repository } context 'without any works/files attached' do it { is_expected.to be_empty } diff --git a/spec/helpers/hyrax_helper_spec.rb b/spec/helpers/hyrax_helper_spec.rb index 5c41f845bb..22d31c177b 100644 --- a/spec/helpers/hyrax_helper_spec.rb +++ b/spec/helpers/hyrax_helper_spec.rb @@ -368,7 +368,8 @@ def new_state let(:repository) { double } before do - allow(controller).to receive(:repository).and_return(repository) + allow(controller).to receive(:blacklight_config).and_return(CatalogController.blacklight_config) + allow(controller.blacklight_config).to receive(:repository).and_return(repository) allow(solr_doc).to receive(:[]).with("title_tesim").and_return(["Collection of Awesomeness"]) allow(bad_solr_doc).to receive(:[]).with("title_tesim").and_return(nil) allow(repository).to receive(:find).with("abcd12345").and_return(solr_response) diff --git a/spec/services/hyrax/admin_set_service_spec.rb b/spec/services/hyrax/admin_set_service_spec.rb index a4451f3526..f2a2692580 100644 --- a/spec/services/hyrax/admin_set_service_spec.rb +++ b/spec/services/hyrax/admin_set_service_spec.rb @@ -3,7 +3,7 @@ let(:controller) { ::CatalogController.new } let(:context) do double(current_ability: Ability.new(user), - repository: controller.repository, + repository: controller.blacklight_config.repository, blacklight_config: controller.blacklight_config, search_state_class: nil) end diff --git a/spec/services/hyrax/collections_service_spec.rb b/spec/services/hyrax/collections_service_spec.rb index 97f7e5d186..5e28fcf360 100644 --- a/spec/services/hyrax/collections_service_spec.rb +++ b/spec/services/hyrax/collections_service_spec.rb @@ -4,7 +4,7 @@ let(:context) do double(current_ability: Ability.new(user1), - repository: controller.repository, + repository: controller.blacklight_config.repository, params: {}, blacklight_config: controller.blacklight_config) end diff --git a/spec/views/hyrax/base/_form.html.erb_spec.rb b/spec/views/hyrax/base/_form.html.erb_spec.rb index 67813f017e..7970bb1352 100644 --- a/spec/views/hyrax/base/_form.html.erb_spec.rb +++ b/spec/views/hyrax/base/_form.html.erb_spec.rb @@ -11,7 +11,7 @@ allow(view).to receive(:curation_concern).and_return(work) assign(:form, form) allow(controller).to receive(:action_name).and_return(controller_action) - allow(controller).to receive(:repository).and_return(controller_class.new.repository) + allow(controller).to receive(:repository).and_return(controller_class.new.blacklight_config.repository) allow(controller).to receive(:blacklight_config).and_return(controller_class.new.blacklight_config) allow(controller).to receive(:controller_name).and_return('batch_uploads') diff --git a/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb b/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb index e10ed072bf..2dc2dc2bb1 100644 --- a/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb +++ b/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb @@ -15,7 +15,7 @@ # Tell rspec where to find form_* partials view.lookup_context.prefixes << 'hyrax/base' allow(controller).to receive(:current_user).and_return(stub_model(User)) - allow(controller).to receive(:repository).and_return(controller_class.new.repository) + allow(controller).to receive(:repository).and_return(controller_class.new.blacklight_config.repository) allow(controller).to receive(:blacklight_config).and_return(controller_class.new.blacklight_config) # mock the admin set options presenter to avoid hitting Solr allow(Hyrax::AdminSetOptionsPresenter).to receive(:new).and_return(options_presenter)