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

check if user can create based on configured collection model #5273

Merged
merged 1 commit into from
Dec 7, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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