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 class attribute from CollectionType #5742

Merged
merged 3 commits into from
Nov 30, 2022
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
16 changes: 0 additions & 16 deletions app/models/hyrax/collection_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ def title=(value)
assign_machine_id
end

# this class attribute is deprecated in favor of {.settings_attributes}
# these need to carefully align with boolean flag attributes/table columns,
# so making it settable is a liability. deprecating is challenging because
# +class_attribute+ calls +singleton_class.class_eval { redefine_method }+
# as the +name=+ implementation. there should be few callers outside hyrax.
class_attribute :collection_type_settings_methods, instance_writer: false
self.collection_type_settings_methods = SETTINGS_ATTRIBUTES

# These are provided as a convenience method based on prior design discussions.
alias_attribute :discovery, :discoverable
alias_attribute :sharing, :sharable
Expand Down Expand Up @@ -123,14 +115,6 @@ def collections(use_valkyrie: Hyrax.config.use_valkyrie?)
ActiveFedora::Base.where(Hyrax.config.collection_type_index_field.to_sym => to_global_id.to_s)
end

##
# @deprecated Use #collections.any? instead
#
# @return [Boolean] True if there is at least one collection of this type
def collections?
Deprecation.warn('Use #collections.any? instead.') && collections.any?
end

# @return [Boolean] True if this is the Admin Set type
def admin_set?
machine_id == ADMIN_SET_MACHINE_ID
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
end

it 'all settings are disabled', :js do
expect(exhibit_collection_type.collections?).to be true
expect(exhibit_collection_type.collections.any?).to be true

click_link('Settings', href: '#settings')

Expand Down
16 changes: 1 addition & 15 deletions spec/models/hyrax/collection_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
let!(:collection) { FactoryBot.valkyrie_create(:hyrax_collection, collection_type_gid: collection_type.to_global_id.to_s) }
end

describe '.collection_type_settings_methods' do
it 'lists collection settings methods' do # deprecated
expect(described_class.collection_type_settings_methods)
.to include(:nestable?, :discoverable?, :brandable?)
end
end

describe '#collection_type_settings_methods' do
it 'lists collection settings methods' do # deprecated
expect(collection_type.collection_type_settings_methods)
.to include(:nestable?, :discoverable?, :brandable?)
end
end

describe '.settings_attributes' do
it 'lists collection settings methods' do
expect(described_class.settings_attributes)
Expand Down Expand Up @@ -203,7 +189,7 @@
end
end

describe "collections?", :clean_repo do
describe "collections.any?", :clean_repo do
let(:collection_type) { FactoryBot.create(:collection_type) }

it 'returns true if there are any collections of this collection type' do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/matchers/collection_type_property_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

RSpec::Matchers.define :have_collections do
match do |actual|
actual&.collections?
actual&.collections&.any?
end
end