Skip to content

Commit

Permalink
Stop using the deprecated build_presenters() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 12, 2017
1 parent ba48302 commit 1f6692f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/forms/hyrax/forms/collection_form.rb
Expand Up @@ -53,7 +53,9 @@ def all_files
end

def member_presenters
PresenterFactory.build_presenters(model.member_ids, WorkShowPresenter, nil)
PresenterFactory.build_for(ids: model.member_ids,
presenter_class: WorkShowPresenter,
presenter_args: [nil])
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/forms/hyrax/forms/work_form.rb
Expand Up @@ -126,7 +126,9 @@ def self.workflow_for(admin_set_id:)
# @return [Array<FileSetPresenter>] presenters for the file sets in order of the ids
def file_presenters
@file_sets ||=
Hyrax::PresenterFactory.build_presenters(model.member_ids, FileSetPresenter, current_ability)
Hyrax::PresenterFactory.build_for(ids: model.member_ids,
presenter_class: FileSetPresenter,
presenter_args: current_ability)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/featured_work_list.rb
Expand Up @@ -36,9 +36,9 @@ def ids

def work_presenters
ability = nil
Hyrax::PresenterFactory.build_presenters(ids,
Hyrax::WorkShowPresenter,
ability)
Hyrax::PresenterFactory.build_for(ids: ids,
presenter_class: Hyrax::WorkShowPresenter,
presenter_args: ability)
end

def work_with_id(id)
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/hyrax/file_set_presenter.rb
Expand Up @@ -84,9 +84,9 @@ def parent
ids = ActiveFedora::SolrService.query("{!field f=member_ids_ssim}#{id}",
fl: ActiveFedora.id_field)
.map { |x| x.fetch(ActiveFedora.id_field) }
@parent_presenter ||= Hyrax::PresenterFactory.build_presenters(ids,
WorkShowPresenter,
current_ability).first
@parent_presenter ||= Hyrax::PresenterFactory.build_for(ids: ids,
presenter_class: WorkShowPresenter,
presenter_args: current_ability).first
end

def fixity_check_service
Expand Down
4 changes: 3 additions & 1 deletion app/presenters/hyrax/member_presenter_factory.rb
Expand Up @@ -21,7 +21,9 @@ def initialize(work, ability, request = nil)
# @param [Class] presenter_class the type of presenter to build
# @return [Array<presenter_class>] presenters for the ordered_members (not filtered by class)
def member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class)
PresenterFactory.build_presenters(ids, presenter_class, *presenter_factory_arguments)
PresenterFactory.build_for(ids: ids,
presenter_class: presenter_class,
presenter_args: presenter_factory_arguments)
end

# @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
Expand Down
5 changes: 1 addition & 4 deletions app/presenters/hyrax/presenter_factory.rb
Expand Up @@ -21,10 +21,7 @@ def build_for(ids:, presenter_class:, presenter_args: [])
# @param [Array] args any other arguments to pass to the presenters
# @return [Array] presenters for the documents in order of the ids
def build_presenters(ids, klass, *args)
Deprecation.warn(to_s,
Deprecation.deprecated_method_warning(to_s,
:build_presenters,
"use .build_for instead"))
Deprecation.warn(self, "build_presenters is deprecated and will be removed from Hyrax 3.0 (use .build_for instead)")
build_for(ids: ids, presenter_class: klass, presenter_args: args)
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/hyrax/work_show_presenter.rb
Expand Up @@ -64,9 +64,9 @@ def representative_presenter
# Get presenters for the collections this work is a member of via the member_of_collections association.
# @return [Array<CollectionPresenter>] presenters
def member_of_collection_presenters
PresenterFactory.build_presenters(member_of_collection_ids,
collection_presenter_class,
*presenter_factory_arguments)
PresenterFactory.build_for(ids: member_of_collection_ids,
presenter_class: collection_presenter_class,
presenter_args: presenter_factory_arguments)
end

def date_modified
Expand Down
6 changes: 4 additions & 2 deletions spec/presenters/hyrax/member_presenter_factory_spec.rb
Expand Up @@ -16,8 +16,10 @@
end

it "uses the set class" do
expect(Hyrax::PresenterFactory).to receive(:build_presenters)
.with(['12', '33'], presenter_class, ability, request)
expect(Hyrax::PresenterFactory).to receive(:build_for)
.with(ids: ['12', '33'],
presenter_class: presenter_class,
presenter_args: [ability, request])
factory.file_set_presenters
end
end
Expand Down
7 changes: 5 additions & 2 deletions spec/presenters/hyrax/work_show_presenter_spec.rb
Expand Up @@ -175,8 +175,11 @@
let(:obj) { create(:work_with_representative_file) }
let(:attributes) { obj.to_solr }
it "has a representative" do
expect(Hyrax::PresenterFactory).to receive(:build_presenters)
.with([obj.members[0].id], Hyrax::CompositePresenterFactory, ability, request).and_return ["abc"]
expect(Hyrax::PresenterFactory).to receive(:build_for)
.with(ids: [obj.members[0].id],
presenter_class: Hyrax::CompositePresenterFactory,
presenter_args: [ability, request])
.and_return ["abc"]
expect(presenter.representative_presenter).to eq("abc")
end
end
Expand Down

0 comments on commit 1f6692f

Please sign in to comment.