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 various deprecated methods with 4.0 and earlier time horizons #6203

Merged
merged 6 commits into from
Aug 24, 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
32 changes: 1 addition & 31 deletions app/models/admin_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ class AdminSet < ActiveFedora::Base
before_destroy :check_if_not_default_set, :check_if_empty
after_destroy :destroy_permission_template

def self.default_set?(id)
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
Hyrax::AdminSetCreateService.default_admin_set?(id: id)
end

def default_set?
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
self.class.default_set?(id)
end

# Creates the default AdminSet and an associated PermissionTemplate with workflow
def self.find_or_create_default_admin_set_id
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
"Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.")
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
end

def collection_type_gid
# allow AdminSet to behave more like a regular Collection
Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
Expand All @@ -86,17 +67,6 @@ def active_workflow
Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
end

##
# @deprecated use PermissionTemplate#reset_access_controls_for instead
#
# Calculate and update who should have edit access based on who
# has "manage" access in the 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)
end

# @api public
#
# return an id for the AdminSet.
Expand All @@ -120,7 +90,7 @@ def check_if_empty
end

def check_if_not_default_set
return true unless default_set?
return true unless Hyrax::AdminSetCreateService.default_admin_set?(id: id)
errors[:base] << I18n.t('hyrax.admin.admin_sets.delete.error_default_set')
throw :abort
end
Expand Down
14 changes: 1 addition & 13 deletions app/models/hyrax/collection_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def self.find_by_gid(gid)
# @see #gid
# @see Hyrax::MultipleMembershipChecker
def self.gids_that_do_not_allow_multiple_membership
where(allow_multiple_membership: false).map(&:gid)
where(allow_multiple_membership: false).map { |c| c.to_global_id.to_s }
end

# Find the collection type associated with the Global Identifier (gid)
Expand Down Expand Up @@ -98,18 +98,6 @@ def self.settings_attributes
SETTINGS_ATTRIBUTES
end

##
# @deprecation use #to_global_id
#
# Return the Global Identifier for this collection type.
# @return [String, nil] Global Identifier (gid) for this collection_type (e.g. gid://internal/hyrax-collectiontype/3)
#
# @see https://github.com/rails/globalid#usage
def gid
Deprecation.warn('use #to_global_id.')
to_global_id.to_s if id
end

##
# @return [Enumerable<Collection, PcdmCollection>]
def collections(use_valkyrie: Hyrax.config.use_valkyrie?)
Expand Down
7 changes: 0 additions & 7 deletions app/presenters/hyrax/presenter_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ def label(field)
default: [:"defaults.#{field}", field.to_s.humanize]).presence
end

##
# @deprecated
def fields(terms, &_block)
Deprecation.warn("Fields is deprecated for removal in Hyrax 4.0.0. use #value and #label directly instead.")
@view_context.safe_join(terms.map { |term| yield self, term })
end

private

def render_show_field_partial(field_name, locals)
Expand Down
10 changes: 0 additions & 10 deletions app/presenters/hyrax/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,6 @@ def list_of_item_ids_to_display
paginated_item_list(page_array: authorized_item_ids)
end

##
# @deprecated use `#member_presenters(ids)` instead
#
# @param [Array<String>] ids a list of ids to build presenters for
# @return [Array<presenter_class>] presenters for the array of ids (not filtered by class)
def member_presenters_for(an_array_of_ids)
Deprecation.warn("Use `#member_presenters` instead.")
member_presenters(an_array_of_ids)
end

# @return [Integer] total number of pages of viewable items
def total_pages
(total_items.to_f / rows_from_params.to_f).ceil
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_items.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<% array_of_ids = presenter.list_of_item_ids_to_display %>
<% members = presenter.member_presenters_for(array_of_ids) %>
<% members = presenter.member_presenters(array_of_ids) %>
<% if members.present? %>
<table class="table table-striped related-files">
<thead>
Expand Down
85 changes: 0 additions & 85 deletions spec/models/admin_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,55 +112,6 @@
end
end

describe ".default_set?", :clean_repo do
before { FactoryBot.valkyrie_create(:default_hyrax_admin_set) }
context "with default AdminSet ID" do
it "returns true" do
expect(described_class.default_set?(described_class::DEFAULT_ID)).to be true
end
end

context "with a non-default ID" do
it "returns false" do
expect(described_class.default_set?('different-id')).to be false
end
end
end

describe "#default_set?", :clean_repo do
let(:default_admin_set) do
administrative_set = FactoryBot.valkyrie_create(:default_hyrax_admin_set)
Wings::ActiveFedoraConverter.new(resource: administrative_set).convert
end
context "with default AdminSet ID" do
subject { default_admin_set.default_set? }

