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

remove deprecated methods from CollectionBehavior #5744

Merged
merged 2 commits into from
Mar 8, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions app/models/concerns/hyrax/collection_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ def collection_type=(new_collection_type)
self.collection_type_gid = new_collection_type.to_global_id
end

# Add members using the members association.
def add_members(new_member_ids)
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
new_member_ids: new_member_ids,
user: nil)
end

# Add member objects by adding this collection to the objects' member_of_collection association.
# @param [Enumerable<String>] the ids of the new child collections and works collection ids
def add_member_objects(new_member_ids)
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
new_member_ids: new_member_ids,
user: nil)
end

# @return [Enumerable<ActiveFedora::Base>] an enumerable over the children of this collection
def member_objects
ActiveFedora::Base.where("member_of_collection_ids_ssim:#{id}")
Expand All @@ -96,22 +77,6 @@ def _to_partial_path # :nodoc:
"hyrax/#{collection}/#{element}"
end
end

def collection_type_gid_document_field_name
Deprecation.warn('use Hyrax.config.collection_type_index_field instead')
Hyrax.config.collection_type_index_field
end
end

# @deprecated to be removed in 4.0.0; this feature was replaced with a
# hard-coded null implementation
# @return [Fixnum] 0
def bytes
Deprecation.warn('#bytes has been deprecated for removal in Hyrax 4.0.0; ' \
'The implementation of the indexed Collection size ' \
'feature is extremely inefficient, so it has been removed. ' \
'This method now returns a hard-coded `0` for compatibility.')
0
end

# @api public
Expand All @@ -122,18 +87,6 @@ def permission_template
Hyrax::PermissionTemplate.find_by!(source_id: id)
end

##
# @deprecated use PermissionTemplate#reset_access_controls_for instead
#
# Calculate and update who should have read/edit access to the collections based on who
# has access in PermissionTemplateAccess
def reset_access_controls!
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.")

permission_template
.reset_access_controls_for(collection: self, interpret_visibility: true)
end

private

# Solr field name works use to index member ids
Expand Down
4 changes: 2 additions & 2 deletions spec/abilities/collection_ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
permission_template: collection.permission_template,
agent_type: 'user',
agent_id: manager.user_key)
collection.reset_access_controls!
collection.permission_template.reset_access_controls_for(collection: collection)
end

it 'can do everything for the collection they manage' do
Expand Down Expand Up @@ -280,7 +280,7 @@
permission_template: collection.permission_template,
agent_type: 'user',
agent_id: viewer.user_key)
collection.reset_access_controls!
collection.permission_template.reset_access_controls_for(collection: collection)
end

it 'can view the collection where they are a viewer' do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/collections_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
attributes[:manage_users] = CollectionFactoryHelper.user_managers(evaluator.with_permission_template, evaluator.user, evaluator.create_access)
attributes = evaluator.with_permission_template.merge(attributes) if evaluator.with_permission_template.respond_to?(:merge)
create(:permission_template, attributes) unless Hyrax::PermissionTemplate.find_by(source_id: collection.id)
collection.reset_access_controls!
collection.permission_template.reset_access_controls_for(collection: collection, interpret_visibility: true)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/features/dashboard/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@
permission_template: collection1.permission_template,
agent_type: 'user',
agent_id: user2.user_key)
collection1.reset_access_controls!
collection1.permission_template.reset_access_controls_for(collection: collection1, interpret_visibility: true)
create(:permission_template_access,
:deposit,
permission_template: collection2.permission_template,
agent_type: 'user',
agent_id: user2.user_key)
collection2.reset_access_controls!
collection2.permission_template.reset_access_controls_for(collection: collection2, interpret_visibility: true)
create(:permission_template_access,
:view,
permission_template: collection4.permission_template,
agent_type: 'user',
agent_id: user2.user_key)
collection4.reset_access_controls!
collection4.permission_template.reset_access_controls_for(collection: collection4, interpret_visibility: true)
sign_in user2
visit '/dashboard/my/collections'
end
Expand Down
15 changes: 4 additions & 11 deletions spec/models/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
expect(collection.read_groups).to eq ['public']
end

describe '#bytes' do
it 'returns a hard-coded integer and issues a deprecation warning' do
expect(Deprecation).to receive(:warn).at_least(:once)
expect(collection.bytes).to eq(0)
end
end

describe "#validates_with" do
before { collection.title = nil }
it "ensures the collection has a title" do
Expand Down Expand Up @@ -226,25 +219,25 @@ class Member < ActiveFedora::Base

it 'resets user edit access' do
expect(collection.edit_users).to match_array([user.user_key])
collection.reset_access_controls!
permission_template.reset_access_controls_for(collection: collection)
expect(collection.edit_users).to match_array([user.user_key, 'mgr1@ex.com', 'mgr2@ex.com'])
end

it 'resets group edit access' do
expect(collection.edit_groups).to match_array([])
collection.reset_access_controls!
permission_template.reset_access_controls_for(collection: collection)
expect(collection.edit_groups).to match_array(['managers', ::Ability.admin_group_name])
end

it 'resets user read access' do
expect(collection.read_users).to match_array([])
collection.reset_access_controls!
permission_template.reset_access_controls_for(collection: collection)
expect(collection.read_users).to match_array(['vw1@ex.com', 'vw2@ex.com', 'dep1@ex.com', 'dep2@ex.com'])
end

it 'resets group read access' do
expect(collection.read_groups).to match_array([])
collection.reset_access_controls!
permission_template.reset_access_controls_for(collection: collection)
expect(collection.read_groups).to match_array(['viewers', 'depositors', ::Ability.admin_group_name])
end
end
Expand Down