Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Fix manifest permissions after LAE change. (#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Pendragon authored and Jon Stroop committed May 20, 2017
1 parent 0264656 commit e91a6f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def ephemera_editor_permissions
can [:manage], EphemeraFolder
can [:create, :read, :edit, :update, :publish], Collection
can [:create, :read, :edit, :update, :publish, :download], FileSet
can [:manifest], EphemeraFolderPresenter
can [:destroy], FileSet, depositor: current_user.uid
end

Expand Down Expand Up @@ -93,6 +94,9 @@ def curation_concern_read_permissions
cannot [:read], curation_concerns do |curation_concern|
!readable_concern?(curation_concern)
end
can [:manifest], [ScannedResourceShowPresenter, MultiVolumeWorkShowPresenter, EphemeraFolderPresenter] do |curation_concern|
readable_concern?(curation_concern)
end
cannot [:manifest], EphemeraFolder do |folder|
folder.workflow_state == "needs_qa"
end
Expand Down Expand Up @@ -127,7 +131,7 @@ def universal_reader?
end

def curation_concerns
Hyrax.config.curation_concerns
Hyrax.config.curation_concerns + [ScannedResourceShowPresenter, MultiVolumeWorkShowPresenter, EphemeraFolderPresenter]
end

def roles
Expand Down
11 changes: 11 additions & 0 deletions spec/ability/roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
let(:role) { Role.where(name: 'admin').first_or_create }
let(:solr) { ActiveFedora.solr.conn }

def presenter(resource)
DynamicShowPresenter.new.new(SolrDocument.new(resource.to_solr), subject)
end

before do
allow(open_scanned_resource).to receive(:id).and_return("open")
allow(private_scanned_resource).to receive(:id).and_return("private")
Expand Down Expand Up @@ -161,6 +165,9 @@
should be_able_to(:update, other_ephemera_folder)
should be_able_to(:destroy, other_ephemera_folder)

should be_able_to(:manifest, presenter(complete_ephemera_folder))
should be_able_to(:manifest, presenter(needs_qa_ephemera_folder))

should_not be_able_to(:create, Role.new)
should_not be_able_to(:destroy, role)
should_not be_able_to(:complete, pending_scanned_resource)
Expand All @@ -186,6 +193,7 @@
should be_able_to(:read, complete_scanned_resource)
should be_able_to(:read, takedown_scanned_resource)
should be_able_to(:read, flagged_scanned_resource)
should be_able_to(:manifest, pending_scanned_resource)
should be_able_to(:download, image_editor_file)
should be_able_to(:file_manager, open_scanned_resource)
should be_able_to(:file_manager, open_multi_volume_work)
Expand All @@ -196,6 +204,8 @@
should be_able_to(:destroy, image_editor_file)
should be_able_to(:destroy, pending_scanned_resource)

should be_able_to(:manifest, presenter(pending_scanned_resource))

should_not be_able_to(:create, Role.new)
should_not be_able_to(:destroy, role)
should_not be_able_to(:complete, pending_scanned_resource)
Expand Down Expand Up @@ -382,6 +392,7 @@
should be_able_to(:pdf, open_scanned_resource)
should be_able_to(:read, complete_scanned_resource)
should be_able_to(:manifest, complete_scanned_resource)
should be_able_to(:manifest, presenter(complete_scanned_resource))
should be_able_to(:read, flagged_scanned_resource)
should be_able_to(:manifest, flagged_scanned_resource)
should be_able_to(:color_pdf, color_enabled_resource)
Expand Down

0 comments on commit e91a6f4

Please sign in to comment.