it { is_expected.to be_truthy }
end

context "with a non-default ID" do
subject { described_class.new(id: 'why-would-you-name-the-default-chupacabra?').default_set? }

it { is_expected.to be_falsey }
end
end

describe ".find_or_create_default_admin_set_id" do
subject { described_class.find_or_create_default_admin_set_id }

let(:default_admin_set) { build(:default_hyrax_admin_set) }

before do
allow(Hyrax::AdminSetCreateService).to receive(:find_or_create_default_admin_set)
.and_return(default_admin_set)
end

it 'gets the default admin set from the create service and returns the DEFAULT_ID' do
expect(Hyrax::AdminSetCreateService).to receive(:find_or_create_default_admin_set)
expect(subject).to eq(described_class::DEFAULT_ID)
end
end

describe "#destroy" do
context "with member works" do
before do
Expand Down Expand Up @@ -227,40 +178,4 @@
end
end
end

describe '#reset_access_controls!' do
let!(:user) { build(:user) }
let!(:admin_set) { create(:admin_set, creator: [user.user_key], edit_users: [user.user_key], edit_groups: [::Ability.admin_group_name], read_users: [], read_groups: ['public']) }
let!(:permission_template) { build(:permission_template) }

before do
allow(admin_set).to receive(:permission_template).and_return(permission_template)
allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'user').and_return(['mgr1@ex.com', 'mgr2@ex.com', user.user_key])
allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'group').and_return(['managers', ::Ability.admin_group_name])
allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'user').and_return(['dep1@ex.com', 'dep2@ex.com'])
allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'group').and_return(['depositors', 'registered'])
allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'user').and_return(['vw1@ex.com', 'vw2@ex.com'])
allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'group').and_return(['viewers', 'public'])
end

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

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

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

it 'resets group read access' do
admin_set.reset_access_controls!
expect(admin_set.read_groups).to match_array(['depositors', 'viewers'])
end
end
end
20 changes: 0 additions & 20 deletions spec/models/hyrax/collection_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@
expect(collection_type).not_to assign_visibility
end

describe '#gid' do
it 'returns the gid when id exists' do
collection_type.id = 5
expect(collection_type.gid.to_s).to eq "gid://#{GlobalID.app}/#{described_class}/5"
end

it 'returns nil when id is nil' do
collection_type.id = nil
expect(collection_type.gid).to be_nil
end
end

describe ".any_nestable?" do
context "when there is a nestable collection type" do
let!(:collection_type) { FactoryBot.create(:collection_type, nestable: true) }
Expand Down Expand Up @@ -125,10 +113,6 @@
describe '.find_by_gid' do
let(:collection_type) { FactoryBot.create(:collection_type) }

it 'returns the same collection type the gid exists' do
expect(described_class.find_by_gid(collection_type.gid)).to eq collection_type
end

it 'returns the same collection type with `#to_global_id`' do
expect(described_class.find_by_gid(collection_type.to_global_id)).to eq collection_type
end
Expand All @@ -145,10 +129,6 @@
describe '.find_by_gid!' do
let(:collection_type) { FactoryBot.create(:collection_type) }

it 'returns instance of collection type when one with the gid exists' do
expect(described_class.find_by_gid(collection_type.gid)).to eq collection_type
end

it 'returns the same collection type with `#to_global_id`' do
expect(described_class.find_by_gid!(collection_type.to_global_id)).to eq collection_type
end
Expand Down
4 changes: 2 additions & 2 deletions spec/views/hyrax/base/_items.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

context 'when children are not present' do
let(:member_list) { [] }
let(:presenter) { double(:presenter, list_of_items_to_display: member_list, member_presenters_for: member_list, id: 'the-id', human_readable_type: 'Thing') }
let(:presenter) { double(:presenter, list_of_items_to_display: member_list, member_presenters: member_list, id: 'the-id', human_readable_type: 'Thing') }

before do
expect(presenter).to receive(:list_of_item_ids_to_display).and_return(member_list)
Expand Down Expand Up @@ -40,7 +40,7 @@
stub_template 'hyrax/base/_member.html.erb' => '<%= member %>'
expect(Flipflop).to receive(:hide_private_items?).and_return(:flipflop)
allow(presenter).to receive(:list_of_item_ids_to_display).and_return(member_list)
allow(presenter).to receive(:member_presenters_for).with(member_list).and_return(member_list)
allow(presenter).to receive(:member_presenters).with(member_list).and_return(member_list)
allow(presenter).to receive(:ordered_ids).and_return([])

allow(ability).to receive(:can?).with(:read, child1.id).and_return true
Expand Down