From 2f13f011af30ee8c5af3660f68311019a44ff3d9 Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Fri, 13 Apr 2018 14:47:05 -0400 Subject: [PATCH] limit the explosure of the permissions_attributes deprecation warning for collections Moved the deprecation down so users will only see it if they pass in read/edit permissions in the permissions_attributes. This deprecation will never be triggered through the UI. It is triggered through tests that confirm the older style permission parameters (e.g. read, edit) are correctly converted to the new style (e.g. manage, deposit, view). --- app/controllers/hyrax/dashboard/collections_controller.rb | 3 ++- .../controllers/hyrax/dashboard/collections_controller_spec.rb | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index e9bac01971..ea17c5a532 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -337,9 +337,10 @@ def collection_params def extract_old_style_permission_attributes(attributes) # TODO: REMOVE in 3.0 - part of deprecation of permission attributes - Deprecation.warn(self, "passing in permissions with a new collection is deprecated and will be removed from Hyrax 3.0 ()") # TODO: elr - add alternative in () permissions = attributes.delete("permissions_attributes") return [] unless permissions + Deprecation.warn(self, "Passing in permissions_attributes parameter with a new collection is deprecated and support will be removed from Hyrax 3.0. " \ + "Use Hyrax::PermissionTemplate instead to grant Manage, Deposit, or View access.") participants = [] permissions.each do |p| access = access(p) diff --git a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb index 51cb68934e..9d6a3c0716 100644 --- a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb @@ -39,6 +39,9 @@ post :create, params: { collection: collection_attrs.merge( visibility: 'open', + # TODO: Tests with old approach to sharing a collection which is deprecated and + # will be removed in 3.0. New approach creates a PermissionTemplate with + # source_id = the collection's id. permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }]