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

use the ActiveModel::Name#human instead of #to_s for human names #5625

Merged
merged 1 commit into from
May 12, 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: 1 addition & 1 deletion app/presenters/hyrax/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def presenter_types
def grouped_presenters(filtered_by: nil, except: nil)
# TODO: we probably need to retain collection_presenters (as parent_presenters)
# and join this with member_of_collection_presenters
grouped = member_of_collection_presenters.group_by(&:model_name).transform_keys { |key| key.to_s.underscore }
grouped = member_of_collection_presenters.group_by(&:model_name).transform_keys(&:human)
grouped.select! { |obj| obj.downcase == filtered_by } unless filtered_by.nil?
grouped.except!(*except) unless except.nil?
grouped
Expand Down
17 changes: 17 additions & 0 deletions spec/presenters/hyrax/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,23 @@
end
end

describe "#grouped_presenters" do
let(:collections) do
[FactoryBot.valkyrie_create(:hyrax_collection),
FactoryBot.valkyrie_create(:hyrax_collection)]
end

before do
allow(presenter)
.to receive(:member_of_authorized_parent_collections)
.and_return collections.map(&:id).map(&:to_s)
end

it "groups the presenters with the human version of the model name" do
expect(presenter.grouped_presenters.keys).to contain_exactly("Collection")
end
end

describe "#show_deposit_for?" do
context "when user has depositable collections" do
let(:user_collections) { double }
Expand Down