Skip to content

Commit

Permalink
Merge pull request #5273 from samvera/fix/5272_missing_new_collection…
Browse files Browse the repository at this point in the history
…_button

check if user can create based on configured collection model
  • Loading branch information
elrayle committed Dec 7, 2021
2 parents 3ba11bf + ef4adc7 commit 58e014e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/views/hyrax/my/collections/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Page tabs -->
<nav><%= render 'tabs' if @managed_collection_count > 0 %></nav>

<% if can?(:create_any, Collection) && @collection_type_list_presenter.any? %>
<% if can?(:create_any, Hyrax.config.collection_class) && @collection_type_list_presenter.any? %>
<% if @collection_type_list_presenter.many? %>
<% # modal to select type %>
<button type="button"
Expand Down
37 changes: 28 additions & 9 deletions spec/features/create_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,36 @@

context "when the user is not an admin" do
context "and user does not have permissions to create managed collection type" do
before do
sign_in user
click_link('Collections', match: :first)
context "and collection model is an ActiveFedora::Base" do
before do
allow(Hyrax.config).to receive(:collection_model).and_return('::Collection')
sign_in user
click_link('Collections', match: :first)
end

it 'user is not offered the option to create that type of collection' do
# try and create the new admin set
click_button "New Collection"
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
end
end

it 'user is not offered the option to create that type of collection' do
# try and create the new admin set
click_button "New Collection"
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
context "and collection model is a Valkyrie::Resource" do
before do
allow(Hyrax.config).to receive(:collection_model).and_return('Hyrax::PcdmCollection')
sign_in user
click_link('Collections', match: :first)
end

it 'user is not offered the option to create that type of collection' do
# try and create the new admin set
click_button "New Collection"
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
end
end
end

Expand Down

0 comments on commit 58e014e

Please sign in to comment.