Skip to content

Commit

Permalink
Merge pull request #4963 from samvera/work-show
Browse files Browse the repository at this point in the history
document `WorkShowPresenter#show_deposit_for?(collections:)`
  • Loading branch information
cjcolvar authored May 18, 2021
2 parents 5faf403 + 7b0cd07 commit 7173506
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions app/presenters/hyrax/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,19 @@ def member_count
@member_count ||= member_presenters.count
end

# determine if the user can add this work to a collection
# @param collections [Array<::Collection>] list of collections to which this user can deposit
# @return true if the user can deposit to at least one collection OR if the user can create a collection; otherwise, false
##
# Given a set of collections, which the caller asserts the current ability
# can deposit to, decide whether to display actions to add this work to a
# collection.
#
# By default, this returns `true` if any collections are passed in OR the
# current ability can create a collection.
#
# @param collections [Enumerable<::Collection>, nil] list of collections to
# which the current ability can deposit
#
# @return [Boolean] a flag indicating whether to display collection deposit
# options.
def show_deposit_for?(collections:)
collections.present? || current_ability.can?(:create_any, ::Collection)
end
Expand Down
2 changes: 0 additions & 2 deletions spec/presenters/hyrax/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@
end

describe "#show_deposit_for?" do
subject { presenter }

context "when user has depositable collections" do
let(:user_collections) { double }

Expand Down

0 comments on commit 7173506

Please sign in to comment.