Skip to content

Commit

Permalink
Cleanup use of removed compatibility methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpierce committed Mar 29, 2023
1 parent 8a7800e commit d5b8a61
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/hyrax/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hyrax/dashboard/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hyrax/file_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/hyrax/hyrax_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/admin_set_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/restriction_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def presenters(builder)
end

def repository
config.repository
config.blacklight_config.repository
end

def config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/hyrax/dashboard/works_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/hyrax/my/collections_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/hyrax/my/works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/forms/hyrax/forms/admin_set_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion spec/forms/hyrax/forms/collection_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 2 additions & 1 deletion spec/helpers/hyrax_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/services/hyrax/admin_set_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/services/hyrax/collections_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/views/hyrax/base/_form.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d5b8a61

Please sign in to comment.